e icon - use new skip header async preload to make icon loads async

now they can be trule async hopefully stopping things like application
menu from stalling while loading icons header... which is really nasty
with svg's. this actually makes icons async by default which is really
EXACTLY what you want. this also prepares for later making edje loads
async.

@feature
This commit is contained in:
Carsten Haitzler 2017-01-01 22:19:51 +09:00
parent 227d49e346
commit 3779086a63
16 changed files with 135 additions and 136 deletions

View File

@ -176,11 +176,7 @@ e_dialog_icon_set(E_Dialog *dia, const char *icon, Evas_Coord size)
evas_object_show(dia->icon_object);
}
if (!e_util_icon_theme_set(dia->icon_object, icon))
if (!e_icon_file_edje_set(dia->icon_object, icon, "icon"))
{
E_FREE_FUNC(dia->icon_object, evas_object_del);
return;
}
e_icon_file_edje_set(dia->icon_object, icon, "icon");
evas_object_size_hint_min_set(dia->icon_object, size * e_scale, size * e_scale);
elm_layout_signal_emit(dia->bg_object, "e,state,icon", "e");
elm_layout_signal_emit(dia->bg_object, "e,icon,enabled", "e");

View File

@ -11517,9 +11517,9 @@ _update_volume_icon(E_Volume *v, E_Fm2_Icon *ic)
if (e)
{
if (ic->info.removable_full)
edje_object_signal_emit(e, "e,state,removable,full", "e");
e_icon_edje_emit(ic->obj_icon, "e,state,removable,full", "e");
else
edje_object_signal_emit(e, "e,state,removable,empty", "e");
e_icon_edje_emit(ic->obj_icon, "e,state,removable,empty", "e");
}
if (v)

View File

