1 #include <Elementary.h>
6 #define NON_EXISTING (void *)-1
7 static const char *icon_theme = NULL;
10 typedef struct _Widget_Data Widget_Data;
16 Elm_Icon_Lookup_Order lookup_order;
18 #ifdef HAVE_ELEMENTARY_ETHUMB
25 Ecore_Event_Handler *eeh;
27 Ethumb_Thumb_Format format;
29 Ethumb_Client_Async *request;
42 Eina_Bool scale_up : 1;
43 Eina_Bool scale_down : 1;
45 Eina_Bool fill_outside : 1;
46 Eina_Bool no_scale : 1;
48 /* for animation feature */
57 #ifdef HAVE_ELEMENTARY_ETHUMB
58 static Eina_List *_elm_icon_retry = NULL;
59 static int _icon_pending_request = 0;
62 static const char *widtype = NULL;
63 static void _del_hook(Evas_Object *obj);
64 static void _theme_hook(Evas_Object *obj);
65 static void _sizing_eval(Evas_Object *obj);
66 static void _mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
68 static Eina_Bool _icon_standard_set(Widget_Data *wd, Evas_Object *obj, const char *name);
69 static Eina_Bool _icon_freedesktop_set(Widget_Data *wd, Evas_Object *obj, const char *name, int size);
71 static const char SIG_CLICKED[] = "clicked";
73 static const Evas_Smart_Cb_Description _signals[] = {
79 //FIXME: move this code to ecore
82 _path_is_absolute(const char *path)
84 //TODO: Check if this works with all absolute paths in windows
85 return ((isalpha (*path)) && (*(path + 1) == ':') && ((*(path + 2) == '\\') || (*(path + 2) == '/')));
89 _path_is_absolute(const char *path)
91 return (*path == '/');
96 _icon_size_min_get(Evas_Object *icon)
99 _els_smart_icon_size_get(icon, &size, NULL);
100 return (size < 16) ? 16 : size;
103 #ifdef HAVE_ELEMENTARY_ETHUMB
105 _icon_thumb_stop(Widget_Data *wd, void *ethumbd)
107 if (wd->thumb.request)
109 ethumb_client_thumb_async_cancel(ethumbd, wd->thumb.request);
110 wd->thumb.request = NULL;
111 _icon_pending_request--;
116 _elm_icon_retry = eina_list_remove(_elm_icon_retry, wd);
117 wd->thumb.retry = EINA_FALSE;
122 _icon_thumb_display(Widget_Data *wd)
124 Eina_Bool ret = EINA_FALSE;
126 if (wd->thumb.format == ETHUMB_THUMB_EET)
128 static const char *extensions[] = {
129 ".avi", ".mp4", ".ogv", ".mov", ".mpg", ".wmv", NULL
131 const char **ext, *ptr;
133 Eina_Bool video = EINA_FALSE;
135 prefix_size = eina_stringshare_strlen(wd->thumb.file.path) - 4;
136 if (prefix_size >= 0)
138 ptr = wd->thumb.file.path + prefix_size;
139 for (ext = extensions; *ext; ++ext)
140 if (!strcasecmp(ptr, *ext))
148 ret = _els_smart_icon_file_edje_set(wd->img, wd->thumb.thumb.path, wd->thumb.thumb.key);
152 ret = _els_smart_icon_file_key_set(wd->img, wd->thumb.thumb.path, wd->thumb.thumb.key);
158 _icon_thumb_retry(Widget_Data *wd)
160 return _icon_thumb_display(wd);
164 _icon_thumb_cleanup(Ethumb_Client *ethumbd)
169 EINA_LIST_FOREACH_SAFE(_elm_icon_retry, l, ll, wd)
170 if (_icon_thumb_retry(wd))
172 _elm_icon_retry = eina_list_remove_list(_elm_icon_retry, l);
173 wd->thumb.retry = EINA_FALSE;
176 if (_icon_pending_request == 0)
177 EINA_LIST_FREE(_elm_icon_retry, wd)
178 _icon_thumb_stop(wd, ethumbd);
182 _icon_thumb_finish(Widget_Data *wd, Ethumb_Client *ethumbd)
184 const char *file = NULL, *group = NULL;
187 _els_smart_icon_file_get(wd->img, &file, &group);
188 file = eina_stringshare_ref(file);
189 group = eina_stringshare_ref(group);
191 ret = _icon_thumb_display(wd);
197 if (!wd->thumb.retry)
199 _elm_icon_retry = eina_list_append(_elm_icon_retry, wd);
200 wd->thumb.retry = EINA_TRUE;
203 /* Back to previous image */
204 if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
205 _els_smart_icon_file_edje_set(wd->img, file, group);
207 _els_smart_icon_file_key_set(wd->img, file, group);
210 _icon_thumb_cleanup(ethumbd);
212 eina_stringshare_del(file);
213 eina_stringshare_del(group);
217 _icon_thumb_done(Ethumb_Client *client, const char *thumb_path, const char *thumb_key, void *data)
219 Widget_Data *wd = data;
221 assert(wd->thumb.request);
223 _icon_pending_request--;
224 wd->thumb.request = NULL;
226 eina_stringshare_replace(&wd->thumb.thumb.path, thumb_path);
227 eina_stringshare_replace(&wd->thumb.thumb.key, thumb_key);
228 wd->thumb.format = ethumb_client_format_get(client);
230 _icon_thumb_finish(wd, client);
234 _icon_thumb_error(Ethumb_Client *client, void *data)
236 Widget_Data *wd = data;
238 assert(wd->thumb.request);
240 _icon_pending_request--;
241 wd->thumb.request = NULL;
243 ERR("could not generate thumbnail for %s (key: %s)", wd->thumb.file.path, wd->thumb.file.key);
244 _icon_thumb_cleanup(client);
248 _icon_thumb_apply(Widget_Data *wd)
250 Ethumb_Client *ethumbd;
252 ethumbd = elm_thumb_ethumb_client_get();
254 _icon_thumb_stop(wd, ethumbd);
256 if (!wd->thumb.file.path) return ;
258 _icon_pending_request++;
259 if (!ethumb_client_file_set(ethumbd, wd->thumb.file.path, wd->thumb.file.key)) return ;
260 ethumb_client_size_set(ethumbd, _icon_size_min_get(wd->img), _icon_size_min_get(wd->img));
261 wd->thumb.request = ethumb_client_thumb_async_get(ethumbd, _icon_thumb_done, _icon_thumb_error, wd);
265 _icon_thumb_apply_cb(void *data, int type __UNUSED__, void *ev __UNUSED__)
267 Widget_Data *wd = data;
269 _icon_thumb_apply(wd);
270 return ECORE_CALLBACK_RENEW;
275 _del_hook(Evas_Object *obj)
277 Widget_Data *wd = elm_widget_data_get(obj);
278 #ifdef HAVE_ELEMENTARY_ETHUMB
279 Ethumb_Client *ethumbd;
283 if (wd->stdicon) eina_stringshare_del(wd->stdicon);
285 #ifdef HAVE_ELEMENTARY_ETHUMB
286 ethumbd = elm_thumb_ethumb_client_get();
287 _icon_thumb_stop(wd, ethumbd);
289 eina_stringshare_del(wd->thumb.file.path);
290 eina_stringshare_del(wd->thumb.file.key);
291 eina_stringshare_del(wd->thumb.thumb.path);
292 eina_stringshare_del(wd->thumb.thumb.key);
295 ecore_event_handler_del(wd->thumb.eeh);
299 ecore_timer_del(wd->timer);
304 _theme_hook(Evas_Object *obj)
306 Widget_Data *wd = elm_widget_data_get(obj);
309 _elm_theme_object_icon_set(obj, wd->img, wd->stdicon, elm_widget_style_get(obj));
314 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
316 Widget_Data *wd = elm_widget_data_get(obj);
318 Evas_Object *icon_edje;
319 icon_edje = _els_smart_icon_edje_get(wd->img);
320 if (!icon_edje) return;
321 edje_object_signal_emit(icon_edje, emission, source);
325 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
327 Widget_Data *wd = elm_widget_data_get(obj);
329 Evas_Object *icon_edje;
330 icon_edje = _els_smart_icon_edje_get(wd->img);
331 if (!icon_edje) return;
332 edje_object_signal_callback_add(icon_edje, emission, source, func_cb, data);
336 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
338 Widget_Data *wd = elm_widget_data_get(obj);
340 Evas_Object *icon_edje;
341 icon_edje = _els_smart_icon_edje_get(wd->img);
342 if (!icon_edje) return;
343 edje_object_signal_callback_del_full(icon_edje, emission, source, func_cb,
348 _sizing_eval(Evas_Object *obj)
350 Widget_Data *wd = elm_widget_data_get(obj);
352 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
356 _els_smart_icon_size_get(wd->img, &w, &h);
358 if (wd->freedesktop.use && wd->stdicon)
361 /* This icon has been set to a freedesktop icon, and the requested
362 appears to have a different size than the requested size, so try to
363 request another, higher resolution, icon.
364 FIXME: Find a better heuristic to determine if there should be
365 an icon with a different resolution. */
366 size = ((w / 16) + 1) * 16;
367 _icon_freedesktop_set(wd, obj, wd->stdicon, size);
370 _els_smart_icon_scale_up_set(wd->img, wd->scale_up);
371 _els_smart_icon_scale_down_set(wd->img, wd->scale_down);
372 _els_smart_icon_smooth_scale_set(wd->img, wd->smooth);
373 _els_smart_icon_fill_inside_set(wd->img, !(wd->fill_outside));
374 if (wd->no_scale) _els_smart_icon_scale_set(wd->img, 1.0);
377 _els_smart_icon_scale_set(wd->img, elm_widget_scale_get(obj) *
379 _els_smart_icon_size_get(wd->img, &w, &h);
391 evas_object_size_hint_min_set(obj, minw, minh);
392 evas_object_size_hint_max_set(obj, maxw, maxh);
397 _mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
399 Evas_Event_Mouse_Up *ev = event_info;
400 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
401 evas_object_smart_callback_call(data, SIG_CLICKED, event_info);
405 _elm_icon_animate_cb(void *data)
407 Widget_Data *wd = data;
408 Evas_Object *img_obj;
410 if (!wd) return ECORE_CALLBACK_CANCEL;
411 if (!wd->anim) return ECORE_CALLBACK_CANCEL;
413 img_obj = _els_smart_icon_object_get(wd->img);
415 if (wd->cur_frame > wd->frame_count)
416 wd->cur_frame = wd->cur_frame % wd->frame_count;
417 evas_object_image_animated_frame_set(img_obj, wd->cur_frame);
419 wd->duration = evas_object_image_animated_frame_duration_get(img_obj, wd->cur_frame, 0);
421 if (wd->duration > 0)
422 ecore_timer_interval_set(wd->timer, wd->duration);
423 return ECORE_CALLBACK_RENEW;
427 _icon_standard_set(Widget_Data *wd, Evas_Object *obj, const char *name)
429 if (_elm_theme_object_icon_set(obj, wd->img, name, "default"))
432 /* TODO: elm_unneed_efreet() */
433 wd->freedesktop.use = EINA_FALSE;
442 _icon_file_set(Widget_Data *wd, Evas_Object *obj, const char *path)
444 _icon_file_set(Widget_Data *wd __UNUSED__, Evas_Object *obj, const char *path)
447 if (elm_icon_file_set(obj, path, NULL))
450 /* TODO: elm_unneed_efreet() */
451 wd->freedesktop.use = EINA_FALSE;
460 _icon_freedesktop_set(Widget_Data *wd, Evas_Object *obj, const char *name, int size)
462 _icon_freedesktop_set(Widget_Data *wd __UNUSED__, Evas_Object *obj __UNUSED__, const char *name __UNUSED__, int size __UNUSED__)
469 if (icon_theme == NON_EXISTING) return EINA_FALSE;
472 Efreet_Icon_Theme *theme;
473 /* TODO: Listen for EFREET_EVENT_ICON_CACHE_UPDATE */
474 theme = efreet_icon_theme_find(getenv("E_ICON_THEME"));
478 static const char *themes[] = {
479 "gnome", "Human", "oxygen", "hicolor", NULL
481 for (itr = themes; *itr; itr++)
483 theme = efreet_icon_theme_find(*itr);
490 icon_theme = NON_EXISTING;
494 icon_theme = eina_stringshare_add(theme->name.internal);
496 path = efreet_icon_path_find(icon_theme, name, size);
497 wd->freedesktop.use = !!path;
498 if (wd->freedesktop.use)
500 wd->freedesktop.requested_size = size;
501 elm_icon_file_set(obj, path, NULL);
509 _elm_icon_standard_set(Widget_Data *wd, Evas_Object *obj, const char *name, Eina_Bool *fdo)
514 /* try locating the icon using the specified lookup order */
515 switch (wd->lookup_order)
517 case ELM_ICON_LOOKUP_FDO:
518 ret = _icon_freedesktop_set(wd, obj, name, _icon_size_min_get(wd->img));
519 if (ret && fdo) *fdo = EINA_TRUE;
521 case ELM_ICON_LOOKUP_THEME:
522 ret = _icon_standard_set(wd, obj, name);
524 case ELM_ICON_LOOKUP_THEME_FDO:
525 ret = _icon_standard_set(wd, obj, name);
528 ret = _icon_freedesktop_set(wd, obj, name, _icon_size_min_get(wd->img));
529 if (ret && fdo) *fdo = EINA_TRUE;
532 case ELM_ICON_LOOKUP_FDO_THEME:
534 ret = _icon_freedesktop_set(wd, obj, name, _icon_size_min_get(wd->img));
536 ret = _icon_standard_set(wd, obj, name);
544 eina_stringshare_replace(&wd->stdicon, name);
545 if (!wd->in_eval) _sizing_eval(obj);
549 if (_path_is_absolute(name))
550 return _icon_file_set(wd, obj, name);
552 /* if that fails, see if icon name is in the format size/name. if so,
553 try locating a fallback without the size specification */
554 if (!(tmp = strchr(name, '/'))) return EINA_FALSE;
556 if (*tmp) return elm_icon_standard_set(obj, tmp);
562 _elm_icon_standard_resize(void *data,
565 void *event_info __UNUSED__)
567 Widget_Data *wd = data;
568 const char *refup = eina_stringshare_ref(wd->stdicon);
569 Eina_Bool fdo = EINA_FALSE;
571 if (!_elm_icon_standard_set(wd, obj, wd->stdicon, &fdo) || (!fdo))
572 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
573 _elm_icon_standard_resize, wd);
574 eina_stringshare_del(refup);
577 #ifdef HAVE_ELEMENTARY_ETHUMB
579 _elm_icon_thumb_resize(void *data,
582 void *event_info __UNUSED__)
584 Widget_Data *wd = data;
586 if (wd->thumb.file.path)
587 elm_icon_thumb_set(obj, wd->thumb.file.path, wd->thumb.file.key);
592 elm_icon_add(Evas_Object *parent)
598 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
600 ELM_SET_WIDTYPE(widtype, "icon");
601 elm_widget_type_set(obj, "icon");
602 elm_widget_can_focus_set(obj, EINA_FALSE);
603 elm_widget_sub_object_add(parent, obj);
604 elm_widget_data_set(obj, wd);
605 elm_widget_del_hook_set(obj, _del_hook);
606 elm_widget_theme_hook_set(obj, _theme_hook);
607 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
608 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
609 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
611 wd->lookup_order = ELM_ICON_LOOKUP_THEME_FDO;
612 wd->img = _els_smart_icon_add(e);
613 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
615 evas_object_repeat_events_set(wd->img, EINA_TRUE);
616 elm_widget_resize_object_set(obj, wd->img);
618 evas_object_smart_callbacks_descriptions_set(obj, _signals);
620 #ifdef HAVE_ELEMENTARY_ETHUMB
621 wd->thumb.request = NULL;
624 wd->smooth = EINA_TRUE;
625 wd->scale_up = EINA_TRUE;
626 wd->scale_down = EINA_TRUE;
633 elm_icon_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key)
635 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
636 Widget_Data *wd = elm_widget_data_get(obj);
639 if (!wd) return EINA_FALSE;
640 EINA_SAFETY_ON_NULL_RETURN_VAL(img, EINA_FALSE);
641 EINA_SAFETY_ON_TRUE_RETURN_VAL(!size, EINA_FALSE);
642 eina_stringshare_del(wd->stdicon);
644 ret = _els_smart_icon_memfile_set(wd->img, img, size, format, key);
645 if (!wd->in_eval) _sizing_eval(obj);
650 elm_icon_file_set(Evas_Object *obj, const char *file, const char *group)
652 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
653 Widget_Data *wd = elm_widget_data_get(obj);
655 const char *tmp_file;
656 const char *tmp_group;
658 if (!wd) return EINA_FALSE;
659 EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE);
661 _els_smart_icon_file_get(wd->img, &tmp_file, &tmp_group);
662 if ((tmp_file == file || (file && tmp_file && !strcmp(tmp_file, file)))
663 && (group == tmp_group || (group && tmp_group && !strcmp(group, tmp_group))))
667 if (!wd->freedesktop.use)
669 if (wd->stdicon) eina_stringshare_del(wd->stdicon);
673 if (eina_str_has_extension(file, ".edj"))
674 ret = _els_smart_icon_file_edje_set(wd->img, file, group);
676 ret = _els_smart_icon_file_key_set(wd->img, file, group);
677 if (!wd->in_eval) _sizing_eval(obj);
682 elm_icon_file_get(const Evas_Object *obj, const char **file, const char **group)
684 ELM_CHECK_WIDTYPE(obj, widtype);
685 Widget_Data *wd = elm_widget_data_get(obj);
687 _els_smart_icon_file_get(wd->img, file, group);
691 elm_icon_thumb_set(Evas_Object *obj, const char *file, const char *group)
693 ELM_CHECK_WIDTYPE(obj, widtype);
694 Widget_Data *wd = elm_widget_data_get(obj);
697 #ifdef HAVE_ELEMENTARY_ETHUMB
698 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
699 _elm_icon_standard_resize, wd);
700 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
701 _elm_icon_thumb_resize, wd);
703 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
704 _elm_icon_thumb_resize, wd);
706 eina_stringshare_replace(&wd->thumb.file.path, file);
707 eina_stringshare_replace(&wd->thumb.file.key, group);
709 if (elm_thumb_ethumb_client_connected())
711 _icon_thumb_apply(wd);
717 wd->thumb.eeh = ecore_event_handler_add(ELM_ECORE_EVENT_ETHUMB_CONNECT, _icon_thumb_apply_cb, wd);
728 elm_icon_animated_available_get(const Evas_Object *obj)
730 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
731 Evas_Object *img_obj ;
732 Widget_Data *wd = elm_widget_data_get(obj);
733 if (!wd) return EINA_FALSE;
735 img_obj = _els_smart_icon_object_get(wd->img);
737 return evas_object_image_animated_get(img_obj);
741 elm_icon_animated_set(Evas_Object *obj, Eina_Bool anim)
743 ELM_CHECK_WIDTYPE(obj, widtype);
744 Evas_Object *img_obj ;
745 Widget_Data *wd = elm_widget_data_get(obj);
747 if (wd->anim == anim) return;
749 img_obj = _els_smart_icon_object_get(wd->img);
750 if (!evas_object_image_animated_get(img_obj)) return;
753 wd->frame_count = evas_object_image_animated_frame_count_get(img_obj);
755 wd->duration = evas_object_image_animated_frame_duration_get(img_obj, wd->cur_frame, 0);
756 evas_object_image_animated_frame_set(img_obj, wd->cur_frame);
760 wd->frame_count = -1;
769 elm_icon_animated_get(const Evas_Object *obj)
771 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
772 Widget_Data *wd = elm_widget_data_get(obj);
773 if (!wd) return EINA_FALSE;
778 elm_icon_animated_play_set(Evas_Object *obj, Eina_Bool play)
780 ELM_CHECK_WIDTYPE(obj, widtype);
781 Widget_Data *wd = elm_widget_data_get(obj);
783 if (!wd->anim) return;
784 if (wd->play == play) return;
788 wd->timer = ecore_timer_add(wd->duration, _elm_icon_animate_cb, wd);
794 ecore_timer_del(wd->timer);
803 elm_icon_animated_play_get(const Evas_Object *obj)
805 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
806 Widget_Data *wd = elm_widget_data_get(obj);
807 if (!wd) return EINA_FALSE;
812 elm_icon_standard_set(Evas_Object *obj, const char *name)
814 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
815 Widget_Data *wd = elm_widget_data_get(obj);
816 Eina_Bool fdo = EINA_FALSE;
819 if ((!wd) || (!name)) return EINA_FALSE;
821 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
822 _elm_icon_standard_resize, wd);
824 ret = _elm_icon_standard_set(wd, obj, name, &fdo);
827 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
828 _elm_icon_standard_resize, wd);
834 elm_icon_standard_get(const Evas_Object *obj)
836 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
837 Widget_Data *wd = elm_widget_data_get(obj);
838 if (!wd) return NULL;
843 elm_icon_order_lookup_set(Evas_Object *obj, Elm_Icon_Lookup_Order order)
845 ELM_CHECK_WIDTYPE(obj, widtype);
846 Widget_Data *wd = elm_widget_data_get(obj);
847 if (wd) wd->lookup_order = order;
850 EAPI Elm_Icon_Lookup_Order
851 elm_icon_order_lookup_get(const Evas_Object *obj)
853 ELM_CHECK_WIDTYPE(obj, widtype) ELM_ICON_LOOKUP_THEME_FDO;
854 Widget_Data *wd = elm_widget_data_get(obj);
855 if (!wd) return ELM_ICON_LOOKUP_THEME_FDO;
856 return wd->lookup_order;
860 elm_icon_smooth_set(Evas_Object *obj, Eina_Bool smooth)
862 ELM_CHECK_WIDTYPE(obj, widtype);
863 Widget_Data *wd = elm_widget_data_get(obj);
867 if (!wd->in_eval) _sizing_eval(obj);
871 elm_icon_smooth_get(const Evas_Object *obj)
873 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
874 Widget_Data *wd = elm_widget_data_get(obj);
876 if (!wd) return EINA_FALSE;
881 elm_icon_no_scale_set(Evas_Object *obj, Eina_Bool no_scale)
883 ELM_CHECK_WIDTYPE(obj, widtype);
884 Widget_Data *wd = elm_widget_data_get(obj);
887 wd->no_scale = no_scale;
888 if (!wd->in_eval) _sizing_eval(obj);
892 elm_icon_no_scale_get(const Evas_Object *obj)
894 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
895 Widget_Data *wd = elm_widget_data_get(obj);
896 if (!wd) return EINA_FALSE;
901 elm_icon_scale_set(Evas_Object *obj, Eina_Bool scale_up, Eina_Bool scale_down)
903 ELM_CHECK_WIDTYPE(obj, widtype);
904 Widget_Data *wd = elm_widget_data_get(obj);
907 wd->scale_up = scale_up;
908 wd->scale_down = scale_down;
909 if (!wd->in_eval) _sizing_eval(obj);
913 elm_icon_scale_get(const Evas_Object *obj, Eina_Bool *scale_up, Eina_Bool *scale_down)
915 ELM_CHECK_WIDTYPE(obj, widtype);
916 Widget_Data *wd = elm_widget_data_get(obj);
918 if (scale_up) *scale_up = wd->scale_up;
919 if (scale_down) *scale_down = wd->scale_down;
923 elm_icon_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside)
925 ELM_CHECK_WIDTYPE(obj, widtype);
926 Widget_Data *wd = elm_widget_data_get(obj);
929 wd->fill_outside = fill_outside;
930 if (!wd->in_eval) _sizing_eval(obj);
934 elm_icon_size_get(const Evas_Object *obj, int *w, int *h)
936 ELM_CHECK_WIDTYPE(obj, widtype);
937 Widget_Data *wd = elm_widget_data_get(obj);
940 _els_smart_icon_size_get(wd->img, w, h);
944 elm_icon_fill_outside_get(const Evas_Object *obj)
946 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
947 Widget_Data *wd = elm_widget_data_get(obj);
949 if (!wd) return EINA_FALSE;
950 return wd->fill_outside;
954 elm_icon_prescale_set(Evas_Object *obj, int size)
956 ELM_CHECK_WIDTYPE(obj, widtype);
957 Widget_Data *wd = elm_widget_data_get(obj);
960 _els_smart_icon_scale_size_set(wd->img, size);
964 elm_icon_prescale_get(const Evas_Object *obj)
966 ELM_CHECK_WIDTYPE(obj, widtype) 0;
967 Widget_Data *wd = elm_widget_data_get(obj);
970 return _els_smart_icon_scale_size_get(wd->img);
974 elm_icon_object_get(Evas_Object *obj)
976 ELM_CHECK_WIDTYPE(obj, widtype) 0;
977 Widget_Data *wd = elm_widget_data_get(obj);
979 if (!wd) return NULL;
980 return _els_smart_icon_object_get(wd->img);
984 elm_icon_preload_set(Evas_Object *obj, Eina_Bool disable)
986 ELM_CHECK_WIDTYPE(obj, widtype);
987 Widget_Data *wd = elm_widget_data_get(obj);
990 _els_smart_icon_preload_set(wd->img, disable);