Enlightenment CVS committal

Author  : essiene
Project : e17
Module  : proto

Dir     : e17/proto/entrance_edit_gui/src/gui


Modified Files:
        background.c theme.c 


Log Message:
Refactorings in theme.c, That main dialog construction function looks clean 
now. I'm happy.
Also made background.c use enlightenment backgrounds currently. THIS IS 
TEMPORARY so we at least see it work, while laying things in place. As an aside 
though, it *may* be usefull to have standardized edje part names. For instance, 
in Entrance the theme contains a "Background" part that is loaded as a 
background, while in E, the background part is called desktop/background. Maybe 
there should be a standar somewhere. I'm just thinking out loud though. 

===================================================================
RCS file: /cvs/e/e17/proto/entrance_edit_gui/src/gui/background.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- background.c        13 Aug 2006 19:58:45 -0000      1.4
+++ background.c        13 Aug 2006 21:33:45 -0000      1.5
@@ -38,13 +38,13 @@
    list_thumbs = ew_textlist_new(NULL, 320, 140, 20, 90);
    
    /* scan for backgrounds and add them to the list */
-   backgrounds = ecore_file_ls("/usr/share/entrance/backgrounds");
+   backgrounds = ecore_file_ls("/usr/share/enlightenment/data/backgrounds");
    if(!backgrounds || ecore_list_is_empty(backgrounds))
      return;
 
    background = ecore_list_first(backgrounds);
    char *background_file = _background_get_path(background);
-   ew_image_edje_load(img_preview, background_file, "Preview");
+   ew_image_edje_load(img_preview, background_file, "desktop/background");
    free(background_file);
    /*FIXME: selecting the first row doesn't work - maybe we select first row 
while adding elements to the list:(*/
    ew_list_first_row_select(list_thumbs);
@@ -75,7 +75,7 @@
 {
        char* background = ew_list_selected_data_get(list_thumbs);
        char* background_path = _background_get_path(background);
-       ew_image_edje_load(img_preview, background_path, "Preview");
+       ew_image_edje_load(img_preview, background_path, "desktop/background");
 
        free(background_path);
 }
@@ -104,7 +104,7 @@
 _background_get_path(const char *t)
 {
        char *path = calloc(PATH_MAX, sizeof(*path));
-       snprintf(path, PATH_MAX, "/usr/share/entrance/backgrounds/%s", t);
+       snprintf(path, PATH_MAX, 
"/usr/share/enlightenment/data/backgrounds/%s", t);
 
        return path;
 }
===================================================================
RCS file: /cvs/e/e17/proto/entrance_edit_gui/src/gui/theme.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- theme.c     13 Aug 2006 06:17:27 -0000      1.5
+++ theme.c     13 Aug 2006 21:33:45 -0000      1.6
@@ -4,6 +4,10 @@
 #include <Entrance_Widgets.h>
 #include <Entrance_Edit.h>
 
+#define THEME_PATH "/usr/share/entrance/themes"
+#define THEME_PREVIEW_EDJE_PART "Preview"
+#define THEME_LIST_TITLE "Themes"
+
 static void _theme_cb_selected(void);
 static void _theme_cb_ok(void *, void *);
 static void _theme_cb_apply(void *, void *);
@@ -12,6 +16,8 @@
 static char* _theme_get_path(const char *);
 static void _theme_close(void);
 static void _theme_apply(void);
+static char* _theme_populate_list(void);
+static void _theme_load_preview(const char *);
 
 static Entrance_Dialog win;
 static Entrance_Widget img_preview;
@@ -20,11 +26,13 @@
 static Entrance_Widget group_preview;
 static Entrance_Widget group_options;
 
+/*static char* theme_path;
+static char* theme_preview_edje_part;
+static char* theme_list_title;*/
+
 void
 egui_theme_dialog_show()
 {
-   Ecore_List *themes;
-   char *theme;
    
    win = ew_dialog_new(_("Entrance - Theme Chooser"), EW_FALSE);
 
@@ -33,31 +41,12 @@
    img_preview = ew_image_new(320, 240);
    ew_group_add(group_preview, img_preview);
 
-   group_themes = ew_dialog_group_add(win, _("Themes"));
+   group_themes = ew_dialog_group_add(win, _(THEME_LIST_TITLE));
 
    list_thumbs = ew_textlist_new(NULL, 320, 140, 20, 90);
    
-   /* scan for themes and add them to the list */
-   themes = ecore_file_ls("/usr/share/entrance/themes");
-   if(!themes || ecore_list_is_empty(themes))
-     return;
-
-   theme = ecore_list_first(themes);
-   char *theme_file = _theme_get_path(theme);
-   ew_image_edje_load(img_preview, theme_file, "Preview");
-   free(theme_file);
-   /*FIXME: selecting the first row doesn't work - maybe we select first row 
while adding elements to the list:(*/
-   ew_list_first_row_select(list_thumbs);
-
-   ecore_list_goto_first(themes);
-   while((theme = ecore_list_next(themes)))
-     {
-        char *theme_no_ext = ecore_file_strip_ext(theme);
-               ew_textlist_add(list_thumbs, theme_no_ext, theme, strlen(theme) 
+ 1, _theme_cb_selected);
-
-        free(theme_no_ext);
-     }
-   ecore_list_destroy(themes);
+   char *first_theme = _theme_populate_list();
+   _theme_load_preview(first_theme);
    
    ew_group_add(group_themes, list_thumbs);
 
@@ -75,7 +64,7 @@
 {
        char* theme = ew_list_selected_data_get(list_thumbs);
        char* theme_path = _theme_get_path(theme);
-       ew_image_edje_load(img_preview, theme_path, "Preview");
+       ew_image_edje_load(img_preview, theme_path, THEME_PREVIEW_EDJE_PART);
 
        free(theme_path);
 }
@@ -104,7 +93,7 @@
 _theme_get_path(const char *t)
 {
        char *path = calloc(PATH_MAX, sizeof(*path));
-       snprintf(path, PATH_MAX, "/usr/share/entrance/themes/%s", t);
+       snprintf(path, PATH_MAX, THEME_PATH "/%s", t);
 
        return path;
 }
@@ -130,4 +119,40 @@
 _theme_close(void)
 {
        ew_dialog_destroy(win);
+}
+
+static char*
+_theme_populate_list(void)
+{
+   Ecore_List *theme_list = ecore_file_ls(THEME_PATH);
+   char* first_theme;
+
+   if(theme_list && !ecore_list_is_empty(theme_list))
+   {
+          ecore_list_goto_first(theme_list);
+
+          char* theme;
+          first_theme = strdup(ecore_list_first(theme_list));
+
+          while((theme = ecore_list_next(theme_list)))
+                {
+                       char *theme_no_ext = ecore_file_strip_ext(theme);
+                       ew_textlist_add(list_thumbs, theme_no_ext, theme, 
strlen(theme) + 1, _theme_cb_selected);
+                       free(theme_no_ext);
+                }
+
+          ecore_list_destroy(theme_list);
+   }
+
+   return first_theme;
+}
+
+static void
+_theme_load_preview(const char *theme)
+{
+   char *theme_file = _theme_get_path(theme);
+   ew_image_edje_load(img_preview, theme_file, THEME_PREVIEW_EDJE_PART);
+   free(theme_file);
+   /*FIXME: selecting the first row doesn't work - maybe we select first row 
while adding elements to the list:(*/
+   /*ew_list_first_row_select(list_thumbs);*/
 }



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to