@ -217,20 +217,22 @@ _handle_anim(E_Smart_Data *sd)
return 1;
}
E_API Eina_Bool
E_API void
e_icon_file_set(Evas_Object *obj, const char *file)
{
E_Smart_Data *sd;
int len;
if (!file) return EINA_FALSE;
if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0);
if (!(sd = evas_object_smart_data_get(obj)))
return EINA_FALSE;
if (!file) return;
if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR();
if (!(sd = evas_object_smart_data_get(obj))) return;
len = strlen(file);
if ((len > 4) && (!strcasecmp(file + len - 4, ".edj")))
return e_icon_file_edje_set(obj, file, "icon");
{
e_icon_file_edje_set(obj, file, "icon");
return;
}
/* smart code here */
_e_icon_obj_prepare(obj, sd);
@ -258,13 +260,15 @@ e_icon_file_set(Evas_Object *obj, const char *file)
if (_e_icon_cache_find(obj, file))
{
_e_icon_smart_reconfigure(sd);
return EINA_TRUE;
return;
}
#endif
if (sd->preload)
evas_object_image_load_head_skip_set(sd->obj, EINA_TRUE);
evas_object_image_file_set(sd->obj, file, NULL);
if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
return EINA_FALSE;
// if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
// return EINA_FALSE;
if (!_handle_anim(sd))
{
@ -294,17 +298,15 @@ e_icon_file_set(Evas_Object *obj, const char *file)
#endif
_e_icon_smart_reconfigure(sd);
return EINA_TRUE;
}
E_API Eina_Bool
E_API void
e_icon_file_key_set(Evas_Object *obj, const char *file, const char *key)
{
E_Smart_Data *sd;
if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0);
if (!(sd = evas_object_smart_data_get(obj)))
return EINA_FALSE;
if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR();
if (!(sd = evas_object_smart_data_get(obj))) return;
/* smart code here */
sd->loading = 0;
@ -327,8 +329,8 @@ e_icon_file_key_set(Evas_Object *obj, const char *file, const char *key)
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, file, key);
if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
return EINA_FALSE;
// if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
// return EINA_FALSE;
if (!_handle_anim(sd))
{
if (sd->preload)
@ -340,7 +342,6 @@ e_icon_file_key_set(Evas_Object *obj, const char *file, const char *key)
evas_object_show(sd->obj);
}
_e_icon_smart_reconfigure(sd);
return EINA_TRUE;
}
E_API void
@ -385,14 +386,13 @@ e_icon_edje_get(Evas_Object *obj)
return sd->edje ? sd->obj : NULL;
}
E_API Eina_Bool
E_API void
e_icon_file_edje_set(Evas_Object *obj, const char *file, const char *part)
{
E_Smart_Data *sd;
if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0);
if (!(sd = evas_object_smart_data_get(obj)))
return EINA_FALSE;
if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR();
if (!(sd = evas_object_smart_data_get(obj))) return;
/* smart code here */
if (sd->obj) evas_object_del(sd->obj);
@ -413,27 +413,29 @@ e_icon_file_edje_set(Evas_Object *obj, const char *file, const char *part)
sd->obj = edje_object_add(evas_object_evas_get(obj));
edje_object_file_set(sd->obj, file, part);
if (edje_object_load_error_get(sd->obj) != EDJE_LOAD_ERROR_NONE)
return EINA_FALSE;
// if (edje_object_load_error_get(sd->obj) != EDJE_LOAD_ERROR_NONE)
// return EINA_FALSE;
if (evas_object_visible_get(obj)) evas_object_show(sd->obj);
evas_object_smart_member_add(sd->obj, obj);
_e_icon_smart_reconfigure(sd);
return EINA_TRUE;
}
E_API Eina_Bool
E_API void
e_icon_fdo_icon_set(Evas_Object *obj, const char *icon)
{
E_Smart_Data *sd;
const char *path;
int len;
if (!icon) return EINA_FALSE;
if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(0);
if (icon[0] == '/') return e_icon_file_set(obj, icon);
if (!icon) return;
if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR();
if (icon[0] == '/')
{
e_icon_file_set(obj, icon);
return;
}
if (!(sd = evas_object_smart_data_get(obj)))
return EINA_FALSE;
if (!(sd = evas_object_smart_data_get(obj))) return;
if (sd->timer) ecore_timer_del(sd->timer);
sd->timer = NULL;
@ -444,19 +446,22 @@ e_icon_fdo_icon_set(Evas_Object *obj, const char *icon)
sd->edje = EINA_FALSE;
eina_stringshare_replace(&sd->fdo, icon);
if (!sd->fdo) return EINA_FALSE;
if (!sd->fdo) return;
path = efreet_icon_path_find(e_config->icon_theme, sd->fdo, sd->size);
if (!path)
{
if (e_util_strcmp(e_config->icon_theme, "hicolor"))
path = efreet_icon_path_find("hicolor", sd->fdo, sd->size);
if (!path) return EINA_FALSE;
if (!path) return;
}
len = strlen(icon);
if ((len > 4) && (!strcasecmp(icon + len - 4, ".edj")))
return e_icon_file_edje_set(obj, path, "icon");
{
e_icon_file_edje_set(obj, path, "icon");
return;
}
/* smart code here */
_e_icon_obj_prepare(obj, sd);
@ -465,8 +470,8 @@ e_icon_fdo_icon_set(Evas_Object *obj, const char *icon)
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);
if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
return EINA_FALSE;
// if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
// return EINA_FALSE;
if (sd->preload)
{
sd->loading = 1;
@ -475,7 +480,7 @@ e_icon_fdo_icon_set(Evas_Object *obj, const char *icon)
else if (evas_object_visible_get(obj))
evas_object_show(sd->obj);
_e_icon_smart_reconfigure(sd);
return EINA_TRUE;
return;
}
E_API void
@ -723,6 +728,16 @@ e_icon_selected_set(const Evas_Object *obj, Eina_Bool selected)
edje_object_signal_emit(sd->obj, "e,state,unselected", "e");
}
E_API void
e_icon_edje_emit(const Evas_Object *obj, const char *sig, const char *src)
{
E_Smart_Data *sd;
if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR();
if (!(sd = evas_object_smart_data_get(obj))) return;
edje_object_signal_emit(sd->obj, sig, src);
}
/* local subsystem globals */
static void
_e_icon_smart_reconfigure(E_Smart_Data *sd)
@ -731,61 +746,62 @@ _e_icon_smart_reconfigure(E_Smart_Data *sd)
Evas_Coord x, y, w, h;
if (!sd->obj) return;
if (sd->edje)
w = sd->w;
h = sd->h;
x = sd->x;
y = sd->y;
if (!sd->loading)
{
w = sd->w;
h = sd->h;
x = sd->x;
y = sd->y;
evas_object_move(sd->obj, x, y);
evas_object_resize(sd->obj, w, h);
evas_object_move(sd->eventarea, x, y);
evas_object_resize(sd->eventarea, w, h);
}
else
{
iw = 0;
ih = 0;
evas_object_image_size_get(sd->obj, &iw, &ih);
if (iw < 1) iw = 1;
if (ih < 1) ih = 1;
if (sd->fill_inside)
if (sd->edje)
{
w = sd->w;
h = ((double)ih * w) / (double)iw;
if (h > sd->h)
{
h = sd->h;
w = ((double)iw * h) / (double)ih;
}
evas_object_move(sd->obj, x, y);
evas_object_resize(sd->obj, w, h);
}
else
{
w = sd->w;
h = ((double)ih * w) / (double)iw;
if (h < sd->h)
iw = 0;
ih = 0;
evas_object_image_size_get(sd->obj, &iw, &ih);
if (iw < 1) iw = 1;
if (ih < 1) ih = 1;
if (sd->fill_inside)
{
h = sd->h;
w = ((double)iw * h) / (double)ih;
w = sd->w;
h = ((double)ih * w) / (double)iw;
if (h > sd->h)
{
h = sd->h;
w = ((double)iw * h) / (double)ih;
}
}
}
if (!sd->scale_up)
{
if ((w > iw) || (h > ih))
else
{
w = iw;
h = ih;
w = sd->w;
h = ((double)ih * w) / (double)iw;
if (h < sd->h)
{
h = sd->h;
w = ((double)iw * h) / (double)ih;
}
}
if (!sd->scale_up)
{
if ((w > iw) || (h > ih))
{
w = iw;
h = ih;
}
}
x = sd->x + ((sd->w - w) / 2);
y = sd->y + ((sd->h - h) / 2);
evas_object_move(sd->obj, x, y);
evas_object_image_fill_set(sd->obj, 0, 0, w, h);
evas_object_resize(sd->obj, w, h);
}
x = sd->x + ((sd->w - w) / 2);
y = sd->y + ((sd->h - h) / 2);
evas_object_move(sd->obj, x, y);
evas_object_image_fill_set(sd->obj, 0, 0, w, h);
evas_object_resize(sd->obj, w, h);
evas_object_move(sd->eventarea, x, y);
evas_object_resize(sd->eventarea, w, h);
}
evas_object_move(sd->eventarea, x, y);
evas_object_resize(sd->eventarea, w, h);
}
static void
@ -820,7 +836,7 @@ _e_icon_preloaded(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
evas_object_smart_callback_call(data, "preloaded", NULL);
evas_object_show(sd->obj);
sd->loading = 0;
_e_icon_smart_reconfigure(sd);
#ifdef USE_ICON_CACHE
_e_icon_cache_icon_loaded(sd->ci);
#endif
@ -832,13 +848,15 @@ _e_icon_smart_add(Evas_Object *obj)
E_Smart_Data *sd;
if (!(sd = calloc(1, sizeof(E_Smart_Data)))) return;
sd->eventarea = evas_object_rectangle_add(evas_object_evas_get(obj));
evas_object_color_set(sd->eventarea, 0, 0, 0, 0);
evas_object_smart_member_add(sd->eventarea, obj);
sd->obj = evas_object_image_add(evas_object_evas_get(obj));
evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_IMAGE_PRELOADED,
_e_icon_preloaded, obj);
sd->eventarea = evas_object_rectangle_add(evas_object_evas_get(obj));
evas_object_color_set(sd->eventarea, 0, 0, 0, 0);
evas_object_smart_member_add(sd->eventarea, obj);
sd->x = 0;
sd->y = 0;
sd->w = 0;
@ -846,6 +864,7 @@ _e_icon_smart_add(Evas_Object *obj)
sd->fill_inside = 1;
sd->scale_up = 1;
sd->size = 64;
sd->preload = 0;
evas_object_smart_member_add(sd->obj, obj);
evas_object_smart_data_set(obj, sd);
}

