EM_INTERN Evas_Object * em_util_icon_add(Evas_Object *obj, const char *icon) { Evas_Object *ow; const char *path; ow = elm_icon_add(obj); evas_object_size_hint_aspect_set(ow, EVAS_ASPECT_CONTROL_BOTH, 1, 1); #ifdef ELM_EFREET /* tell elm that we need efreet */ elm_need_efreet(); if (!(path = efreet_icon_path_find(getenv("E_ICON_THEME"), icon, 48))) { if (!(path = efreet_icon_path_find("default", icon, 48))) if (!(path = efreet_icon_path_find("hicolor", icon, 48))) if (!(path = efreet_icon_path_find("gnome", icon, 48))) path = efreet_icon_path_find("Human", icon, 48); } if (path) elm_icon_file_set(ow, path, NULL); #endif return ow; }
static const char * ewl_icon_theme_icon_path_get_helper(const char *icon, unsigned int size, const char *theme, const char *key, Ecore_Hash *cache) { char *ret; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(icon, EWL_THEME_KEY_NOMATCH); #if BUILD_EFREET_SUPPORT ret = ecore_hash_get(cache, key); if (!ret) { /* XXX: How to store NOMATCH in the cache? The cache is strings which must be free'd */ ret = efreet_icon_path_find(theme, icon, size); if (!ret) ret = EWL_THEME_KEY_NOMATCH; else ecore_hash_set(cache, strdup(key), (void *)ret); } #else ret = EWL_THEME_KEY_NOMATCH; #endif DRETURN_PTR(ret, DLEVEL_STABLE); }
E_API void e_util_desktop_menu_item_icon_add(Efreet_Desktop *desktop, unsigned int size, E_Menu_Item *mi) { const char *path = NULL; if ((!desktop) || (!desktop->icon)) return; if (desktop->icon[0] == '/') path = desktop->icon; else path = efreet_icon_path_find(e_config->icon_theme, desktop->icon, size); if (path) { const char *ext; ext = strrchr(path, '.'); if (ext) { if (strcmp(ext, ".edj") == 0) e_menu_item_icon_edje_set(mi, path, "icon"); else e_menu_item_icon_file_set(mi, path); } else e_menu_item_icon_file_set(mi, path); } }
static int _e_util_menu_item_fdo_icon_set(E_Menu_Item *mi, const char *icon) { const char *path = NULL; unsigned int size; if ((!icon) || (!icon[0])) return 0; size = e_util_icon_size_normalize(24 * e_scale); path = efreet_icon_path_find(e_config->icon_theme, icon, size); if (!path) return 0; e_menu_item_icon_file_set(mi, path); return 1; }
EAPI Eina_Bool 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 (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE; if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; if (sd->guessing_animation) ecore_timer_del(sd->guessing_animation); sd->guessing_animation = NULL; sd->frame = 0; sd->frame_count = 0; sd->edje = 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_FALSE; len = strlen(icon); if ((len > 4) && (!strcasecmp(icon + len - 4, ".edj"))) return e_icon_file_edje_set(obj, path, "icon"); /* 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); 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; }
static int _e_util_icon_fdo_set(Evas_Object *obj, const char *icon) { const char *path = NULL; unsigned int size; if ((!icon) || (!icon[0])) return 0; size = e_icon_scale_size_get(obj); if (size < 16) size = 16; size = e_util_icon_size_normalize(size * e_scale); path = efreet_icon_path_find(e_config->icon_theme, icon, size); if (!path) return 0; e_icon_file_set(obj, path); return 1; }
E_API Evas_Object * e_util_icon_theme_icon_add(const char *icon_name, unsigned int size, Evas *evas) { if (!icon_name) return NULL; if (icon_name[0] == '/') return _e_util_icon_add(icon_name, evas, size); else { Evas_Object *obj; const char *path; path = efreet_icon_path_find(e_config->icon_theme, icon_name, size); if (path) { obj = _e_util_icon_add(path, evas, size); return obj; } } return NULL; }