Enlightenment CVS committal

Author  : tsauerbeck
Project : misc
Module  : eplayer

Dir     : misc/eplayer/src


Modified Files:
        Makefile.am callbacks.c callbacks.h eplayer.c eplayer.h 
        interface.c playlist.c playlist.h utils.c utils.h 
Added Files:
        playlist_item.c playlist_item.h 


Log Message:
moved the playlist edje code from interface.c to playlist_item.c.
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/Makefile.am,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- Makefile.am 28 Dec 2003 12:53:45 -0000      1.10
+++ Makefile.am 1 Feb 2004 11:51:01 -0000       1.11
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.10 2003/12/28 12:53:45 tsauerbeck Exp $
+# $Id: Makefile.am,v 1.11 2004/02/01 11:51:01 tsauerbeck Exp $
 
 SUBDIRS = input output
 
@@ -8,13 +8,15 @@
 
 bin_PROGRAMS = eplayer
 
-eplayer_SOURCES = eplayer.c eplayer.h \
-       interface.c interface.h \
-       callbacks.c callbacks.h \
-       track.c track.h \
-       playlist.c playlist.h \
-       plugin.c plugin.h \
-       utils.c utils.h
+eplayer_SOURCES = \
+       eplayer.c       eplayer.h \
+       callbacks.c     callbacks.h \
+       interface.c     interface.h \
+       playlist.c      playlist.h \
+       playlist_item.c playlist_item.h \
+       plugin.c        plugin.h \
+       track.c         track.h \
+       utils.c         utils.h
 
 eplayer_LDADD = @PTHREAD_LIBS@ @DL_LIBS@ \
        @ECORE_LIBS@ @EVAS_LIBS@ @EDJE_LIBS@ @ESMART_LIBS@ @EWL_LIBS@
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/callbacks.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -3 -r1.36 -r1.37
--- callbacks.c 31 Jan 2004 10:55:25 -0000      1.36
+++ callbacks.c 1 Feb 2004 11:51:01 -0000       1.37
@@ -189,15 +189,19 @@
 }
 
 EDJE_CB(playlist_scroll_up) {
+       int size = (int) evas_object_data_get(player->gui.playlist,
+                                             "PlaylistFontSize");
+
        /* it's * 3 because we're scrolling 3 elements at once */
-       e_container_scroll(player->gui.playlist,
-                          player->gui.playlist_font_size * 3);
+       e_container_scroll(player->gui.playlist, size * 3);
 }
 
 EDJE_CB(playlist_scroll_down) {
+       int size = (int) evas_object_data_get(player->gui.playlist,
+                                             "PlaylistFontSize");
+
        /* it's * 3 because we're scrolling 3 elements at once */
-       e_container_scroll(player->gui.playlist,
-                          player->gui.playlist_font_size * -3);
+       e_container_scroll(player->gui.playlist, size * -3);
 }
 
 EDJE_CB(playlist_item_play) {
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/callbacks.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- callbacks.h 25 Jan 2004 20:23:59 -0000      1.17
+++ callbacks.h 1 Feb 2004 11:51:01 -0000       1.18
@@ -2,9 +2,15 @@
 #define __CALLBACKS_H
 
 #include <Evas.h>
+#include <Ewl.h>
+
+typedef void (*EdjeCb)(void *udata, Evas_Object *o,
+                       const char *emission, const char *src);
+
+struct _ePlayer;
 
 #define EDJE_CB(name) \
-       void cb_##name(ePlayer *player, Evas_Object *obj, \
+       void cb_##name(struct _ePlayer *player, Evas_Object *obj, \
                       const char *emission, const char *src)
 
 EDJE_CB(play);
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/eplayer.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- eplayer.c   31 Jan 2004 21:55:26 -0000      1.30
+++ eplayer.c   1 Feb 2004 11:51:01 -0000       1.31
@@ -170,8 +170,6 @@
 
        load_input_plugins(player);
 
