diff --git a/src/bin/e_apps.c b/src/bin/e_apps.c index 9ac49e4da..0a22c3700 100644 --- a/src/bin/e_apps.c +++ b/src/bin/e_apps.c @@ -1176,7 +1176,15 @@ e_app_fields_fill(E_App *a, const char *path) if (desktop->startup) a->startup_notify = *(desktop->startup); -// if (desktop->icon_path) a->icon_path = evas_stringshare_add(desktop->icon_path); + if (desktop->icon) + { + /* FIXME: Should do this only when needed, is it can be expensive. */ + /* FIXME: Use a real icon size and theme. */ + v = ecore_desktop_icon_find(desktop->icon, NULL, NULL); + if (v) + a->icon_path = evas_stringshare_add(v); + } + // if (desktop->type) a->type = evas_stringshare_add(desktop->type); // if (desktop->categories) a->categories = evas_stringshare_add(desktop->categories); } @@ -1400,6 +1408,7 @@ e_app_fields_empty(E_App *a) if (a->comment) evas_stringshare_del(a->comment); if (a->exe) evas_stringshare_del(a->exe); if (a->icon_class) evas_stringshare_del(a->icon_class); + if (a->icon_path) evas_stringshare_del(a->icon_path); if (a->win_name) evas_stringshare_del(a->win_name); if (a->win_class) evas_stringshare_del(a->win_class); if (a->win_title) evas_stringshare_del(a->win_title); @@ -1409,6 +1418,7 @@ e_app_fields_empty(E_App *a) a->comment = NULL; a->exe = NULL; a->icon_class = NULL; + a->icon_path = NULL; a->win_name = NULL; a->win_class = NULL; a->win_title = NULL; @@ -1506,7 +1516,20 @@ e_app_icon_add(Evas *evas, E_App *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"); + { + if (edje_object_file_set(o, a->path, "icon")) + { + ; /* It's a bit more obvious this way. */ + } + else if (a->icon_path) /* If that fails, then this might be an FDO icon. */ + { + /* Free the aborted object first. */ + if (o) evas_object_del(o); + o = e_icon_add(evas); + e_icon_file_set(o, a->icon_path); + e_icon_fill_inside_set(o, 1); + } + } return o; } @@ -2085,6 +2108,7 @@ _e_app_copy(E_App *dst, E_App *src) dst->win_title = src->win_title; dst->win_role = src->win_role; dst->icon_class = src->icon_class; + dst->icon_path = src->icon_path; dst->startup_notify = src->startup_notify; dst->wait_exit = src->wait_exit; dst->starting = src->starting; @@ -2276,6 +2300,7 @@ _e_app_cache_copy(E_App_Cache *ac, E_App *a) IF_DUP(win_title); IF_DUP(win_role); IF_DUP(icon_class); + IF_DUP(icon_path); a->startup_notify = ac->startup_notify; a->wait_exit = ac->wait_exit; } diff --git a/src/bin/e_apps.h b/src/bin/e_apps.h index 3afa60fe9..40d7d7631 100644 --- a/src/bin/e_apps.h +++ b/src/bin/e_apps.h @@ -46,6 +46,7 @@ struct _E_App const char *win_role; /* window role */ const char *icon_class; /* icon_class */ + const char *icon_path; /* FDO icon path */ Evas_List *subapps; /* if this a directory, a list of more E_App's */ diff --git a/src/bin/e_apps_cache.c b/src/bin/e_apps_cache.c index 9e891cc95..ce71726be 100644 --- a/src/bin/e_apps_cache.c +++ b/src/bin/e_apps_cache.c @@ -55,6 +55,7 @@ e_app_cache_init(void) NEWI("wt", win_title, EET_T_STRING); NEWI("wr", win_role, EET_T_STRING); NEWI("ic", icon_class, EET_T_STRING); + NEWI("ip", icon_path, EET_T_STRING); NEWL("ap", subapps, _e_app_cache_edd); NEWI("sn", startup_notify, EET_T_UCHAR); NEWI("wx", wait_exit, EET_T_UCHAR); @@ -145,6 +146,7 @@ e_app_cache_free(E_App_Cache *ac) if (ac->win_title) evas_stringshare_del(ac->win_title); if (ac->win_role) evas_stringshare_del(ac->win_role); if (ac->icon_class) evas_stringshare_del(ac->icon_class); + if (ac->icon_path) evas_stringshare_del(ac->icon_path); while (ac->subapps) { E_App_Cache *ac2; @@ -190,6 +192,7 @@ _e_eapp_cache_fill(E_App_Cache *ac, E_App *a) IF_DUP(win_title); IF_DUP(win_role); IF_DUP(icon_class); + IF_DUP(icon_path); ac->startup_notify = a->startup_notify; ac->wait_exit = a->wait_exit; } diff --git a/src/bin/e_apps_cache.h b/src/bin/e_apps_cache.h index f699372b5..36fa3fed4 100644 --- a/src/bin/e_apps_cache.h +++ b/src/bin/e_apps_cache.h @@ -25,6 +25,7 @@ struct _E_App_Cache const char *win_role; /* window role */ const char *icon_class; /* icon_class */ + const char *icon_path; /* FDO icon path */ Evas_List *subapps; /* if this a directory, a list of more E_App's */ diff --git a/src/bin/e_int_menus.c b/src/bin/e_int_menus.c index 7ff2c3103..dd126edf7 100644 --- a/src/bin/e_int_menus.c +++ b/src/bin/e_int_menus.c @@ -439,7 +439,10 @@ _e_int_menus_apps_scan(E_Menu *m) { 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_icon_edje_set(mi, a->path, "icon"); + if (a->icon_path) e_menu_item_icon_path_set(mi, a->icon_path); + } e_menu_item_callback_set(mi, _e_int_menus_apps_run, a); app_count++; } @@ -450,7 +453,7 @@ _e_int_menus_apps_scan(E_Menu *m) snprintf(buf, sizeof(buf), "%s/.directory.eap", a->path); 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_icon_edje_set(mi, buf, "icon"); e_menu_item_submenu_set(mi, e_int_menus_apps_new(a->path)); app_count++; } @@ -705,7 +708,10 @@ _e_int_menus_clients_pre_cb(void *data, E_Menu *m) { 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_icon_edje_set(mi, a->path, "icon"); + if (a->icon_path) e_menu_item_icon_path_set(mi, a->icon_path); + } } } mi = e_menu_item_new(m); @@ -863,7 +869,10 @@ _e_int_menus_lost_clients_pre_cb(void *data, E_Menu *m) { 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_icon_edje_set(mi, a->path, "icon"); + if (a->icon_path) e_menu_item_icon_path_set(mi, a->icon_path); + } } } e_object_free_attach_func_set(E_OBJECT(m), _e_int_menus_lost_clients_free_hook); diff --git a/src/bin/e_menu.c b/src/bin/e_menu.c index a9d0a8486..c62425003 100644 --- a/src/bin/e_menu.c +++ b/src/bin/e_menu.c @@ -548,6 +548,21 @@ e_menu_item_num_get(E_Menu_Item *mi) return -1; } +EAPI void +e_menu_item_icon_path_set(E_Menu_Item *mi, const char *icon) +{ + E_OBJECT_CHECK(mi); + E_OBJECT_TYPE_CHECK(mi, E_MENU_ITEM_TYPE); + if (((mi->icon_path) && (icon) && (!strcmp(icon, mi->icon_path))) || + ((!mi->icon_path) && (!icon))) + return; + if (mi->icon_path) evas_stringshare_del(mi->icon_path); + mi->icon_path = NULL; + if (icon) mi->icon_path = evas_stringshare_add(icon); + mi->changed = 1; + mi->menu->changed = 1; +} + EAPI void e_menu_item_icon_file_set(E_Menu_Item *mi, const char *icon) { @@ -1045,6 +1060,7 @@ _e_menu_item_free(E_Menu_Item *mi) mi->menu->items = evas_list_remove(mi->menu->items, mi); if (mi->icon) evas_stringshare_del(mi->icon); if (mi->icon_key) evas_stringshare_del(mi->icon_key); + if (mi->icon_path) evas_stringshare_del(mi->icon_path); if (mi->label) evas_stringshare_del(mi->label); free(mi); } @@ -1197,6 +1213,7 @@ _e_menu_item_realize(E_Menu_Item *mi) else evas_object_del(o); + /* FIXME: This should be cleaned up a bit. */ if (mi->icon_object) { o = e_icon_add(mi->menu->evas); @@ -1208,6 +1225,7 @@ _e_menu_item_realize(E_Menu_Item *mi) } else if (mi->icon) { + /* Try a the usual suspects first. */ if (!mi->icon_key) { o = e_icon_add(mi->menu->evas); @@ -1221,13 +1239,27 @@ _e_menu_item_realize(E_Menu_Item *mi) Evas_Coord iww, ihh; o = edje_object_add(mi->menu->evas); + if (edje_object_file_set(o, mi->icon, mi->icon_key)) + { + mi->icon_object = o; + edje_object_size_max_get(o, &iww, &ihh); + icon_w = iww; + icon_h = ihh; + } + } + + if ((!mi->icon_object) && (mi->icon_path)) /* If that fails, then this might be an FDO icon. */ + { + /* Free the aborted object first. */ + if (mi->icon_object) evas_object_del(mi->icon_object); + o = e_icon_add(mi->menu->evas); mi->icon_object = o; - edje_object_file_set(o, mi->icon, mi->icon_key); - edje_object_size_max_get(o, &iww, &ihh); - icon_w = iww; - icon_h = ihh; + e_icon_file_set(o, mi->icon_path); + e_icon_fill_inside_set(o, 1); + e_icon_size_get(mi->icon_object, &icon_w, &icon_h); } } + evas_object_pass_events_set(o, 1); evas_object_show(o); diff --git a/src/bin/e_menu.h b/src/bin/e_menu.h index c49062e68..f28c740ab 100644 --- a/src/bin/e_menu.h +++ b/src/bin/e_menu.h @@ -84,6 +84,7 @@ struct _E_Menu_Item E_Menu *menu; const char *icon; const char *icon_key; + const char *icon_path; const char *label; E_Menu *submenu; @@ -169,6 +170,7 @@ EAPI E_Menu *e_menu_root_get(E_Menu *m); EAPI E_Menu_Item *e_menu_item_new(E_Menu *m); EAPI E_Menu_Item *e_menu_item_nth(E_Menu *m, int n); EAPI int e_menu_item_num_get(E_Menu_Item *mi); +EAPI void e_menu_item_icon_path_set(E_Menu_Item *mi, const char *icon); EAPI void e_menu_item_icon_file_set(E_Menu_Item *mi, const char *icon); EAPI void e_menu_item_icon_edje_set(E_Menu_Item *mi, const char *icon, const char *key); EAPI void e_menu_item_icon_object_set(E_Menu_Item *mi, Evas_Object *obj);