Hi Kevin,

Thank you for your patch, but I can't applied it since I have modified a
lot the playlist.c file and I have started to implement the shuffling.

A few comments on your patch:
* In fact, your patch doesn't do shuffling but random playing: shuffle
is more complicated, a file must only be played once and you have to
store the history since you must be able to get the previous file
played.
* You do not have to use your function *_renumber since you can access
the nth node of an evas_list with the function evas_list_nth_list().

Regards,
MoOm

Le lundi 06 juin 2005 à 18:12 -0400, Kevin Webb a écrit :
> Enlightenment developers,
> 
> I couldn't find a mailing list or website specific to eclair, so I'm
> sending the patch here.  I apologize if this is the wrong place...
> 
> As the name would imply, the patch adds playlist shuffling to eclair.
> 
> pièce jointe document plein texte (eclair-shuffle.patch)
> 
> 
> Index: data/glade/eclair.glade
> ===================================================================
> RCS file: data/glade/eclair.glade,v
> retrieving revision 1.2
> diff -b -u -2 -r1.2 eclair.glade
> --- data/glade/eclair.glade   27 May 2005 21:31:48 -0000      1.2
> +++ data/glade/eclair.glade   6 Jun 2005 04:24:25 -0000
> @@ -254,4 +254,28 @@
>      </widget>
>    </child>
> +
> +  <child>
> +    <widget class="GtkMenuItem" id="options1">
> +      <property name="visible">True</property>
> +      <property name="label" translatable="yes">Options</property>
> +      <property name="use_underline">True</property>
> +      <signal name="activate" handler="on_options1_activate" 
> last_modification_time="Sun, 05 Jun 2005 23:24:01 GMT"/>
> +
> +      <child>
> +     <widget class="GtkMenu" id="options1_menu">
> +
> +       <child>
> +         <widget class="GtkCheckMenuItem" id="toggle_shuffle1">
> +           <property name="visible">True</property>
> +           <property name="label" translatable="yes">Shuffle</property>
> +           <property name="use_underline">True</property>
> +           <property name="active">False</property>
> +           <signal name="activate" handler="toggle_shuffle_handler" 
> last_modification_time="Sun, 05 Jun 2005 23:24:01 GMT"/>
> +         </widget>
> +       </child>
> +     </widget>
> +      </child>
> +    </widget>
> +  </child>
>  </widget>
> 
> Index: src/eclair.c
> ===================================================================
> RCS file: src/eclair.c,v
> retrieving revision 1.19
> diff -b -u -2 -r1.19 eclair.c
> --- src/eclair.c      27 May 2005 20:28:22 -0000      1.19
> +++ src/eclair.c      6 Jun 2005 04:24:26 -0000
> @@ -32,4 +32,5 @@
>     Evas_List *filenames, *l;
>     filenames = NULL;
> +   int shuffle = 0;
>  
>     if (!eclair)
> @@ -72,4 +73,6 @@
>     eclair_dialogs_init(&eclair->dialogs_manager, eclair);
>     eclair_playlist_init(&eclair->playlist, eclair);
> +   if (eclair_config_get_prop_int(&eclair->config, "shuffle", "on", 
> &shuffle))
> +      eclair->playlist.shuffle = shuffle;
>     eclair_playlist_container_set_media_list(eclair->playlist_container, 
> &eclair->playlist.playlist);
>     eclair_subtitles_init(&eclair->subtitles);
> @@ -110,4 +113,9 @@
>        }
>  
> +      if (&eclair->playlist)
> +      {
> +         eclair_config_set_prop_int(&eclair->config, "shuffle", "on", 
> eclair->playlist.shuffle);
> +      }
> +
>        fprintf(stderr, "Eclair: Debug: Destroying create video object 
> thread\n");
>        pthread_join(eclair->video_create_thread, NULL); 
> @@ -372,5 +380,12 @@
>        return;
>     
> +   if (eclair->playlist.shuffle)
> +   {
> +      eclair_playlist_random_as_current(&eclair->playlist);
> +   }
> +   else
> +   {
>     eclair_playlist_next_as_current(&eclair->playlist);
> +   }
>     eclair_play_current(eclair);
>  }
> 
> Index: src/eclair_config.c
> ===================================================================
> RCS file: src/eclair_config.c,v
> retrieving revision 1.8
> diff -b -u -2 -r1.8 eclair_config.c
> --- src/eclair_config.c       27 May 2005 20:28:22 -0000      1.8
> +++ src/eclair_config.c       6 Jun 2005 04:24:26 -0000
> @@ -71,4 +71,5 @@
>     eclair_config_set_prop_int(config, "gui_window", "x", 0);
>     eclair_config_set_prop_int(config, "gui_window", "y", 0);
> +   eclair_config_set_prop_int(config, "shuffle", "on", 0);
>  }
>  
> Index: src/eclair_dialogs.c
> ===================================================================
> RCS file: src/eclair_dialogs.c,v
> retrieving revision 1.9
> diff -b -u -2 -r1.9 eclair_dialogs.c
> --- src/eclair_dialogs.c      29 May 2005 09:27:28 -0000      1.9
> +++ src/eclair_dialogs.c      6 Jun 2005 04:24:26 -0000
> @@ -28,4 +28,6 @@
>  static void _eclair_dialogs_menu_on_remove_all(GtkWidget *widget, gpointer 
> data);
>  
> +static void _eclair_dialogs_options_on_toggle_shuffle(GtkWidget *widget, 
> gpointer data);
> +
>  //Initialize dialogs manager
>  void eclair_dialogs_init(Eclair_Dialogs_Manager *dialogs_manager, Eclair 
> *eclair)
> @@ -147,4 +149,5 @@
>     Eclair_Dialogs_Manager *dialogs_manager;
>     Eclair *eclair;
> +   GtkWidget *shuffle_toggle;
>  
>     if (!(eclair = param))
> @@ -166,4 +169,9 @@
>     glade_xml_signal_connect_data(dialogs_manager->menu_xml, 
> "remove_all_handler", G_CALLBACK(_eclair_dialogs_menu_on_remove_all), eclair);
>  
> +   glade_xml_signal_connect_data(dialogs_manager->menu_xml, 
> "toggle_shuffle_handler", 
> G_CALLBACK(_eclair_dialogs_options_on_toggle_shuffle), eclair);
> +
> +   shuffle_toggle = glade_xml_get_widget(dialogs_manager->menu_xml, 
> "toggle_shuffle1");
> +   gtk_check_menu_item_set_active((GtkCheckMenuItem *) shuffle_toggle, 
> eclair->playlist.shuffle);
> +
>     g_timeout_add(50, _eclair_dialogs_update, dialogs_manager);
>  
> @@ -423,2 +431,20 @@
>     eclair_playlist_empty(&eclair->playlist);
>  }
> +
> +//-------
> +//Options
> +//-------
> +static void _eclair_dialogs_options_on_toggle_shuffle(GtkWidget *widget, 
> gpointer data)
> +{
> +   Eclair *eclair;
> +   gboolean status = 0;
> +
> +   if (!(eclair = data))
> +      return;
> +
> +   status = gtk_check_menu_item_get_active((GtkCheckMenuItem *) widget);
> +   if (status)
> +      eclair->playlist.shuffle = 1;
> +   else
> +      eclair->playlist.shuffle = 0;
> +}
> 
> Index: src/eclair_playlist.c
> ===================================================================
> RCS file: src/eclair_playlist.c,v
> retrieving revision 1.13
> diff -b -u -2 -r1.13 eclair_playlist.c
> --- src/eclair_playlist.c     27 May 2005 20:28:22 -0000      1.13
> +++ src/eclair_playlist.c     6 Jun 2005 04:24:27 -0000
> @@ -3,4 +3,6 @@
>  #include <string.h>
>  #include <stdio.h>
> +#include <stdlib.h>
> +#include <time.h>
>  #include <Evas.h>
>  #include <Ecore_File.h>
> @@ -30,6 +32,9 @@
>     playlist->shuffle = 0;
>     playlist->repeat = 0;
> +   playlist->size = 0;
>     playlist->eclair = eclair;
>     playlist->media_files_destructor_timer = ecore_timer_add(0.05, 
> eclair_playlist_media_files_destructor, playlist);
> +
> +   srand((unsigned) time(NULL));
>  }
>  
> @@ -131,4 +136,24 @@
>  }
>  
> +//(Re)Number the elements of the playlist
> +void eclair_playlist_renumber_elements(Eclair_Playlist *playlist)
> +{
> +   Evas_List *l;
> +   Eclair_Media_File *media_file;
> +   int position = 0;
> +   
> +   if (!playlist)
> +      return;
> +
> +   for (l = playlist->playlist; l; )
> +   {
> +      media_file = l->data;
> +      media_file->playlist_position = position;
> +      ++position;
> +      l = l->next;
> +   }
> +   playlist->size = position;
> +}
> +
>  //Add recursively a directory
>  Evas_Bool eclair_playlist_add_dir(Eclair_Playlist *playlist, char *dir, 
> Evas_Bool update_container, Evas_Bool autoplay)
> @@ -256,4 +281,6 @@
>        eclair_meta_tag_add_file_to_scan(&eclair->meta_tag_manager, 
> new_media_file);
>  
> +   eclair_playlist_renumber_elements(playlist);
> +
>     return 1;   
>  }
> @@ -293,4 +320,6 @@
>        eclair_playlist_container_update(playlist->eclair->playlist_container);
>  
> +   eclair_playlist_renumber_elements(playlist);
> +
>     return next;
>  }
> @@ -401,2 +430,25 @@
>     eclair_playlist_current_set_list(playlist,  playlist->current->next);
>  }
> +
> +//Randomly set the active media file
> +void eclair_playlist_random_as_current(Eclair_Playlist *playlist)
> +{
> +   Evas_List *l;
> +   Eclair_Media_File *media_file;
> +   int position = 0;
> +
> +   if (!playlist)
> +      return;
> +
> +   position = (int) ((rand() / ((double) RAND_MAX + 1)) * playlist->size);
> +
> +   for (l = playlist->playlist; l; )
> +   {
> +      media_file = l->data;
> +      if (media_file->playlist_position == position)
> +      {
> +         eclair_playlist_current_set(playlist, media_file);
> +      }
> +      l = l->next;
> +   }
> +}
> 
> Index: src/eclair_playlist.h
> ===================================================================
> RCS file: src/eclair_playlist.h,v
> retrieving revision 1.9
> diff -b -u -2 -r1.9 eclair_playlist.h
> --- src/eclair_playlist.h     21 May 2005 12:55:23 -0000      1.9
> +++ src/eclair_playlist.h     6 Jun 2005 04:24:27 -0000
> @@ -26,4 +26,5 @@
>  void eclair_playlist_prev_as_current(Eclair_Playlist *playlist);
>  void eclair_playlist_next_as_current(Eclair_Playlist *playlist);
> +void eclair_playlist_random_as_current(Eclair_Playlist *playlist);
>  
>  #endif
> 
> Index: src/eclair_private.h
> ===================================================================
> RCS file: src/eclair_private.h,v
> retrieving revision 1.18
> diff -b -u -2 -r1.18 eclair_private.h
> --- src/eclair_private.h      27 May 2005 21:31:49 -0000      1.18
> +++ src/eclair_private.h      6 Jun 2005 04:24:27 -0000
> @@ -166,4 +166,5 @@
>     int bitrate;
>     int samplerate;
> +   int playlist_position;
>  
>     Eclair_Playlist_Container_Object *container_object;
> @@ -182,4 +183,5 @@
>     Evas_Bool repeat;
>     Ecore_Timer *media_files_destructor_timer;
> +   int size;
>  
>     Eclair *eclair;



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r 
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to