Enlightenment CVS committal

Author  : onefang
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_desktop


Modified Files:
        Ecore_Desktop.h ecore_desktop.c ecore_desktop_icon.c 


Log Message:
Part of a review of icon searching, to be completed on sunday.

===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/Ecore_Desktop.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- Ecore_Desktop.h     22 Sep 2006 10:11:32 -0000      1.30
+++ Ecore_Desktop.h     22 Sep 2006 14:55:43 -0000      1.31
@@ -45,10 +45,11 @@
    char               *categories;
    char               *exec;
    char               *exec_params;
-   char               *icon;
-   char               *original_icon;
    char               *icon_class;
+   char               *icon_theme;
+   char               *icon;
    char               *icon_path;
+   time_t              icon_time;      /* For checking if the icon cache is 
valid. */
    char               *path;
    char               *URL;
    char               *file;
@@ -81,6 +82,8 @@
    char               *inherits;
    char               *directories;
    int                 hidden;
+   /* Actually calling this st_mtime causes compile issues, must be some 
strange macros at work. */
+   time_t              mtime;  /* For checking if the cache is valid. */
 };
 typedef struct _Ecore_Desktop_Icon_Theme Ecore_Desktop_Icon_Theme;
 
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- ecore_desktop.c     22 Sep 2006 10:11:32 -0000      1.37
+++ ecore_desktop.c     22 Sep 2006 14:55:43 -0000      1.38
@@ -299,8 +299,8 @@
                                result->window_role);
 
                       IFGETDUP(value, "Icon", result->icon);
-                      if (result->icon)
-                         result->original_icon = strdup(result->icon);
+                      IFGETDUP(value, "X-Enlightenment-IconTheme",
+                               result->icon_theme);
                       IFGETDUP(value, "X-Enlightenment-IconClass",
                                result->icon_class);
                       IFGETDUP(value, "X-Enlightenment-IconPath",
@@ -312,7 +312,6 @@
                            if (result->icon[0] == '/')
                              {
                                 result->icon_path = strdup(result->icon);
-                                result->icon = NULL;
                              }
                            else        /* It's a relative path. */
                              {
@@ -335,7 +334,6 @@
                                                   result->icon);
                                           result->icon_path =
                                              ecore_file_realpath(temp);
-                                          result->icon = NULL;
                                           free(dir);
                                        }
                                      free(temp);
