centralise getting icon evas object from app
authorCarsten Haitzler <raster@rasterman.com>
Thu, 15 Dec 2005 07:12:00 +0000 (07:12 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Thu, 15 Dec 2005 07:12:00 +0000 (07:12 +0000)
SVN revision: 19038

configure.in
src/bin/e.h
src/bin/e_apps.c
src/bin/e_apps.h
src/bin/e_border.c
src/bin/e_exebuf.c
src/bin/e_init.c
src/bin/e_int_menus.c
src/bin/e_utils.c

index e5e5489..58f7009 100644 (file)
@@ -17,6 +17,7 @@ AC_HEADER_STDC
 AC_C_CONST
 AM_ENABLE_SHARED
 AM_PROG_LIBTOOL
+AC_FUNC_ALLOCA
 AC_C___ATTRIBUTE__
 
 AC_CHECK_FUNCS(setenv)
index b21de6b..747c7e8 100644 (file)
 #include "config.h"
 #endif
 
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+
 #if HAVE___ATTRIBUTE__
 #define __UNUSED__ __attribute__((unused))
 #else
index c877348..6b0f876 100644 (file)
@@ -1242,6 +1242,17 @@ e_app_valid_exe_get(E_App *a)
    return ok;
 }
 
+EAPI Evas_Object *
+e_app_icon_add(Evas *evas, E_App *a)
+{
+   Evas_Object *o;
+   
+   o = edje_object_add(evas);
+   if (!e_util_edje_icon_list_set(o, a->icon_class))
+     edje_object_file_set(o, a->path, "icon");
+   return o;
+}
+
 
 /* local subsystem functions */
 
index 83c71e0..3a38d03 100644 (file)
@@ -106,12 +106,13 @@ EAPI Evas_List  *e_app_generic_glob_list                 (char *generic);
 EAPI Evas_List  *e_app_exe_glob_list                     (char *exe);
 EAPI Evas_List  *e_app_comment_glob_list                 (char *comment);
     
-EAPI void        e_app_fields_fill                       (E_App *a, const char *path);
-EAPI void        e_app_fields_save                       (E_App *a);
-EAPI E_App      *e_app_raw_new                           (void);
-EAPI Ecore_List *e_app_dir_file_list_get                 (E_App *a);
-EAPI void        e_app_fields_empty                      (E_App *a);
-EAPI int         e_app_valid_exe_get                     (E_App *a);
-    
+EAPI void         e_app_fields_fill                       (E_App *a, const char *path);
+EAPI void         e_app_fields_save                       (E_App *a);
+EAPI E_App       *e_app_raw_new                           (void);
+EAPI Ecore_List  *e_app_dir_file_list_get                 (E_App *a);
+EAPI void         e_app_fields_empty                      (E_App *a);
+EAPI int          e_app_valid_exe_get                     (E_App *a);
+EAPI Evas_Object *e_app_icon_add                          (Evas *evas, E_App *a);
+
 #endif
 #endif
index 73cfaec..0b65880 100644 (file)
@@ -2336,13 +2336,9 @@ e_border_icon_add(E_Border *bd, Evas *evas)
      }
    if (a)
      {
-       o = edje_object_add(evas);
-       if (!e_util_edje_icon_list_set(o, a->icon_class))
-         {
-            edje_object_file_set(o, a->path, "icon");
-            bd->app = a;
-            e_object_ref(E_OBJECT(bd->app));
-         }
+       o = e_app_icon_add(evas, a);
+       bd->app = a;
+       e_object_ref(E_OBJECT(bd->app));
        return o;
      }
    else if (bd->client.netwm.icons)
