Enlightenment CVS committal

Author  : handyande
Project : e17
Module  : apps/examine

Dir     : e17/apps/examine/src


Modified Files:
        examine.c examine_client.c examine_client.h exsh.c 


Log Message:
Add proper theme support
indent
theme previews currently only work if the client app is installed in /usr/local
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/examine/src/examine.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- examine.c   1 May 2004 23:10:39 -0000       1.10
+++ examine.c   2 May 2004 21:09:46 -0000       1.11
@@ -5,13 +5,15 @@
 
 #include "Ecore_Config.h"
 
-#include <Ewl.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 
+#include <sys/types.h>
+#include <dirent.h>
+
 #include "examine_client.h"
 
 int             debug = 1;
@@ -19,6 +21,7 @@
 void            render_ewl(void);
 void            print_usage(void);
 Ewl_Widget     *add_tab(char *name);
+char           *app_name;
 
 Ewl_Widget     *main_win;
 Ewl_Widget     *tree_box;
@@ -52,7 +55,6 @@
 {
   int             ret = ECORE_CONFIG_ERR_SUCC, cc = 0;
   connstate       cs = OFFLINE;
-  char           *pipe_name = NULL;
 
   if (argc <= 1 ||
       (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0)) {
@@ -60,8 +62,8 @@
     return 0;
   }
 
-  pipe_name = argv[1];
-  E(2, "examine: connecting to %s.\n", pipe_name);
+  app_name = argv[1];
+  E(2, "examine: connecting to %s.\n", app_name);
 
   ecore_init();
   ecore_app_args_set(argc, (const char **) argv);
@@ -81,9 +83,9 @@
 
 reconnect:
   cc++;
-  if ((ret = examine_client_init(pipe_name, &cs)) != ECORE_CONFIG_ERR_SUCC)
+  if ((ret = examine_client_init(app_name, &cs)) != ECORE_CONFIG_ERR_SUCC)
     E(0, "examine: %sconnect to %s failed: %d\n", (cc > 1) ? "re" : "",
-      pipe_name, ret);
+      app_name, ret);
   else {
     render_ewl();
     ewl_widget_show(main_win);
@@ -165,12 +167,38 @@
   change->value.fval = (float) ewl_spinner_get_value(EWL_SPINNER(w));
 }
 
+void
+cb_choose_theme(Ewl_Widget * w, void *ev_data, void *user_data)
+{
+  examine_prop   *change;
+  char           *theme, *ext;
+  Ewl_Widget     *sibling;
+
+  change = (examine_prop *) user_data;
+
+  if (!(theme = rindex(EWL_IMAGE(w)->path, '/') + 1))
+    theme = EWL_IMAGE(w)->path;
+
+  theme = strdup(theme);
+  if (ext = rindex(theme, '.'))
+    *ext = '\0';
+
+  ewl_container_child_iterate_begin(EWL_CONTAINER(w->parent));
+  while (sibling = ewl_container_next_child(EWL_CONTAINER(w->parent)))
+    ewl_object_set_padding(EWL_OBJECT(sibling), 2, 2, 2, 2);
+  ewl_object_set_padding(EWL_OBJECT(w), 0, 0, 0, 0);
+
+  if (change->value.ptr)
+    free(change->value.ptr);
+  change->value.ptr = theme;
+}
+
 /* UI constructor */
 
 void
 draw_tree(examine_prop * prop_item)
 {
-  Ewl_Widget     *entries[2], *tree_box, *tmp_row;
+  Ewl_Widget     *entries[2], *tree_box, *tmp_row, *tmp;
   examine_panel  *panel_ptr;
   char           *key_tmp;
   char           *panel_name;
@@ -257,6 +285,35 @@
       entries[1] = ewl_entry_new("");
       ewl_callback_append(EWL_ENTRY(entries[1])->text,
                           EWL_CALLBACK_VALUE_CHANGED, cb_set_str, prop_item);
+    } else if (prop_item->type == PT_THM) {
+      struct dirent  *next;
+      DIR            *dp;
+      char           *dir, *fulldir;
+      char           *file;
+
+      entries[1] = ewl_hbox_new();
+
+      // FIXME - only looking in /usr/local/share - should be settable
+      dir = "/usr/local/share/";
+      fulldir = malloc(strlen(dir) + strlen(app_name) + strlen("/themes/") + 1);
+      strcpy(fulldir, dir);
+      strcat(fulldir, app_name);
+      strcat(fulldir, "/themes/");
+      dp = opendir((const char *) fulldir);
+      while (next = readdir(dp)) {
+        if (!strcmp(next->d_name, ".") || !strcmp(next->d_name, ".."))
+          continue;
+        file = malloc(strlen(fulldir) + strlen(next->d_name) + 1);
+        strcpy(file, fulldir);
+        strcat(file, next->d_name);
+        tmp = ewl_image_new(file, (char *) prop_item->data);
+        ewl_widget_show(tmp);
+        ewl_container_append_child(EWL_CONTAINER(entries[1]), tmp);
+        ewl_callback_append(tmp, EWL_CALLBACK_CLICKED, cb_choose_theme,
+                            prop_item);
+        ewl_object_set_padding(EWL_OBJECT(tmp), 2, 2, 2, 2);
+      }
+
     } else
       entries[1] = ewl_entry_new("unknown");
     prop_item->w = entries[1];