@@ -394,7 +392,7 @@
                       if (!result->icon_class)
                         {
                            size = 0;
-                           if ((result->icon) && (result->icon[0] != '/'))
+                           if ((result->icon) && (strchr(result->icon, '/') == 
NULL))
                               size += strlen(result->icon) + 1;
                            if (eap_name)
                               size += strlen(eap_name) + 1;
@@ -409,12 +407,11 @@
                                 int                 done = 0;
 
                                 result->icon_class[0] = '\0';
-                                if ((result->icon) && (result->icon[0] != '/')
+                                if ((result->icon) && (strchr(result->icon, 
'/') == NULL)
                                     && (result->icon[0] != '\0'))
                                   {
                                      strcat(result->icon_class, result->icon);
                                      done = 1;
-                                     result->icon = NULL;
                                   }
                                 /* We do this here coz we don't want to lower 
case the result->icon part later. */
                                 p = result->icon_class;
@@ -592,6 +589,9 @@
        if (desktop->icon)
           ecore_hash_set(desktop->group, strdup("Icon"),
                          strdup(desktop->icon));
+       if (desktop->icon_theme)
+          ecore_hash_set(desktop->group, strdup("X-Enlightenment-IconTheme"),
+                         strdup(desktop->icon_theme));
        if (desktop->icon_class)
           ecore_hash_set(desktop->group, strdup("X-Enlightenment-IconClass"),
                          strdup(desktop->icon_class));
@@ -772,7 +772,7 @@
       IFFREE(desktop->exec_params)
       IFFREE(desktop->categories)
       IFFREE(desktop->icon)
-      IFFREE(desktop->original_icon)
+      IFFREE(desktop->icon_theme)
       IFFREE(desktop->icon_class)
       IFFREE(desktop->icon_path)
       IFFREE(desktop->path)
@@ -899,10 +899,10 @@
                                    break;
 
                                 case 'i':      /* "--icon Icon" field from 
.desktop file, or empty. */
-                                   if (desktop->original_icon)
+                                   if (desktop->icon)
                                      {
                                         snprintf(buf, sizeof(buf), "--icon %s",
-                                                 desktop->original_icon);
+                                                 desktop->icon);
                                         t = buf;
                                      }
                                    break;
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop_icon.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- ecore_desktop_icon.c        22 Sep 2006 10:11:32 -0000      1.22
+++ ecore_desktop_icon.c        22 Sep 2006 14:55:43 -0000      1.23
@@ -19,7 +19,7 @@
 
 /* FIXME: We need a way for the client to disable searching for any of these 
that they don't support. */
 static const char  *ext[] =
-   { ".edj", ".png", ".svgz", ".svg", ".xpm", NULL };
+   { "", ".edj", ".png", ".svgz", ".svg", ".xpm", NULL };  /* "" is in case 
the icon already has an extension, search for that first. */
 static int          init_count = 0;
 static Ecore_Hash  *icon_theme_cache;
 static int          loaded = 0;
@@ -140,10 +140,13 @@
     * it changed the theme to make sure that the new icons will eventually get 
     * used."
     *
+    * The phrase "toplevel icon directories" is ambigous, but I guess they 
mean 
+    * the directory where the index.theme file lives.
+    *
     * On the other hand, OS caching (at least in linux) seems to do a 
reasonable 
     * job here.
     *
-    * We could also precalculate and cache all the information extracted from 
+    * We also precalculate and cache all the information extracted from 
     * the .theme files.
     */
 
@@ -171,7 +174,7 @@
          {
             int                 wanted_size;
             int                 minimal_size = INT_MAX;
-            int                 i, j;
+            int                 i;
             char               *closest = NULL;
             Ecore_Desktop_Icon_Theme_Directory *directory;
 
@@ -230,11 +233,14 @@
                         }
 
                       /* Look for icon with all extensions. */
-                      for (j = 0; ext[j] != NULL; j++)
+                      for (i = 0; ext[i] != NULL; i++)
                         {
+                           /* Check if there will be an extension. */
+                           if ((ext[i][0] == '\0') && (strrchr(icon, '.') == 
NULL))
+                              continue;
                            snprintf(path, PATH_MAX,
                                     "%s/%s/%s%s",
-                                    icon_theme, directory->path, icon, ext[j]);
+                                    icon_theme, directory->path, icon, ext[i]);
 #ifdef DEBUG
                            printf("FDO icon = %s\n", path);
 #endif
@@ -243,7 +249,12 @@
                               (ecore_desktop_paths_icons, path, 0, NULL, NULL);
                            if (found)
                              {
-                                if (match)     /* If there is a match in 
sizes, return the icon. */
+                                 if (ecore_file_is_dir(found))
+                                  {
+                                     free(found);
+                                     found = NULL;
+                                  }
+                                else if (match)        /* If there is a match 
in sizes, return the icon. */
                                    break;
                                 else if (result_size < minimal_size)   /* 
While we are here, figure out our next fallback strategy. */
                                   {
@@ -251,6 +262,7 @@
                                      if (closest)
                                         free(closest);
                                      closest = found;
+                                     found = NULL;
                                   }
                                 else
                                   {
@@ -299,6 +311,9 @@
                       /* Fall back strategy #4, Just search in the base of the 
icon directories. */
                       for (i = 0; ext[i] != NULL; i++)
                         {
+                           /* Check if there will be an extension. */
+                           if ((ext[i][0] == '\0') && (strrchr(icon, '.') == 
NULL))
+                              continue;
                            snprintf(path, PATH_MAX, "%s%s", icon, ext[i]);
 #ifdef DEBUG
                            printf("FDO icon = %s\n", path);
@@ -307,7 +322,15 @@
                               ecore_desktop_paths_file_find
                               (ecore_desktop_paths_icons, path, 0, NULL, NULL);
                            if (found)
-                              break;
+                             {
+                                 if (ecore_file_is_dir(found))
+                                  {
+                                     free(found);
+                                     found = NULL;
+                                  }
+                                else
+                                   break;
+                             }
                         }
                    }
               }



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to