index 9d9596b..c7d9dc8 100644 (file)
@@ -293,8 +293,7 @@ _e_exebuf_update(void)
    if (!a) a = e_app_generic_find(cmd_buf);
    if (a)
      {
-       o = edje_object_add(exebuf->evas);
-       edje_object_file_set(o, a->path, "icon");
+       o = e_app_icon_add(exebuf->evas, a);
        icon_object = o;
        edje_object_part_swallow(bg_object, "icon_swallow", o);
        evas_object_show(o);
@@ -742,8 +741,7 @@ _e_exebuf_matches_update(void)
        evas_object_show(o);
        if (edje_object_part_exists(exe->bg_object, "icon_swallow"))
          {
-            o = edje_object_add(exebuf->evas);
-            edje_object_file_set(o, exe->app->path, "icon");
+            o = e_app_icon_add(exebuf->evas, exe->app);
             exe->icon_object = o;
             edje_object_part_swallow(exe->bg_object, "icon_swallow", o);
             evas_object_show(o);
@@ -787,8 +785,7 @@ _e_exebuf_matches_update(void)
             a = e_app_exe_find(exe->file);
             if (a)
               {
-                 o = edje_object_add(exebuf->evas);
-                 edje_object_file_set(o, a->path, "icon");
+                 o = e_app_icon_add(exebuf->evas, a);
                  exe->icon_object = o;
                  edje_object_part_swallow(exe->bg_object, "icon_swallow", o);
                  evas_object_show(o);
index fe86dd0..c24e676 100644 (file)
@@ -216,8 +216,7 @@ e_init_icons_app_add(E_App *app)
        evas_object_show(o);
      }
    
-   o = edje_object_add(_e_init_evas);
-   edje_object_file_set(o,app->path, "icon");
+   o = e_app_icon_add(_e_init_evas, app);
    evas_object_resize(o, _e_init_icon_size, _e_init_icon_size);
    e_box_pack_end(_e_init_icon_box, o);
    e_box_pack_options_set(o, 
index 761a57a..73bad8d 100644 (file)
@@ -443,7 +443,9 @@ _e_int_menus_apps_scan(E_Menu *m)
                  e_menu_item_label_set(mi, label);
                  if (a->exe)
                    {
-                      e_menu_item_icon_edje_set(mi, a->path, "icon");
+                      if (!((a->icon_class) && 
+                            (e_util_menu_item_edje_icon_list_set(mi, a->icon_class))))
+                        e_menu_item_icon_edje_set(mi, a->path, "icon");
                       e_menu_item_callback_set(mi, _e_int_menus_apps_run, a);
                       app_count++;
                    }
@@ -452,7 +454,9 @@ _e_int_menus_apps_scan(E_Menu *m)
                       char buf[4096];
                       
                       snprintf(buf, sizeof(buf), "%s/.directory.eap", a->path);
-                      e_menu_item_icon_edje_set(mi, buf, "icon");
+                      if (!((a->icon_class) && 
+                            (e_util_menu_item_edje_icon_list_set(mi, a->icon_class))))
+                        e_menu_item_icon_edje_set(mi, buf, "icon");
                       e_menu_item_submenu_set(mi, e_int_menus_apps_new(a->path));
                       app_count++;
                    }
@@ -711,11 +715,13 @@ _e_int_menus_clients_pre_cb(void *data, E_Menu *m)
 //     e_object_breadcrumb_add(E_OBJECT(bd), "clients_menu");
        e_menu_item_callback_set(mi, _e_int_menus_clients_item_cb, bd);
        if (!bd->iconic) e_menu_item_toggle_set(mi, 1);
-       a = e_app_window_name_class_title_role_find(bd->client.icccm.name,
-                                                   bd->client.icccm.class,
-                                                   title,
-                                                   bd->client.icccm.window_role);
-       if (a) e_menu_item_icon_edje_set(mi, a->path, "icon");
+       a = bd->app;
+       if (a)
+         {
+            if (!((a->icon_class) && 
+                  (e_util_menu_item_edje_icon_list_set(mi, a->icon_class))))
+              e_menu_item_icon_edje_set(mi, a->path, "icon");
+         }
      }
    mi = e_menu_item_new(m);
    e_menu_item_separator_set(mi, 1);
@@ -996,11 +1002,13 @@ _e_int_menus_lost_clients_pre_cb(void *data, E_Menu *m)
        e_object_ref(E_OBJECT(bd));
 //     e_object_breadcrumb_add(E_OBJECT(bd), "lost_clients_menu");
        e_menu_item_callback_set(mi, _e_int_menus_lost_clients_item_cb, bd);
-       a = e_app_window_name_class_title_role_find(bd->client.icccm.name,
-                                                   bd->client.icccm.class,
-                                                   title,
-                                                   bd->client.icccm.window_role);
-       if (a) e_menu_item_icon_edje_set(mi, a->path, "icon");
+       a = bd->app;
+       if (a)
+         {
+            if (!((a->icon_class) && 
+                  (e_util_menu_item_edje_icon_list_set(mi, a->icon_class))))
+              e_menu_item_icon_edje_set(mi, a->path, "icon");
+         }
      }
    e_object_free_attach_func_set(E_OBJECT(m), _e_int_menus_lost_clients_free_hook);
    e_object_data_set(E_OBJECT(m), borders);
index f99c471..b5d74ba 100644 (file)
@@ -307,7 +307,7 @@ e_util_edje_icon_list_set(Evas_Object *obj, char *list)
    char *p, *c;
    
    if ((!list) || (!list[0])) return 0;
-   buf = malloc(strlen(list) + 1);
+   buf = alloca(strlen(list) + 1);
    p = list;
    while (p)
      {
@@ -316,31 +316,17 @@ e_util_edje_icon_list_set(Evas_Object *obj, char *list)
          {
             strncpy(buf, p, c - p);
             buf[c - p] = 0;
-            if (e_util_edje_icon_set(obj, buf))
-              {
-                 free(buf);
-                 return 1;
-              }
+            if (e_util_edje_icon_set(obj, buf)) return 1;
             p = c + 1;
-            if (!*p)
-              {
-                 free(buf);
-                 return 0;
-              }
+            if (!*p) return 0;
          }
        else
          {
             strcpy(buf, p);
-            if (e_util_edje_icon_set(obj, buf))
-              {
-                 free(buf);
-                 return 1;
-              }
-            free(buf);
+            if (e_util_edje_icon_set(obj, buf)) return 1;
             return 0;
          }
      }
-   free(buf);
    return 0;
 }
 
@@ -351,7 +337,7 @@ e_util_menu_item_edje_icon_list_set(E_Menu_Item *mi, char *list)
    char *p, *c;
    
    if ((!list) || (!list[0])) return 0;
-   buf = malloc(strlen(list) + 1);
+   buf = alloca(strlen(list) + 1);
    p = list;
    while (p)
      {
@@ -360,29 +346,17 @@ e_util_menu_item_edje_icon_list_set(E_Menu_Item *mi, char *list)
          {
             strncpy(buf, p, c - p);
             buf[c - p] = 0;
-            if (e_util_menu_item_edje_icon_set(mi, buf))
-              {
-                 free(buf);
-                 return 1;
-              }
+            if (e_util_menu_item_edje_icon_set(mi, buf)) return 1;
             p = c + 1;
-            if (!*p)
-              {
-                 free(buf);
-                 return 0;
-              }
+            if (!*p) return 0;
          }
        else
          {
             strcpy(buf, p);
-            if (e_util_menu_item_edje_icon_set(mi, buf))
-              {
-                 free(buf);
-                 return 1;
-              }
+            if (e_util_menu_item_edje_icon_set(mi, buf)) return 1;
+            return 0;
          }
      }
-   free(buf);
    return 0;
 }