update ibar icon to match shelf size

SVN revision: 53852
This commit is contained in:
Sebastian Dransfeld 2010-10-25 10:21:14 +00:00
parent de632e8367
commit 7edb27b105
3 changed files with 60 additions and 1 deletions

View File

@ -978,6 +978,26 @@ e_util_icon_add(const char *path, Evas *evas)
return o;
}
EAPI void
e_util_icon_file_set(Evas_Object *icon, const char *path)
{
const char *ext;
if (!path) return;
if (!ecore_file_exists(path)) return;
ext = strrchr(path, '.');
if (ext)
{
if (!strcmp(ext, ".edj"))
e_icon_file_edje_set(icon, path, "icon");
else
e_icon_file_set(icon, path);
}
else
e_icon_file_set(icon, path);
}
EAPI Evas_Object *
e_util_desktop_icon_add(Efreet_Desktop *desktop, unsigned int size, Evas *evas)
{
@ -985,6 +1005,13 @@ e_util_desktop_icon_add(Efreet_Desktop *desktop, unsigned int size, Evas *evas)
return e_util_icon_theme_icon_add(desktop->icon, size, evas);
}
EAPI void
e_util_desktop_icon_file_set(Evas_Object *icon, Efreet_Desktop *desktop, unsigned int size)
{
if ((!desktop) || (!desktop->icon)) return;
return e_util_icon_theme_icon_file_set(icon, desktop->icon, size);
}
EAPI Evas_Object *
e_util_icon_theme_icon_add(const char *icon_name, unsigned int size, Evas *evas)
{
@ -1006,6 +1033,27 @@ e_util_icon_theme_icon_add(const char *icon_name, unsigned int size, Evas *evas)
return NULL;
}
EAPI void
e_util_icon_theme_icon_file_set(Evas_Object *icon, const char *icon_name, unsigned int size)
{
if (!icon_name) return;
if (icon_name[0] == '/')
{
e_util_icon_file_set(icon, icon_name);
}
else
{
char *path;
path = efreet_icon_path_find(e_config->icon_theme, icon_name, size);
if (path)
{
e_util_icon_file_set(icon, path);
free(path);
}
}
}
EAPI void
e_util_desktop_menu_item_icon_add(Efreet_Desktop *desktop, unsigned int size, E_Menu_Item *mi)
{

View File

@ -61,8 +61,11 @@ EAPI char *e_util_file_time_get(time_t ftime);
EAPI void e_util_library_path_strip(void);
EAPI void e_util_library_path_restore(void);
EAPI Evas_Object *e_util_icon_add(const char *path, Evas *evas);
EAPI void e_util_icon_file_set(Evas_Object *icon, const char *path);
EAPI Evas_Object *e_util_desktop_icon_add(Efreet_Desktop *desktop, unsigned int size, Evas *evas);
EAPI void e_util_desktop_icon_file_set(Evas_Object *icon, Efreet_Desktop *desktop, unsigned int size);
EAPI Evas_Object *e_util_icon_theme_icon_add(const char *icon_name, unsigned int size, Evas *evas);
EAPI void e_util_icon_theme_icon_file_set(Evas_Object *icon, const char *icon_name, unsigned int size);
EAPI void e_util_desktop_menu_item_icon_add(Efreet_Desktop *desktop, unsigned int size, E_Menu_Item *mi);
EAPI int e_util_dir_check(const char *dir);
EAPI void e_util_defer_object_del(E_Object *obj);

View File

@ -413,6 +413,15 @@ _ibar_resize_handle(IBar *b)
e_box_freeze(b->o_box);
EINA_LIST_FOREACH(b->icons, l, ic)
{
if ((w > 0) && (h > 0))
{
int size;
size = MAX(w, h);
/* TODO: Check icon padding */
if (ic->o_icon) e_util_desktop_icon_file_set(ic->o_icon, ic->app, size);
if (ic->o_icon2) e_util_desktop_icon_file_set(ic->o_icon2, ic->app, size);
}
e_box_pack_options_set(ic->o_holder,
1, 1, /* fill */
0, 0, /* expand */
@ -589,7 +598,6 @@ _ibar_icon_free(IBar_Icon *ic)
static void
_ibar_icon_fill(IBar_Icon *ic)
{
/* TODO: Correct icon size! */
if (ic->o_icon) evas_object_del(ic->o_icon);
ic->o_icon = e_util_desktop_icon_add(ic->app, 48,
evas_object_evas_get(ic->ibar->o_box));