Beginning to drag all the basic "show this icon for this app" code

together in one place to make it easy to keep it consistant.


SVN revision: 25273
This commit is contained in:
David Walter Seikel 2006-09-01 09:01:52 +00:00
parent 74e1827485
commit d3de4f4e95
5 changed files with 35 additions and 47 deletions

View File

@ -1617,10 +1617,36 @@ e_app_icon_add(Evas *evas, E_App *a)
e_icon_file_set(o, a->icon_path);
e_icon_fill_inside_set(o, 1);
}
/* FIXME: if we still haven't found an icon, feed icon_class into the FDO lookup process. */
}
return o;
}
/* Search order? -
*
* fixed path to icon
* an .edje icon in ~/.e/e/icons
* icon_class in theme
* icon from a->path in theme
* FDO search
* FDO search for icon_class
*/
EAPI void
e_app_icon_add_to_menu_item(E_Menu_Item *mi, E_App *a)
{
if (!e_util_menu_item_edje_icon_list_set(mi, a->icon_class))
{
/* e_menu_item_icon_edje_set() just tucks away the params, the actual call to edje_object_file_set() happens later. */
/* e_menu_item_icon_file_set() just tucks away the params, the actual call to e_icon_add() happens later. */
e_menu_item_icon_edje_set(mi, a->path, "icon");
if (a->icon_path) /* If that fails, then this might be an FDO icon. */
e_menu_item_icon_file_set(mi, a->icon_path);
/* FIXME: if we still haven't found an icon, feed icon_class into the FDO lookup process. */
}
return;
}
/* local subsystem functions */

View File

@ -136,6 +136,7 @@ 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);
EAPI void e_app_icon_add_to_menu_item (E_Menu_Item *mi, E_App *a);
#endif
#endif

View File

@ -467,12 +467,7 @@ _e_int_menus_apps_scan(E_Menu *m)
e_menu_item_label_set(mi, label);
if (a->exe)
{
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");
if (a->icon_path) e_menu_item_icon_path_set(mi, a->icon_path);
}
e_app_icon_add_to_menu_item(mi, a);
e_menu_item_callback_set(mi, _e_int_menus_apps_run, a);
e_menu_item_drag_callback_set(mi, _e_int_menus_apps_drag, a);
app_count++;
@ -481,6 +476,7 @@ _e_int_menus_apps_scan(E_Menu *m)
{
char buf[4096];
/* FIXME: .directory.eaps are obsolete, but have yet to be replaced by FDO stuff. */
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))))
@ -946,14 +942,7 @@ _e_int_menus_lost_clients_pre_cb(void *data, E_Menu *m)
e_menu_item_callback_set(mi, _e_int_menus_lost_clients_item_cb, bd);
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");
if (a->icon_path) e_menu_item_icon_path_set(mi, a->icon_path);
}
}
e_app_icon_add_to_menu_item(mi, a);
}
e_object_free_attach_func_set(E_OBJECT(m), _e_int_menus_lost_clients_free_hook);
e_object_data_set(E_OBJECT(m), borders);

View File

@ -551,21 +551,6 @@ 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)
{
@ -1068,7 +1053,6 @@ _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);
}
@ -1223,16 +1207,9 @@ _e_menu_item_realize(E_Menu_Item *mi)
if (mi->icon)
{
/* Try a the usual suspects first. */
if (!mi->icon_key)
{
o = e_icon_add(mi->menu->evas);
mi->icon_object = o;
e_icon_file_set(o, mi->icon);
e_icon_fill_inside_set(o, 1);
e_icon_size_get(mi->icon_object, &icon_w, &icon_h);
}
else
/* This is done this way to match up with how e_app_icon_add does it. */
mi->icon_object = NULL; /* Just coz I'm paranoid, may not be needed. */
if (mi->icon_key)
{
Evas_Coord iww, ihh;
@ -1245,14 +1222,11 @@ _e_menu_item_realize(E_Menu_Item *mi)
icon_h = ihh;
}
}
if ((!mi->icon_object) && (mi->icon_path)) /* If that fails, then this might be an FDO icon. */
if (!mi->icon_object)
{
/* 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;
e_icon_file_set(o, mi->icon_path);
e_icon_file_set(o, mi->icon);
e_icon_fill_inside_set(o, 1);
e_icon_size_get(mi->icon_object, &icon_w, &icon_h);
}

View File

@ -84,7 +84,6 @@ struct _E_Menu_Item
E_Menu *menu;
const char *icon;
const char *icon_key;
const char *icon_path;
const char *label;
E_Menu *submenu;
@ -184,7 +183,6 @@ 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_label_set(E_Menu_Item *mi, const char *label);