Enlightenment CVS committal

Author  : raster
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e.h e_apps.c e_apps.h e_border.c e_exebuf.c e_init.c 
        e_int_menus.c e_utils.c 


Log Message:


centralise getting icon evas object from app

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -3 -r1.36 -r1.37
--- e.h 22 Nov 2005 13:28:10 -0000      1.36
+++ e.h 15 Dec 2005 07:12:00 -0000      1.37
@@ -39,6 +39,10 @@
 #include "config.h"
 #endif
 
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+
 #if HAVE___ATTRIBUTE__
 #define __UNUSED__ __attribute__((unused))
 #else
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_apps.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -3 -r1.106 -r1.107
--- e_apps.c    14 Dec 2005 15:54:51 -0000      1.106
+++ e_apps.c    15 Dec 2005 07:12:00 -0000      1.107
@@ -1242,6 +1242,17 @@
    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 */
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_apps.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- e_apps.h    14 Dec 2005 15:54:51 -0000      1.25
+++ e_apps.h    15 Dec 2005 07:12:00 -0000      1.26
@@ -106,12 +106,13 @@
 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
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_border.c,v
retrieving revision 1.467
retrieving revision 1.468
diff -u -3 -r1.467 -r1.468
--- e_border.c  11 Dec 2005 05:56:26 -0000      1.467
+++ e_border.c  15 Dec 2005 07:12:00 -0000      1.468
@@ -2336,13 +2336,9 @@
      }
    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)
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_exebuf.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- e_exebuf.c  15 Dec 2005 04:29:38 -0000      1.5
+++ e_exebuf.c  15 Dec 2005 07:12:00 -0000      1.6
@@ -293,8 +293,7 @@
    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 @@
        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 @@
             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);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_init.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- e_init.c    4 Dec 2005 12:03:58 -0000       1.31
+++ e_init.c    15 Dec 2005 07:12:00 -0000      1.32
@@ -216,8 +216,7 @@
        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, 
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_int_menus.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -3 -r1.115 -r1.116
--- e_int_menus.c       4 Dec 2005 12:03:58 -0000       1.115
+++ e_int_menus.c       15 Dec 2005 07:12:00 -0000      1.116
@@ -443,7 +443,9 @@
                  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 @@
                       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_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_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);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_utils.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -3 -r1.32 -r1.33
--- e_utils.c   14 Dec 2005 15:54:51 -0000      1.32
+++ e_utils.c   15 Dec 2005 07:12:00 -0000      1.33
@@ -307,7 +307,7 @@
    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 @@
          {
             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 @@
    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 @@
          {
             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;
 }
 




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to