-       player->playlist = playlist_new(player->input_plugins);
-
        if (!load_output_plugin(player)) {
                debug(DEBUG_LEVEL_CRITICAL, "Cannot load %s output plugin!\n",
                      player->cfg.output_plugin);
@@ -267,15 +265,18 @@
        ePlayer *player = data;
        int i;
 
+       player->playlist = playlist_new(player->gui.evas,
+                                       player->input_plugins,
+                                       player->gui.playlist,
+                                       player->cfg.theme);
+       assert(player->playlist);
+
        for (i = 1; player->args[i]; i++)
                playlist_load_any(player->playlist, player->args[i], i > 1);
 
        debug(DEBUG_LEVEL_INFO, "Got %i playlist entries\n",
              player->playlist->num);
 
-       /* update the ui */
-       ui_fill_playlist(player);
-
        if (player->playlist->num)
                track_open(player);
        
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/eplayer.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -3 -r1.23 -r1.24
--- eplayer.h   31 Jan 2004 10:55:25 -0000      1.23
+++ eplayer.h   1 Feb 2004 11:51:01 -0000       1.24
@@ -26,7 +26,7 @@
        Ecore_Evas *ee;
        Evas_Object *edje;
        Evas_Object *playlist; /* playlist container */
-       int playlist_font_size;
+       /*int playlist_font_size;*/
 } Gui;
 
 typedef struct {
@@ -35,7 +35,7 @@
        int seek_dir;
 } Flags;
 
