Actually display the FDO icons referenced from the FDO .desktop files.

Theme icons and .eaps are searched first.

Still needs some work and a lot of testing.  Also needs optimising,
which will come when I go over the caching code later.

Ibar and ibox modules read the .eap directly, so I need to convert them
seperately.

Next I'll spend some time with valgrind, things are leaking.


SVN revision: 24795
This commit is contained in:
David Walter Seikel 2006-08-16 09:37:14 +00:00
parent 37241926bc
commit 3d29c9caf7
7 changed files with 83 additions and 10 deletions

View File

@ -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;
}

View File

@ -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 */

View File

@ -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;
}

View File

@ -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 */

View File

@ -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);

View File

@ -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);

View File

@ -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);