Enlightenment CVS committal

Author  : tsauerbeck
Project : misc
Module  : eplayer

Dir     : misc/eplayer/src


Modified Files:
        eplayer.c eplayer.h interface.c interface.h playlist.c 
        playlist.h 


Log Message:
the playlist loaded after the GUI has been initialized now
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/eplayer.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- eplayer.c   7 Nov 2003 22:33:28 -0000       1.14
+++ eplayer.c   14 Nov 2003 16:40:19 -0000      1.15
@@ -121,6 +121,9 @@
 
        player->playlist = playlist_new(player->input_plugins);
 
+       playlist_item_add_cb_set(player->playlist,
+                                show_playlist_item, player);
+
        /* load the output plugin */
        player->output = plugin_new(player->cfg.output_plugin,
                                    PLUGIN_TYPE_OUTPUT);
@@ -187,9 +190,28 @@
                       (void *) &track_play_chunk, player);
 }
 
+/**
+ * Add files/directories/m3u's to the playlist
+ *
+ * @param player
+ */
+static int load_playlist(void *data) {
+       ePlayer *player = data;
+       int i;
+
+       for (i = 1; player->args[i]; i++)
+               playlist_load_any(player->playlist, player->args[i], i > 1);
+
+       if (player->playlist->num)
+               track_open(player);
+               
+       refresh_time(player, 0);
+
+       return 0; /* stop timer */
+}
+
 int main(int argc, const char **argv) {
        ePlayer *player;
-       int i;
 
        if (argc == 1) {
                printf("%s v%s  - Usage: %s playlist.m3u [file.ogg] [some/dir] 
...\n\n",
@@ -200,28 +222,16 @@
        if (!(player = eplayer_new()))
                return 1;
        
-       /* add files/directories/m3u's to the playlist */
-       for (i = 1; i < argc; i++)
-               playlist_load_any(player->playlist, argv[i], i > 1);
-       
-       if (!player->playlist->num) {
-               debug(DEBUG_LEVEL_CRITICAL, "No files loaded!\n");
-               eplayer_free(player);
-               return 1;
-       }
-       
        if (!setup_gui(player)) {
                eplayer_free(player);
                return 1;
-       }
-               
-       show_playlist(player);
+       }       
+       
+       player->args = argv;
+       ecore_timer_add(1, load_playlist, player);
 
        refresh_volume(player);
        ecore_timer_add(1.5, refresh_volume, player);
-
-       track_open(player);
-       refresh_time(player, 0);
 
        debug(DEBUG_LEVEL_INFO, "Starting main loop\n");
 
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/eplayer.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- eplayer.h   25 Oct 2003 19:31:39 -0000      1.10
+++ eplayer.h   14 Nov 2003 16:40:19 -0000      1.11
@@ -26,6 +26,8 @@
 } Gui;
 
 typedef struct {
+       const char **args;
+
        PlayList *playlist;
        Ecore_Timer *time_timer;
 
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/interface.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- interface.c 9 Nov 2003 14:07:46 -0000       1.11
+++ interface.c 14 Nov 2003 16:40:19 -0000      1.12
@@ -7,6 +7,9 @@
 #include "track.h"
 #include "utils.h"
 
+static int setup_edje(ePlayer *player, Ecore_Evas *ee);
+static void setup_playlist(ePlayer *player);
+
 static int app_signal_exit(void *data, int type, void *event) {
        debug(DEBUG_LEVEL_INFO, "Exit called, shutting down\n");
        
@@ -16,7 +19,6 @@
 
 int setup_gui(ePlayer *player) {
        Ecore_Evas *ee;
-       double edje_w = 0, edje_h = 0;
 
        debug(DEBUG_LEVEL_INFO, "Starting setup\n");
 
@@ -34,7 +36,7 @@
                      "Cannot create Ecore Evas (using %s engine)\n",
                      player->cfg.evas_engine);
 
-               return 1;
+               return 0;
        }
        
        ecore_evas_title_set(ee, "eVorbisPlayer");
@@ -46,7 +48,17 @@
        player->gui.evas = ecore_evas_get(ee);
        evas_font_path_append(player->gui.evas, DATA_DIR "/themes/fonts");
 
-       /* EDJE */
+       if (!setup_edje(player, ee))
+               return 0;
+
+       setup_playlist(player);
+
+       return 1;
+}
+
+static int setup_edje(ePlayer *player, Ecore_Evas *ee) {
+       double edje_w = 0, edje_h = 0;
+
        debug(DEBUG_LEVEL_INFO, "EDJE: Defining Edje \n");
 
        player->gui.edje = edje_object_add(player->gui.evas);
@@ -62,7 +74,7 @@
        evas_object_resize(player->gui.edje, edje_w, edje_h);
        evas_object_show(player->gui.edje);
 
-       ecore_evas_resize(ee, (int)edje_w, (int)edje_h);
+       ecore_evas_resize(ee, (int) edje_w, (int) edje_h);
        ecore_evas_show(ee);
 
        /* add the playlist container */
@@ -113,6 +125,7 @@
                                         double width, double height,
                                         Container_Alignment align) {
        Evas_Object *o = e_container_new(player->gui.evas);
+
        e_container_direction_set(o, 1);
        e_container_spacing_set(o, 0);
        e_container_alignment_set(o, align);
@@ -123,68 +136,81 @@
        return o;
 }
 
-void show_playlist(ePlayer *player) {
+static void setup_playlist(ePlayer *player) {
+       Evas_Object *o;
+       double w, h;
+       int i;
+       
+       for (i = 0; i < 2; i++) {
+               /* instantiate the edje object first, to get the width/height */
+               o = edje_object_add(player->gui.evas);
+
+               edje_object_file_set(o, DATA_DIR "/themes/eplayer.eet",
+                                    "playlist_item_title");
+               
+               w = h = 0;
+               edje_object_size_min_get(o, &w, &h);
+               evas_object_del(o);
+
+               /* now add the columns */
+               evas_object_geometry_get(player->gui.playlist,
+                                        NULL, NULL, NULL, &h);
+
+       
+               player->gui.playlist_col[i] = 
+                       playlist_column_add(player, w, h,
+                                           i ? CONTAINER_ALIGN_RIGHT
+                                           : CONTAINER_ALIGN_LEFT);
+
+               e_container_element_append(player->gui.playlist,
+                                          player->gui.playlist_col[i]);
+       }
+}
+
+void show_playlist_item(PlayListItem *pli, void *data) {
+       ePlayer *player = data;
        Evas_Object *o;
-       Evas_List *l;
        char *title, len[32];
        char *name[] = {"playlist_item_title", "playlist_item_length"};
-       double w = 0, h = 0;
-       int i, added_cols = 0, duration;
+       double w, h;
+       int i, duration;
 
-       for (l = player->playlist->items; l; l = l->next) {
-               /* get the information we want to display */
-               title = ((PlayListItem *) l->data)->comment[COMMENT_ID_TITLE];
-               duration = ((PlayListItem *) l->data)->duration;
-               
-               snprintf(len, sizeof(len), "%i:%02i", duration / 60,
-                        duration % 60);
+       /* get the information we want to display */
+       title = pli->comment[COMMENT_ID_TITLE];
+       duration = pli->duration;
+
+       snprintf(len, sizeof(len), "%i:%02i", duration / 60,
+                duration % 60);
                
-               /* add the title/length items to the container */
-               for (i = 0; i < 2; i++) {
-                       o = edje_object_add(player->gui.evas);
+       /* add the title/length items to the container */
+       for (i = 0; i < 2; i++) {
+               o = edje_object_add(player->gui.evas);
 
-                       edje_object_file_set(o, DATA_DIR "/themes/eplayer.eet",
-                                            name[i]);
+               edje_object_file_set(o, DATA_DIR "/themes/eplayer.eet",
+                                    name[i]);
                        
-                       edje_object_part_text_set(o, "text", i ? len : title);
-                       edje_object_size_min_get(o, &w, &h);
-                       evas_object_resize(o, w, h);
-
-                       /* add the columns if we haven't yet
-                        * we do this at this point, because we need to instantiate
-                        * the edje object first, to get the width/height
-                        */
-                       if (!added_cols) {
-                               evas_object_geometry_get(player->gui.playlist,
-                                                        NULL, NULL, NULL, &h);
-
-                               player->gui.playlist_col[i] = 
-                                       playlist_column_add(player, w, h,
-                                                       i ? CONTAINER_ALIGN_RIGHT
-                                                       : CONTAINER_ALIGN_LEFT);
-                               e_container_element_append(player->gui.playlist,
-                                                          
player->gui.playlist_col[i]);
-                       }
+               edje_object_part_text_set(o, "text", i ? len : title);
 
-                       e_container_element_append(player->gui.playlist_col[i], o);
-               
-                       /* add playlist callbacks */
-                       edje_object_signal_callback_add(o,
-                                                       "PLAYLIST_SCROLL_UP", "text",
-                                                       cb_playlist_scroll_up,
-                                                       player);
-                       edje_object_signal_callback_add(o,
-                                                       "PLAYLIST_SCROLL_DOWN", "text",
-                                                       cb_playlist_scroll_down,
-                                                       player);
-
-                       /* FIXME: we're assuming that the objects minimal height
-                        * equals the text size
-                        */
-                       player->gui.playlist_font_size[i] = h;
-               }
+               w = h = 0;
+               edje_object_size_min_get(o, &w, &h);
+               evas_object_resize(o, w, h);
 
-               added_cols = 1;
+               e_container_element_append(player->gui.playlist_col[i], o);
+               
+               /* add playlist callbacks */
+               edje_object_signal_callback_add(o,
+                                               "PLAYLIST_SCROLL_UP", "text",
+                                               cb_playlist_scroll_up,
+                                               player);
+               edje_object_signal_callback_add(o,
+                                               "PLAYLIST_SCROLL_DOWN", "text",
+                                               cb_playlist_scroll_down,
+                                               player);
+
+               /* FIXME: we're assuming that the objects minimal height
+                * equals the text size
+                */
+               player->gui.playlist_font_size[i] = h;
        }
        
        edje_object_signal_callback_add(player->gui.edje,
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/interface.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- interface.h 21 Oct 2003 17:53:39 -0000      1.3
+++ interface.h 14 Nov 2003 16:40:19 -0000      1.4
@@ -3,7 +3,7 @@
 
 #include "eplayer.h"
 
-void show_playlist(ePlayer *player);
+void show_playlist_item(PlayListItem *pli, void *data);
 int setup_gui(ePlayer *player);
 
 int refresh_volume(void *udata);
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/playlist.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- playlist.c  10 Nov 2003 19:02:41 -0000      1.9
+++ playlist.c  14 Nov 2003 16:40:19 -0000      1.10
@@ -93,6 +93,14 @@
        return pl;
 }
 
+void playlist_item_add_cb_set(PlayList *pl, ItemAddCallback cb, void *data) {
+       if (!pl)
+               return;
+
+       pl->cb = cb;
+       pl->cb_data = data;
+}
+
 /**
  * Removes all items from a PlayList.
  *
@@ -164,9 +172,30 @@
        
        pl->num++;
 
+       if (pl->cb)
+               pl->cb(pli, pl->cb_data);
+
        return 1;
 }
 
+static void finish_playlist(PlayList *pl, Evas_List *list, int append) {
+       Evas_List *l;
+
+       list = evas_list_reverse(list);
+       
+       if (pl->cb)
+               for (l = list; l; l = l->next)
+                       pl->cb(l->data, pl->cb_data);
+       
+       if (append)
+               playlist_append_list(pl, list);
+       else {
+               playlist_remove_all(pl);
+               pl->items = list;
+               pl->cur_item = pl->items;
+       }
+}
+
 /**
  * Add a directory to a PlayList.
  *
@@ -204,15 +233,7 @@
 
        closedir(dir);
 
-       tmp = evas_list_reverse(tmp);
-       
-       if (append)
-               playlist_append_list(pl, tmp);
-       else {
-               playlist_remove_all(pl);
-               pl->items = tmp;
-               pl->cur_item = pl->items;
-       }
+       finish_playlist(pl, tmp, append);
        
        return 1;
 }
@@ -258,15 +279,7 @@
 
        fclose(fp);
 
-       tmp = evas_list_reverse(tmp);
-       
-       if (append)
-               playlist_append_list(pl, tmp);
-       else {
-               playlist_remove_all(pl);
-               pl->items = tmp;
-               pl->cur_item = pl->items;
-       }
+       finish_playlist(pl, tmp, append);
        
        return 1;
 }
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/playlist.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- playlist.h  25 Oct 2003 19:31:39 -0000      1.5
+++ playlist.h  14 Nov 2003 16:40:19 -0000      1.6
@@ -25,7 +25,12 @@
        InputPlugin *plugin; /* plugin that's used for this item */
 } PlayListItem;
 
+typedef void (*ItemAddCallback) (PlayListItem *pli, void *data);
+
 typedef struct {
+       ItemAddCallback cb;
+       void *cb_data;
+
        int num; /* number of entries */
        Evas_List *items;
        Evas_List *cur_item;
@@ -35,6 +40,8 @@
 
 PlayList *playlist_new(Evas_List *plugins);
 void playlist_free();
+
+void playlist_item_add_cb_set(PlayList *pl, ItemAddCallback cb, void *data);
 
 int playlist_load_file(PlayList *pl, const char *file, int append);
 int playlist_load_dir(PlayList *pl, const char *dir, int append);




-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to