View File

@ -31,6 +31,6 @@ E_API void *e_icon_data_get (const Evas_Object *obj, int *w, int
E_API void e_icon_scale_size_set (Evas_Object *obj, int size);
E_API int e_icon_scale_size_get (const Evas_Object *obj);
E_API void e_icon_selected_set (const Evas_Object *obj, Eina_Bool selected);
E_API void e_icon_edje_emit (const Evas_Object *obj, const char *sig, const char *src);
#endif
#endif

View File

@ -224,7 +224,8 @@ e_util_icon_theme_set(Evas_Object *obj, const char *icon)
{
if (icon && (icon[0] == '/'))
{
if (e_icon_file_set(obj, icon)) return 1;
e_icon_file_set(obj, icon);
return 1;
}
if (e_config->icon_theme_overrides)
{

View File

@ -49,19 +49,14 @@ e_widget_image_add_from_file(Evas *evas, const char *file, int minw, int minh)
Evas_Object *obj, *o;
E_Widget_Data *wd;
if (!ecore_file_exists(file)) return NULL;
obj = e_widget_add(evas);
wd = calloc(1, sizeof(E_Widget_Data));
if (!wd) return NULL;
o = e_icon_add(evas);
e_icon_fill_inside_set(o, 1);
if (!e_icon_file_set(o, file))
{
evas_object_del(o);
free(wd);
evas_object_del(obj);
return NULL;
}
e_icon_file_set(o, file);
wd->img = o;
evas_object_show(o);

View File

@ -459,6 +459,7 @@ e_xkb_e_icon_flag_setup(Evas_Object *eicon, const char *name)
char buf[PATH_MAX];
e_xkb_flag_file_get(buf, sizeof(buf), name);
e_icon_preload_set(eicon, EINA_FALSE);
e_icon_file_set(eicon, buf);
e_icon_size_get(eicon, &w, &h);
edje_extern_object_aspect_set(eicon, EDJE_ASPECT_CONTROL_BOTH, w, h);

View File

@ -316,11 +316,7 @@ _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
}
e_xkb_flag_file_get(buf, sizeof(buf), name);
icon = e_icon_add(evas);
if (!e_icon_file_set(icon, buf))
{
evas_object_del(icon);
icon = NULL;
}
e_icon_file_set(icon, buf);
if (cl->variant)
snprintf(buf, sizeof(buf), "%s (%s, %s)", cl->name, cl->model, cl->variant);
else

View File

@ -336,14 +336,8 @@ _icon_new(Evas *evas, const char *theme, const char *icon, unsigned int size)
if (!(path = efreet_icon_path_find(theme, icon, size))) return NULL;
o = e_icon_add(evas);
if (e_icon_file_set(o, path))
e_icon_fill_inside_set(o, 1);
else
{
evas_object_del(o);
o = NULL;
}
e_icon_file_set(o, path);
e_icon_fill_inside_set(o, EINA_TRUE);
return o;
}
@ -359,8 +353,8 @@ _populate_icon_preview(E_Config_Dialog_Data *cfdata)
if (!(path = efreet_icon_path_find(t, _icon_previews[i], PREVIEW_SIZE)))
continue;
if (e_icon_file_set(cfdata->gui.icon_preview[i], path))
e_icon_fill_inside_set(cfdata->gui.icon_preview[i], EINA_TRUE);
e_icon_file_set(cfdata->gui.icon_preview[i], path);
e_icon_fill_inside_set(cfdata->gui.icon_preview[i], EINA_TRUE);
}
}

