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 


Log Message:
Make examine use the theme search path for loading previews
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/examine/src/examine.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- examine.c   8 May 2004 11:18:24 -0000       1.12
+++ examine.c   13 May 2004 15:08:51 -0000      1.13
@@ -12,6 +12,7 @@
 #include <ctype.h>
 
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <dirent.h>
 
 #include "examine_client.h"
@@ -37,6 +38,7 @@
 examine_panel  *panels;
 
 char           *examine_separators = ".\\/\0";
+char           *examine_search_path;
 
 /*****************************************************************************/
 
@@ -285,34 +287,49 @@
       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 stat     st;
       struct dirent  *next;
       DIR            *dp;
-      char           *dir, *fulldir;
+      char           *search_path, *path, *ptr, *end;
       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, ".."))
+      search_path = strdup(__examine_client_theme_search_path);
+      ptr = search_path;
+      end = search_path + strlen(search_path);
+      path = search_path;
+      while (ptr && ptr < end) {
+        while (*ptr != '|' && ptr < end)
+          ptr++;
+        if (ptr < end)
+          *ptr = '\0';
+
+        if (stat(path, &st) != 0) {
+          ptr++;
+          path = ptr;
           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);
+        }
+        dp = opendir((const char *) path);
+        while (next = readdir(dp)) {
+          if (!strcmp(next->d_name, ".") || !strcmp(next->d_name, ".."))
+            continue;
+          file = malloc(strlen(path) + strlen(next->d_name) + 2); /* 2=/+\0 */
+          strcpy(file, path);
+          strcat(file, "/");
+          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);
+        }
+        ptr++;
+       path = ptr;
       }
-
+      free(search_path);
     } else
       entries[1] = ewl_entry_new("unknown");
     prop_item->w = entries[1];
@@ -348,7 +365,7 @@
   ewl_container_append_child(EWL_CONTAINER(main_box), notebook);
   ewl_widget_show(notebook);
 
-  examine_client_list_props();
+  examine_client_theme_search_path_get();
 
   row = ewl_hbox_new();
   ewl_container_append_child(EWL_CONTAINER(main_box), row);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/examine/src/examine_client.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- examine_client.c    8 May 2004 11:18:24 -0000       1.9
+++ examine_client.c    13 May 2004 15:08:51 -0000      1.10
@@ -16,7 +16,8 @@
 typedef enum Examine_Callback_Type {
   EX_DATA_SET = 0,
   EX_DATA_GET = 1,
-  EX_DATA_LIST = 2
+  EX_DATA_LIST = 2,
+  EX_SEARCH_PATH = 3
 } Examine_Callback_Type;
 
 Examine_Callback_Type expected_type;
@@ -27,6 +28,7 @@
 
 
 void            examine_client_list_props_cb(void);
+void            examine_client_theme_search_path_get_cb(void);
 void            examine_client_get_val_cb(void);
 /*****************************************************************************/
 
@@ -82,6 +84,8 @@
   case EX_DATA_LIST:
     examine_client_list_props_cb();
     break;
+  case EX_SEARCH_PATH:
+    examine_client_theme_search_path_get_cb();
   default:
     break;
   }
@@ -162,6 +166,42 @@
 }
 
 void
+examine_client_theme_search_path_get(void)
+{
+  call           *c;
+
+  c = find_call("prop-get");
+  examine_client_send(c, "/e/themes/search_path", NULL);
+
+  expected_type = EX_SEARCH_PATH;
+}
+
+void
+examine_client_theme_search_path_get_cb(void)
+{
+  char          *ret, *tmp, *end;
+  if (examine_client_buf && (strlen(examine_client_buf) > 0)) {
+
+    ret = strstr(examine_client_buf, "=") + 1;
+    if (*ret == '"') {
+      ret++;
+      if (end = strstr(ret, "\""))
+        *end = '\0';
+    }
+
+    if (*(ret + strlen(ret) - 1) == '\n')
+      *(ret + strlen(ret) - 1) = '\0';
+    tmp = strstr(examine_client_buf, ":");
+    *tmp = '\0';
+  
+    __examine_client_theme_search_path = strdup(ret);
+
+    free(examine_client_buf);
+    examine_client_list_props();
+  }
+}
+
+void
 examine_client_list_props(void)
 {
   call           *c;
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/examine/src/examine_client.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- examine_client.h    10 May 2004 22:12:06 -0000      1.8
+++ examine_client.h    13 May 2004 15:08:51 -0000      1.9
@@ -74,10 +74,11 @@
 
 };
 
-
+char           *__examine_client_theme_search_path;
 
 int             examine_client_send(call * c, char *key, char *val);
 void            examine_client_list_props(void);
+void            examine_client_theme_search_path_get(void);
 void            examine_client_revert_list(void);
 void            examine_client_revert(examine_prop * target);
 void            examine_client_save_list(void);




-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to