Enlightenment CVS committal

Author  : essiene
Project : e17
Module  : proto

Dir     : e17/proto/entrance_edit_gui/src/gui


Modified Files:
        main.c theme.c 


Log Message:
- Theme dialog works now.
- I have a problem selecting the first row adding to the list. This should be
done in the widget such that after adding  to a list, the first row is always 
selected
will make our lives easier. Anyone wanting to do this *hint* *hint* should look 
in src/widgets/ew_txtlist.c/ew_txtlist_add() and 
src/widgets/ew_edjelist.c/ew_edjelist_add()
- I've cleaned up theme.c a bit more... it *looks* better. It still leaks like 
a basket though. *hint* *hint*
- i need to sleep now :)

===================================================================
RCS file: /cvs/e/e17/proto/entrance_edit_gui/src/gui/main.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- main.c      13 Aug 2006 04:38:58 -0000      1.5
+++ main.c      13 Aug 2006 06:17:27 -0000      1.6
@@ -1,4 +1,5 @@
 #include <Entrance_Widgets.h>
+#include <Entrance_Edit.h>
 #include "Egui.h"
 #include "config.h"
 
===================================================================
RCS file: /cvs/e/e17/proto/entrance_edit_gui/src/gui/theme.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- theme.c     13 Aug 2006 01:00:33 -0000      1.4
+++ theme.c     13 Aug 2006 06:17:27 -0000      1.5
@@ -2,11 +2,16 @@
 #include <Ecore_File.h>
 #include <Ecore_Data.h>
 #include <Entrance_Widgets.h>
+#include <Entrance_Edit.h>
 
-static void _egui_theme_cb_selected(void);
-static void _egui_theme_cb_ok(void *object, void *data);
-static void _egui_theme_cb_apply(void *object, void *data);
-static void _egui_theme_cb_close(void *object, void *data);
+static void _theme_cb_selected(void);
+static void _theme_cb_ok(void *, void *);
+static void _theme_cb_apply(void *, void *);
+static void _theme_cb_close(void *, void *);
+
+static char* _theme_get_path(const char *);
+static void _theme_close(void);
+static void _theme_apply(void);
 
 static Entrance_Dialog win;
 static Entrance_Widget img_preview;
@@ -20,31 +25,35 @@
 {
    Ecore_List *themes;
    char *theme;
-   char theme_file[PATH_MAX];
    
    win = ew_dialog_new(_("Entrance - Theme Chooser"), EW_FALSE);
 
    group_preview = ew_dialog_group_add(win, _("Preview"));
+
    img_preview = ew_image_new(320, 240);
-  /* ew_image_edje_load(img_preview, "/usr/share/entrance/themes/default.edj", 
"Preview");*/
    ew_group_add(group_preview, img_preview);
 
    group_themes = ew_dialog_group_add(win, _("Themes"));
-   
+
    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;
-        
-        theme_no_ext = ecore_file_strip_ext(theme);
-        snprintf(theme_file, sizeof(theme_file), 
"/usr/share/entrance/themes/%s", theme);
-               ew_textlist_add(list_thumbs, theme_no_ext, theme_file, 
strlen(theme_file) + 1, _egui_theme_cb_selected);
+        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);
      }
@@ -54,37 +63,71 @@
 
    /*Entrance_Widget group_options = ew_dialog_group_add(win, _("Options"));*/
    
-   ew_dialog_close_button_add(win, _egui_theme_cb_close, NULL);
-   ew_dialog_apply_button_add(win, _egui_theme_cb_apply, NULL);
-   ew_dialog_ok_button_add(win, _egui_theme_cb_ok, NULL);
+   ew_dialog_close_button_add(win, _theme_cb_close, NULL);
+   ew_dialog_apply_button_add(win, _theme_cb_apply, NULL);
+   ew_dialog_ok_button_add(win, _theme_cb_ok, NULL);
    
    ew_dialog_show(win);
 }
 
 static void
-_egui_theme_cb_selected()
+_theme_cb_selected()
 {
-       char* themefile = ew_list_selected_data_get(list_thumbs);
-       ew_image_edje_load(img_preview, themefile, "Preview");
+       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");
+
+       free(theme_path);
 }
 
 
 static void
-_egui_theme_cb_ok(void *object, void *data)
+_theme_cb_ok(void *object, void *data)
 {
-   printf("ok pressed!\n");
-   ew_dialog_destroy(win);
+   _theme_apply();
+   _theme_close();
 }
 
 static void
-_egui_theme_cb_apply(void *object, void *data)
+_theme_cb_apply(void *object, void *data)
+{
+   _theme_apply();
+}
+
+static void
+_theme_cb_close(void *object, void *data)
+{
+       _theme_close();
+}
+
+static char*
+_theme_get_path(const char *t)
+{
+       char *path = calloc(PATH_MAX, sizeof(*path));
+       snprintf(path, PATH_MAX, "/usr/share/entrance/themes/%s", t);
+
+       return path;
+}
+
+static void 
+_theme_apply(void)
 {
-   char *themefile = ew_list_selected_data_get(list_thumbs);
-   printf("apply pressed - %s!\n", themefile);
+    char *theme = ew_list_selected_data_get(list_thumbs);
+       if(!theme) 
+       {
+               printf("Error. Please select a theme first\n");
+               return;
+       }
+
+       entrance_edit_string_set(ENTRANCE_EDIT_KEY_CLIENT_THEME_STR, theme);
+       if(!entrance_edit_save())
+       {
+               printf("Error setting theme - %s. Please check your 
permissions\n", theme);
+       }
 }
 
 static void
-_egui_theme_cb_close(void *object, void *data)
+_theme_close(void)
 {
        ew_dialog_destroy(win);
 }



-------------------------------------------------------------------------
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