View File

@ -441,11 +441,7 @@ evry_icon_theme_get(const char *icon, Evas *e)
if (icon[0] == '/')
{
if (!e_icon_file_set(o, icon))
{
evas_object_del(o);
o = NULL;
}
e_icon_file_set(o, icon);
}
else if (!e_util_icon_theme_set(o, icon))
{

View File

@ -972,11 +972,11 @@ _ibar_icon_signal_emit(IBar_Icon *ic, const char *sig, const char *src)
if (ic->o_holder)
edje_object_signal_emit(ic->o_holder, sig, src);
if (ic->o_icon && e_icon_edje_get(ic->o_icon))
edje_object_signal_emit(e_icon_edje_get(ic->o_icon), sig, src);
e_icon_edje_emit(ic->o_icon, sig, src);
if (ic->o_holder2)
edje_object_signal_emit(ic->o_holder2, sig, src);
if (ic->o_icon2 && e_icon_edje_get(ic->o_icon2))
edje_object_signal_emit(e_icon_edje_get(ic->o_icon2), sig, src);
e_icon_edje_emit(ic->o_icon2, sig, src);
}
static void

View File

@ -635,11 +635,11 @@ _ibox_icon_signal_emit(IBox_Icon *ic, char *sig, char *src)
if (ic->o_holder)
edje_object_signal_emit(ic->o_holder, sig, src);
if (ic->o_icon && e_icon_edje_get(ic->o_icon))
edje_object_signal_emit(e_icon_edje_get(ic->o_icon), sig, src);
e_icon_edje_emit(ic->o_icon, sig, src);
if (ic->o_holder2)
edje_object_signal_emit(ic->o_holder2, sig, src);
if (ic->o_icon2 && e_icon_edje_get(ic->o_icon2))
edje_object_signal_emit(e_icon_edje_get(ic->o_icon2), sig, src);
e_icon_edje_emit(ic->o_icon2, sig, src);
}
static Eina_List *

