From 63d89d34cd6f48ba7a46b23369eea5f4ecfa5d64 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sat, 30 Jul 2005 08:12:05 +0000 Subject: [PATCH] accpet an icon class as a comma-delimited list, so you can do multiple classes to match more than one eg: firefox,mozilla,web_browser,browser,application ie the app (lets say it was firefox) is a member of multiple classes - the first matched will be used, if none match, the .eap provided internal icon will be used. SVN revision: 15953 --- src/bin/e_border.c | 2 +- src/bin/e_utils.c | 105 +++++++++++++++++++++++++++++++++++++++++---- src/bin/e_utils.h | 4 +- 3 files changed, 101 insertions(+), 10 deletions(-) diff --git a/src/bin/e_border.c b/src/bin/e_border.c index 1e2d3d7bd..4f35beb32 100644 --- a/src/bin/e_border.c +++ b/src/bin/e_border.c @@ -1748,7 +1748,7 @@ e_border_icon_add(E_Border *bd, Evas *evas) if (a) { o = edje_object_add(evas); - if (!e_util_edje_icon_set(o, a->icon_class)) + if (!e_util_edje_icon_list_set(o, a->icon_class)) edje_object_file_set(o, a->path, "icon"); } } diff --git a/src/bin/e_utils.c b/src/bin/e_utils.c index 83e9e31ff..c68561594 100644 --- a/src/bin/e_utils.c +++ b/src/bin/e_utils.c @@ -256,29 +256,118 @@ e_util_immortal_check(void) return 0; } +int +e_util_ejde_icon_list_set(Evas_Object *obj, char *list) +{ + char *buf; + char *p, *c; + + buf = malloc(strlen(list) + 1); + p = list; + while (p) + { + c = strchr(p, ','); + if (c) + { + strncpy(buf, p, c - p); + buf[c - p] = 0; + if (e_util_edje_icon_set(obj, buf)) + { + free(buf); + return 1; + } + p = c + 1; + if (!*p) + { + free(buf); + return 0; + } + } + else + { + strcpy(buf, p); + if (e_util_edje_icon_set(obj, buf)) + { + free(buf); + return 1; + } + } + } + free(buf); + return 0; +} + +int +e_util_menu_item_ejde_icon_list_set(E_Menu_Item *mi, char *list) +{ + char *buf; + char *p, *c; + + buf = malloc(strlen(list) + 1); + p = list; + while (p) + { + c = strchr(p, ','); + if (c) + { + strncpy(buf, p, c - p); + buf[c - p] = 0; + if (e_util_menu_item_edje_icon_set(mi, buf)) + { + free(buf); + return 1; + } + p = c + 1; + if (!*p) + { + free(buf); + return 0; + } + } + else + { + strcpy(buf, p); + if (e_util_menu_item_edje_icon_set(mi, buf)) + { + free(buf); + return 1; + } + } + } + free(buf); + return 0; +} + int e_util_edje_icon_set(Evas_Object *obj, char *name) { char *file; char buf[4096]; - if (!name) return 0; + if ((!name) || (!name[0])) return 0; snprintf(buf, sizeof(buf), "icons/%s", name); file = (char *)e_theme_edje_file_get("base/theme/icons", buf); - if (!file[0]) return; - edje_object_file_set(obj, file, buf); - return 1; + if (file[0]) + { + edje_object_file_set(obj, file, buf); + return 1; + } + return 0; } -void +int e_util_menu_item_edje_icon_set(E_Menu_Item *mi, char *name) { char *file; char buf[4096]; - if (!name) return; + if ((!name) || (!name[0])) return 0; snprintf(buf, sizeof(buf), "icons/%s", name); file = (char *)e_theme_edje_file_get("base/theme/icons", buf); - if (!file[0]) return; - e_menu_item_icon_edje_set(mi, file, buf); + if (file[0]) + { + e_menu_item_icon_edje_set(mi, file, buf); + return 1; + } + return 0; } diff --git a/src/bin/e_utils.h b/src/bin/e_utils.h index 43eb613a9..522698e13 100644 --- a/src/bin/e_utils.h +++ b/src/bin/e_utils.h @@ -20,8 +20,10 @@ EAPI int e_util_head_exec(int head, char *cmd); EAPI int e_util_strcmp(char *s1, char *s2); EAPI int e_util_both_str_empty(char *s1, char *s2); EAPI int e_util_immortal_check(void); +EAPI int e_util_ejde_icon_list_set(Evas_Object *obj, char *list); +EAPI int e_util_menu_item_ejde_icon_list_set(E_Menu_Item *mi, char *list); EAPI int e_util_edje_icon_set(Evas_Object *obj, char *name); -EAPI void e_util_menu_item_edje_icon_set(E_Menu_Item *mi, char *name); +EAPI int e_util_menu_item_edje_icon_set(E_Menu_Item *mi, char *name); #endif #endif