-typedef struct {
+typedef struct _ePlayer {
        const char **args;
 
        PlayList *playlist;
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/interface.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- interface.c 31 Jan 2004 10:55:25 -0000      1.42
+++ interface.c 1 Feb 2004 11:51:01 -0000       1.43
@@ -10,8 +10,6 @@
 #include "utils.h"
 #include "interface.h"
 
-typedef void (*EdjeCb)(void *udata, Evas_Object *o,
-                       const char *emission, const char *source);
 typedef struct {
        char *name;
        char *src;
@@ -130,6 +128,8 @@
 
        evas_font_path_append(player->gui.evas, buf);
        evas_font_path_append(player->gui.evas, DATA_DIR "/fonts");
+       evas_font_path_append(player->gui.evas, "/usr/X11R6/lib/X11/fonts");
+       evas_font_path_append(player->gui.evas, "/usr/share/fonts");
 
        if (!ui_init_dragger(player))
                return false;
@@ -159,27 +159,6 @@
                                  pli->comment[COMMENT_ID_ALBUM]);
 }
 
-/**
- * Finds the filename for the theme @name.
- * Looks in: ~/.e/apps/eplayer/themes
- *           $prefix/share/eplayer/themes
- */
-static char *find_theme(const char *name) {
-       static char eet[PATH_MAX + 1];
-       struct stat st;
-
-       snprintf(eet, sizeof(eet),
-                "%s/.e/apps/" PACKAGE "/" "themes/%s.eet",
-                getenv("HOME"), name);
-       
-       if (!stat(eet, &st))
-               return eet;
-
-       snprintf(eet, sizeof(eet), DATA_DIR "/themes/%s.eet", name);
-       
-       return stat(eet, &st) ? NULL : eet;
-}
-
 bool ui_init_edje(ePlayer *player, const char *name) {
        double edje_w = 0, edje_h = 0;
 
@@ -212,8 +191,6 @@
        ecore_evas_resize(player->gui.ee, (int) edje_w, (int) edje_h);
        
        setup_playlist(player);
-       ui_fill_playlist(player);
-       ui_fill_track_info(player);
        ui_refresh_volume(player);
 
        register_callbacks(player);
@@ -279,9 +256,17 @@
        
 }
 
+/**
+ * Add the playlist container.
+ *
+ * @param player
+ */
 static void setup_playlist(ePlayer *player) {
-       /* add the playlist container */
        player->gui.playlist = e_container_new(player->gui.evas);
+       assert(player->gui.playlist);
+
+       evas_object_data_set(player->gui.playlist, "ePlayer", player);
+
        e_container_direction_set(player->gui.playlist, 1);
        e_container_spacing_set(player->gui.playlist, 0);
        e_container_fill_policy_set(player->gui.playlist,
@@ -291,61 +276,6 @@
                                 player->gui.playlist);
 }
 
-static void show_playlist_item(ePlayer *player, PlayListItem *pli) {
-       Evas_Object *o;
-       char len[32];
-       double w = 0, h = 0;
-
-       /* add the item to the container */
-       o = edje_object_add(player->gui.evas);
-
-       edje_object_file_set(o, find_theme(player->cfg.theme),
-                            "playlist_item");
-
-       /* set parts text */
-       snprintf(len, sizeof(len), "%i:%02i", pli->duration / 60,
-                pli->duration % 60);
-       edje_object_part_text_set(o, "length", len);
-       edje_object_part_text_set(o, "title",
-                                 pli->comment[COMMENT_ID_TITLE]);
-
-       /* set parts dimensions */
-       edje_object_size_min_get(o, &w, &h);
-       evas_object_resize(o, w, h);
-       
-       evas_object_data_set(o, "PlayListItem", pli);
-
-       /* store font size, we need it later for scrolling
-        * FIXME: we're assuming that the objects minimal height
-        * equals the text size
-        */
-       player->gui.playlist_font_size = h;
-
-       e_container_element_append(player->gui.playlist, o);
-       
-       /* add playlist item callbacks */
-       edje_object_signal_callback_add(o, "PLAYLIST_SCROLL_UP", "",
-                                               (EdjeCb) cb_playlist_scroll_up, 
player);
-       edje_object_signal_callback_add(o, "PLAYLIST_SCROLL_DOWN", "",
-                                               (EdjeCb) cb_playlist_scroll_down, 
player);
-       edje_object_signal_callback_add(o, "PLAYLIST_ITEM_PLAY", "",
-                                               (EdjeCb) cb_playlist_item_play, 
player);
-       edje_object_signal_callback_add(o, "PLAYLIST_ITEM_SELECTED", "",
-                                       (EdjeCb) cb_playlist_item_selected, player);
-       edje_object_signal_callback_add(o, "PLAYLIST_ITEM_REMOVE", "",
-                                       (EdjeCb) cb_playlist_item_remove, player);
-}
-
-void ui_fill_playlist(ePlayer *player) {
-       Evas_List *l;
-
-       assert (player);
-       assert (player->playlist);
-
-       for (l = player->playlist->items; l; l = l->next)
-               show_playlist_item(player, l->data);
-}
-
 int ui_refresh_volume(void *udata) {
        ePlayer *player = udata;
        char buf[8];
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/playlist.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- playlist.c  31 Jan 2004 10:49:11 -0000      1.19
+++ playlist.c  1 Feb 2004 11:51:01 -0000       1.20
@@ -4,96 +4,30 @@
 #include <string.h>
 #include <dirent.h>
 #include <unistd.h>
+#include <assert.h>
 #include "playlist.h"
 #include "utils.h"
 
 /**
- * Fills a PlayListItem's comments/info fields.
- *
- * @param pli The PlayListItem to store the comments/info stuff in.
- */
-static void playlist_item_get_info(PlayListItem *pli) {
-       int i;
-       
-       pli->sample_rate = pli->plugin->get_sample_rate();
-       pli->channels = pli->plugin->get_channels();
-       pli->duration = pli->plugin->get_duration();
-       pli->sample_rate = pli->plugin->get_sample_rate();
-       
-       for (i = 0; i < COMMENT_ID_NUM; i++)
-               snprintf(pli->comment[i], MAX_COMMENT_LEN, "%s",
-                        pli->plugin->get_comment(i));
-}
-
-/**
- * Frees a PlayListItem object.
- *
- * @param pli
- */
-void playlist_item_free(PlayListItem *pli) {
-       if (!pli)
-               return;
-       
-       pthread_mutex_destroy(&pli->pos_mutex);
-       free(pli);
-}
-
-/**
- * Creates a new PlayListItem object.
- *
- * @param file File to load.
- * @return The new PlayListItem object.
- */
-PlayListItem *playlist_item_new(Evas_List *plugins, const char *file) {
-       PlayListItem *pli;
-       Evas_List *l;
-       InputPlugin *ip;
-
-       if (!(pli = malloc(sizeof(PlayListItem))))
-               return NULL;
-       
-       memset(pli, 0, sizeof(PlayListItem));
-
-       pthread_mutex_init(&pli->pos_mutex, NULL);
-
-       /* find the plugin for this file */
-       for (l = plugins; l; l = l->next) {
-               ip = l->data;
-
-               if (ip->open(file)) {
-                       pli->plugin = ip;
-                       break;
-               }
-       }
-
-       if (!pli->plugin) {
-               debug(DEBUG_LEVEL_WARNING, "No plugin found for %s!\n", file);
-
-               playlist_item_free(pli);
-               return NULL;
-       }
-
-       snprintf(pli->file, sizeof(pli->file), "%s", file);
-       playlist_item_get_info(pli);
-
-       return pli;
-}
-
-/**
  * Creates a new PlayList object.
  *
  * @param plugins
  * @return The newly created PlayList.
  */
-PlayList *playlist_new(Evas_List *plugins) {
+PlayList *playlist_new(Evas *evas, Evas_List *plugins, Evas_Object *container,
+                       const char *theme) {
        PlayList *pl;
 
-       if (!(pl = malloc(sizeof(PlayList))))
+       if (!(pl = calloc(1, sizeof(PlayList))))
                return NULL;
 
-       memset(pl, 0, sizeof(PlayList));
+       pl->num = pl->duration = 0;
+       pl->items = pl->cur_item = NULL;
 
+       pl->evas = evas;
        pl->plugins = plugins;
+       pl->container = container;
+       pl->theme = theme;
 
        return pl;
 }
@@ -228,8 +162,11 @@
  */
 bool playlist_load_file(PlayList *pl, const char *file, bool append) {
        PlayListItem *pli;
+
+       assert(pl);
        
-       if (!pl || !(pli = playlist_item_new(pl->plugins, file)))
+       if (!(pli = playlist_item_new(file, pl->evas, pl->plugins, pl->container,
+                                     pl->theme)))
                return false;
 
        if (!append)
@@ -324,7 +261,8 @@
                        ptr = path;
                }
 
-               if ((pli = playlist_item_new(pl->plugins, ptr))) {
+               if ((pli = playlist_item_new(ptr, pl->evas, pl->plugins, pl->container,
+                                            pl->theme))) {
                        tmp = evas_list_prepend(tmp, pli);
                        pl->num++;
                        pl->duration += pli->duration;
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/playlist.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- playlist.h  31 Jan 2004 10:49:11 -0000      1.11
+++ playlist.h  1 Feb 2004 11:51:01 -0000       1.12
@@ -2,26 +2,7 @@
 #define __PLAYLIST_H
 
 #include <Evas.h>
-#include <limits.h>
-#include <pthread.h>
-#include "plugin.h"
-
-typedef struct {
-       char file[PATH_MAX + 1];
-
-       char comment[COMMENT_ID_NUM][MAX_COMMENT_LEN];
-
-       int duration;
-       int channels; /* number of channels */
-       long sample_rate; /* sample rate */
-
-       int current_pos;
-       pthread_mutex_t pos_mutex;
-
-       InputPlugin *plugin; /* plugin that's used for this item */
-} PlayListItem;
-
-typedef void (*ItemAddCallback) (PlayListItem *pli, void *data);
+#include "playlist_item.h"
 
 typedef struct {
        int num; /* number of entries */
@@ -30,10 +11,15 @@
        Evas_List *cur_item;
 
        Evas_List *plugins; /* lists all available plugins */
+       Evas *evas;
+       Evas_Object *container;
+       const char *theme;
 } PlayList;
 
-PlayList *playlist_new(Evas_List *plugins);
-void playlist_free();
+PlayList *playlist_new(Evas *evas, Evas_List *plugins,
+                       Evas_Object *container,
+                       const char *theme);
+void playlist_free(PlayList *pl);
 
 bool playlist_load_file(PlayList *pl, const char *file, bool append);
 bool playlist_load_dir(PlayList *pl, const char *dir, bool append);
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/utils.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- utils.c     31 Jan 2004 10:57:59 -0000      1.4
+++ utils.c     1 Feb 2004 11:51:01 -0000       1.5
@@ -5,8 +5,31 @@
 #include <sys/stat.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <limits.h>
+#include <stdlib.h>
 #include "utils.h"
 
+/**
+ * Finds the filename for the theme @name.
+ * Looks in: ~/.e/apps/eplayer/themes
+ *           $prefix/share/eplayer/themes
+ */
+char *find_theme(const char *name) {
+       static char eet[PATH_MAX + 1];
+       struct stat st;
+
+       snprintf(eet, sizeof(eet),
+                "%s/.e/apps/" PACKAGE "/" "themes/%s.eet",
+                getenv("HOME"), name);
+       
+       if (!stat(eet, &st))
+               return eet;
+
+       snprintf(eet, sizeof(eet), DATA_DIR "/themes/%s.eet", name);
+       
+       return stat(eet, &st) ? NULL : eet;
+}
+
 bool is_dir(const char *dir) {
        struct stat st;
 
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/utils.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- utils.h     31 Jan 2004 10:57:59 -0000      1.3
+++ utils.h     1 Feb 2004 11:51:01 -0000       1.4
@@ -8,6 +8,7 @@
        DEBUG_LEVEL_NUM
 } DebugLevel;
 
+char *find_theme(const char *name);
 bool is_dir(const char *dir);
 char *strstrip(char *str);
 




-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to