View File

@ -470,12 +470,11 @@ _notification_popup_refresh(Popup_Data *popup)
if (!popup->app_icon)
{
popup->app_icon = e_icon_add(popup->e);
if (!e_icon_file_set(popup->app_icon, uri ? uri->path : icon_path))
{
evas_object_del(popup->app_icon);
popup->app_icon = NULL;
}
else e_icon_size_get(popup->app_icon, &w, &h);
e_icon_file_set(popup->app_icon, uri ? uri->path : icon_path);
// XXX: FIXME: this disallows for async to work
// e_icon_size_get(popup->app_icon, &w, &h);
w = width;
h = height;
}
efreet_uri_free(uri);
}

View File

@ -93,7 +93,11 @@ image_load(const char *name, const char *path, uint32_t *imgdata, int w, int h,
for (ext = exts; *ext; ext++)
{
snprintf(buf, sizeof(buf), "%s/%s/%ux%u/apps/%s%s", path, *theme, *i, *i, name, *ext);
if (e_icon_file_set(image, buf)) return;
if (ecore_file_exists(buf))
{
e_icon_file_set(image, buf);
return;
}
}
}
}

View File

@ -723,7 +723,7 @@ _tasks_item_signal_emit(Tasks_Item *item, char *sig, char *src)
{
if (item->o_item) edje_object_signal_emit(item->o_item, sig, src);
if (item->o_icon && e_icon_edje_get(item->o_icon))
edje_object_signal_emit(e_icon_edje_get(item->o_icon), sig, src);
e_icon_edje_emit(item->o_icon, sig, src);
}
static Config_Item *

View File

@ -773,8 +773,7 @@ _e_winlist_activate(void)
ww = _win_selected->data;
edje_object_signal_emit(ww->bg_object, "e,state,selected", "e");
if (ww->icon_object && e_icon_edje_get(ww->icon_object))
edje_object_signal_emit(e_icon_edje_get(ww->icon_object),
"e,state,selected", "e");
e_icon_edje_emit(ww->icon_object, "e,state,selected", "e");
if ((ww->client->iconic) &&
(e_config->winlist_list_uncover_while_selecting))
@ -868,8 +867,7 @@ _e_winlist_deactivate(void)
edje_object_part_text_set(_bg_object, "e.text.label", "");
edje_object_signal_emit(ww->bg_object, "e,state,unselected", "e");
if (ww->icon_object && e_icon_edje_get(ww->icon_object))
edje_object_signal_emit(e_icon_edje_get(ww->icon_object),
"e,state,unselected", "e");
e_icon_edje_emit(ww->icon_object, "e,state,unselected", "e");
if (!ww->client->lock_focus_in)
evas_object_focus_set(ww->client->frame, 0);
}