@@ -316,7 +373,8 @@
 
 /*****************************************************************************/
 
-Ewl_Widget * add_tab(char *name)
+Ewl_Widget     *
+add_tab(char *name)
 {
   Ewl_Widget     *button, *scrollpane, *pane, *headers[2];
   examine_panel  *new_panel;
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/examine/src/examine_client.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- examine_client.c    13 Apr 2004 22:17:32 -0000      1.7
+++ examine_client.c    2 May 2004 21:09:46 -0000       1.8
@@ -256,6 +256,9 @@
           }
         } else if (!strcmp(type, "colour")) {
           prop_tmp->type = PT_RGB;
+        } else if (!strcmp(type, "theme")) {
+          prop_tmp->type = PT_THM;
+          prop_tmp->data = strdup(range);
         } else
           prop_tmp->value.ptr = NULL;
 
@@ -354,6 +357,7 @@
   int             tmpi;
   float           tmpd;
   examine_prop   *prop;
+  Ewl_Widget     *sibling;
 
   ret = strstr(examine_client_buf, "=") + 1;
   if (*ret == '"') {
@@ -390,6 +394,19 @@
     prop->oldvalue.fval = tmpd;
     ewl_spinner_set_value(EWL_SPINNER(prop->w), tmpd);
     break;
+  case PT_THM:
+    prop->value.ptr = strdup(ret);
+    prop->oldvalue.ptr = strdup(ret);
+
+    tmp = malloc(strlen(ret) + 5);      // 5 = .eet + \0
+    strcpy(tmp, ret);
+    strcat(tmp, ".eet");
+    ewl_container_child_iterate_begin(EWL_CONTAINER(prop->w));
+    while (sibling = ewl_container_next_child(EWL_CONTAINER(prop->w)))
+      if (!memcmp(EWL_IMAGE(sibling)->path + strlen(EWL_IMAGE(sibling)->path)
+                  - strlen(tmp), tmp, strlen(tmp)))
+        ewl_object_set_padding(EWL_OBJECT(sibling), 0, 0, 0, 0);
+    break;
   default:                     /* PT_STR, PT_RGB */
     prop->value.ptr = strdup(ret);
     prop->oldvalue.ptr = strdup(ret);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/examine/src/examine_client.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- examine_client.h    27 Mar 2004 23:20:31 -0000      1.6
+++ examine_client.h    2 May 2004 21:09:46 -0000       1.7
@@ -44,7 +44,8 @@
     long            val;
     float           fval;
   } oldvalue;
-  Ewl_Widget       *w;
+  Ewl_Widget     *w;
+  void           *data;
   struct examine_prop *next;
 } examine_prop;
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/examine/src/exsh.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- exsh.c      14 Apr 2004 13:30:14 -0000      1.8
+++ exsh.c      2 May 2004 21:09:46 -0000       1.9
@@ -535,7 +535,7 @@
     if (!cp)
       ret = ECORE_CONFIG_ERR_NOTFOUND;
     else {
-      
+
       if (h)
         puts(cp->help);
       else if (cp->signature & P_HELPONLY) {




-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE. 
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to