Set fdo icon directly in e_icon

This makes it simple to find the right icon size for current view size

SVN revision: 54177
This commit is contained in:
Sebastian Dransfeld 2010-11-05 13:11:31 +00:00
parent 264cedf728
commit 1ba2fd77a0
3 changed files with 79 additions and 13 deletions

View File

@ -8,6 +8,7 @@ struct _E_Smart_Data
Evas_Object *obj;
Evas_Object *eventarea;
int size;
const char *fdo;
unsigned char fill_inside : 1;
unsigned char scale_up : 1;
unsigned char preload : 1;
@ -67,6 +68,11 @@ e_icon_file_set(Evas_Object *obj, const char *file)
_e_icon_obj_prepare(obj, sd);
/* FIXME: 64x64 - unhappy about this. use icon size */
sd->loading = 0;
if (sd->fdo)
{
eina_stringshare_del(sd->fdo);
sd->fdo = NULL;
}
if (sd->size != 0)
evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
if (sd->preload) evas_object_hide(sd->obj);
@ -94,6 +100,11 @@ e_icon_file_key_set(Evas_Object *obj, const char *file, const char *key)
/* smart code here */
sd->loading = 0;
if (sd->fdo)
{
eina_stringshare_del(sd->fdo);
sd->fdo = NULL;
}
_e_icon_obj_prepare(obj, sd);
if (sd->size != 0)
evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
@ -123,6 +134,11 @@ e_icon_file_edje_set(Evas_Object *obj, const char *file, const char *part)
/* smart code here */
if (sd->obj) evas_object_del(sd->obj);
sd->loading = 0;
if (sd->fdo)
{
eina_stringshare_del(sd->fdo);
sd->fdo = NULL;
}
sd->obj = edje_object_add(evas_object_evas_get(obj));
edje_object_file_set(sd->obj, file, part);
if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
@ -133,6 +149,44 @@ e_icon_file_edje_set(Evas_Object *obj, const char *file, const char *part)
return EINA_TRUE;
}
EAPI Eina_Bool
e_icon_fdo_icon_set(Evas_Object *obj, const char *icon)
{
E_Smart_Data *sd;
char *path;
if (!icon) return EINA_TRUE;
if (icon[0] == '/') return e_icon_file_set(obj, icon);
if (!(sd = evas_object_smart_data_get(obj)))
return EINA_FALSE;
eina_stringshare_replace(&sd->fdo, icon);
if (!sd->fdo) return EINA_FALSE;
path = efreet_icon_path_find(e_config->icon_theme, sd->fdo, sd->size);
if (!path) return EINA_TRUE;
/* smart code here */
_e_icon_obj_prepare(obj, sd);
sd->loading = 0;
if (sd->size != 0)
evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
if (sd->preload) evas_object_hide(sd->obj);
evas_object_image_file_set(sd->obj, path, NULL);
free(path);
if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
return EINA_FALSE;
if (sd->preload)
{
sd->loading = 1;
evas_object_image_preload(sd->obj, 0);
}
else if (evas_object_visible_get(obj))
evas_object_show(sd->obj);
_e_icon_smart_reconfigure(sd);
return EINA_TRUE;
}
EAPI void
e_icon_object_set(Evas_Object *obj, Evas_Object *o)
{
@ -466,6 +520,7 @@ _e_icon_smart_del(Evas_Object *obj)
if (!(sd = evas_object_smart_data_get(obj))) return;
evas_object_del(sd->obj);
evas_object_del(sd->eventarea);
if (sd->fdo) eina_stringshare_del(sd->fdo);
free(sd);
}
@ -490,6 +545,25 @@ _e_icon_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
if ((sd->w == w) && (sd->h == h)) return;
sd->w = w;
sd->h = h;
if (sd->fdo)
{
char *path;
sd->size = MAX(w, h);
path = efreet_icon_path_find(e_config->icon_theme, sd->fdo, sd->size);
if (!path) return;
/* smart code here */
evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
evas_object_image_file_set(sd->obj, path, NULL);
free(path);
if (sd->preload)
{
sd->loading = 1;
evas_object_image_preload(sd->obj, 0);
}
}
_e_icon_smart_reconfigure(sd);
}

View File

@ -7,6 +7,7 @@ EAPI Evas_Object *e_icon_add (Evas *evas);
EAPI Eina_Bool e_icon_file_set (Evas_Object *obj, const char *file);
EAPI Eina_Bool e_icon_file_key_set (Evas_Object *obj, const char *file, const char *key);
EAPI Eina_Bool e_icon_file_edje_set (Evas_Object *obj, const char *file, const char *part);
EAPI Eina_Bool e_icon_fdo_icon_set (Evas_Object *obj, const char *icon);
EAPI void e_icon_object_set (Evas_Object *obj, Evas_Object *o);
EAPI const char *e_icon_file_get (const Evas_Object *obj);
EAPI void e_icon_smooth_scale_set (Evas_Object *obj, Eina_Bool smooth);

View File

@ -413,15 +413,6 @@ _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 */
@ -599,14 +590,14 @@ static void
_ibar_icon_fill(IBar_Icon *ic)
{
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));
ic->o_icon = e_icon_add(evas_object_evas_get(ic->ibar->o_box));
e_icon_fdo_icon_set(ic->o_icon, ic->app->icon);
edje_object_part_swallow(ic->o_holder, "e.swallow.content", ic->o_icon);
evas_object_pass_events_set(ic->o_icon, 1);
evas_object_show(ic->o_icon);
if (ic->o_icon2) evas_object_del(ic->o_icon2);
ic->o_icon2 = e_util_desktop_icon_add(ic->app, 48,
evas_object_evas_get(ic->ibar->o_box));
ic->o_icon2 = e_icon_add(evas_object_evas_get(ic->ibar->o_box));
e_icon_fdo_icon_set(ic->o_icon2, ic->app->icon);
edje_object_part_swallow(ic->o_holder2, "e.swallow.content", ic->o_icon2);
evas_object_pass_events_set(ic->o_icon2, 1);
evas_object_show(ic->o_icon2);