1 #include <Elementary.h>
7 #define NON_EXISTING (void *)-1
8 static const char *icon_theme = NULL;
11 typedef struct _Widget_Data Widget_Data;
17 Elm_Icon_Lookup_Order lookup_order;
19 #ifdef HAVE_ELEMENTARY_ETHUMB
28 Ecore_Event_Handler *eeh;
30 Ethumb_Thumb_Format format;
32 Ethumb_Client_Async *request;
46 Eina_Bool scale_up : 1;
47 Eina_Bool scale_down : 1;
49 Eina_Bool fill_outside : 1;
50 Eina_Bool no_scale : 1;
52 /* for animation feature */
61 #ifdef HAVE_ELEMENTARY_ETHUMB
62 static Eina_List *_elm_icon_retry = NULL;
63 static int _icon_pending_request = 0;
66 static const char *widtype = NULL;
67 static void _del_hook(Evas_Object *obj);
68 static void _theme_hook(Evas_Object *obj);
69 static void _sizing_eval(Evas_Object *obj);
70 static void _mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
72 static Eina_Bool _icon_standard_set(Widget_Data *wd, Evas_Object *obj, const char *name);
73 static Eina_Bool _icon_freedesktop_set(Widget_Data *wd, Evas_Object *obj, const char *name, int size);
75 static const char SIG_CLICKED[] = "clicked";
77 static const Evas_Smart_Cb_Description _signals[] = {
83 //FIXME: move this code to ecore
86 _path_is_absolute(const char *path)
88 //TODO: Check if this works with all absolute paths in windows
89 return ((isalpha (*path)) && (*(path + 1) == ':') && ((*(path + 2) == '\\') || (*(path + 2) == '/')));
93 _path_is_absolute(const char *path)
95 return (*path == '/');
100 _icon_size_min_get(Evas_Object *icon)
103 _els_smart_icon_size_get(icon, &size, NULL);
104 return (size < 16) ? 16 : size;
107 #ifdef HAVE_ELEMENTARY_ETHUMB
109 _icon_thumb_stop(Widget_Data *wd, void *ethumbd)
111 if (wd->thumb.request)
113 ethumb_client_thumb_async_cancel(ethumbd, wd->thumb.request);
114 wd->thumb.request = NULL;
115 _icon_pending_request--;
120 _elm_icon_retry = eina_list_remove(_elm_icon_retry, wd);
121 wd->thumb.retry = EINA_FALSE;
126 _icon_thumb_display(Widget_Data *wd)
128 Eina_Bool ret = EINA_FALSE;
130 if (wd->thumb.format == ETHUMB_THUMB_EET)
132 static const char *extensions[] = {
133 ".avi", ".mp4", ".ogv", ".mov", ".mpg", ".wmv", NULL
135 const char **ext, *ptr;
137 Eina_Bool video = EINA_FALSE;
139 prefix_size = eina_stringshare_strlen(wd->thumb.file.path) - 4;
140 if (prefix_size >= 0)
142 ptr = wd->thumb.file.path + prefix_size;
143 for (ext = extensions; *ext; ++ext)
144 if (!strcasecmp(ptr, *ext))
152 ret = _els_smart_icon_file_edje_set(wd->img, wd->thumb.thumb.path, wd->thumb.thumb.key);
156 ret = _els_smart_icon_file_key_set(wd->img, wd->thumb.thumb.path, wd->thumb.thumb.key);
162 _icon_thumb_retry(Widget_Data *wd)
164 return _icon_thumb_display(wd);
168 _icon_thumb_cleanup(Ethumb_Client *ethumbd)
173 EINA_LIST_FOREACH_SAFE(_elm_icon_retry, l, ll, wd)
174 if (_icon_thumb_retry(wd))
176 _elm_icon_retry = eina_list_remove_list(_elm_icon_retry, l);
177 wd->thumb.retry = EINA_FALSE;
180 if (_icon_pending_request == 0)
181 EINA_LIST_FREE(_elm_icon_retry, wd)
182 _icon_thumb_stop(wd, ethumbd);
186 _icon_thumb_finish(Widget_Data *wd, Ethumb_Client *ethumbd)
188 const char *file = NULL, *group = NULL;
191 _els_smart_icon_file_get(wd->img, &file, &group);
192 file = eina_stringshare_ref(file);
193 group = eina_stringshare_ref(group);
195 ret = _icon_thumb_display(wd);
201 if (!wd->thumb.retry)
203 _elm_icon_retry = eina_list_append(_elm_icon_retry, wd);
204 wd->thumb.retry = EINA_TRUE;
207 /* Back to previous image */
208 if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
209 _els_smart_icon_file_edje_set(wd->img, file, group);
211 _els_smart_icon_file_key_set(wd->img, file, group);
214 _icon_thumb_cleanup(ethumbd);
216 eina_stringshare_del(file);
217 eina_stringshare_del(group);
221 _icon_thumb_done(Ethumb_Client *client, const char *thumb_path, const char *thumb_key, void *data)
223 Widget_Data *wd = data;
225 assert(wd->thumb.request);
227 _icon_pending_request--;
228 wd->thumb.request = NULL;
230 eina_stringshare_replace(&wd->thumb.thumb.path, thumb_path);
231 eina_stringshare_replace(&wd->thumb.thumb.key, thumb_key);
232 wd->thumb.format = ethumb_client_format_get(client);
234 _icon_thumb_finish(wd, client);
238 _icon_thumb_error(Ethumb_Client *client, void *data)
240 Widget_Data *wd = data;
242 assert(wd->thumb.request);
244 _icon_pending_request--;
245 wd->thumb.request = NULL;
247 ERR("could not generate thumbnail for %s (key: %s)", wd->thumb.file.path, wd->thumb.file.key);
248 _icon_thumb_cleanup(client);
252 _icon_thumb_apply(Widget_Data *wd)
254 Ethumb_Client *ethumbd;
256 ethumbd = elm_thumb_ethumb_client_get();
258 _icon_thumb_stop(wd, ethumbd);
260 if (!wd->thumb.file.path) return ;
262 _icon_pending_request++;
263 if (!ethumb_client_file_set(ethumbd, wd->thumb.file.path, wd->thumb.file.key)) return ;
264 ethumb_client_size_set(ethumbd, _icon_size_min_get(wd->img), _icon_size_min_get(wd->img));
265 wd->thumb.request = ethumb_client_thumb_async_get(ethumbd, _icon_thumb_done, _icon_thumb_error, wd);
269 _icon_thumb_apply_cb(void *data, int type __UNUSED__, void *ev __UNUSED__)
271 Widget_Data *wd = data;
273 _icon_thumb_apply(wd);
274 return ECORE_CALLBACK_RENEW;
279 _del_hook(Evas_Object *obj)
281 Widget_Data *wd = elm_widget_data_get(obj);
282 #ifdef HAVE_ELEMENTARY_ETHUMB
283 Ethumb_Client *ethumbd;
287 if (wd->stdicon) eina_stringshare_del(wd->stdicon);
289 #ifdef HAVE_ELEMENTARY_ETHUMB
290 ethumbd = elm_thumb_ethumb_client_get();
291 _icon_thumb_stop(wd, ethumbd);
293 eina_stringshare_del(wd->thumb.file.path);
294 eina_stringshare_del(wd->thumb.file.key);
295 eina_stringshare_del(wd->thumb.thumb.path);
296 eina_stringshare_del(wd->thumb.thumb.key);
299 ecore_event_handler_del(wd->thumb.eeh);
303 ecore_timer_del(wd->timer);
308 _theme_hook(Evas_Object *obj)
310 Widget_Data *wd = elm_widget_data_get(obj);
313 _elm_theme_object_icon_set(obj, wd->img, wd->stdicon, elm_widget_style_get(obj));
318 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
320 Widget_Data *wd = elm_widget_data_get(obj);
322 Evas_Object *icon_edje;
323 icon_edje = _els_smart_icon_edje_get(wd->img);
324 if (!icon_edje) return;
325 edje_object_signal_emit(icon_edje, emission, source);
329 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
331 Widget_Data *wd = elm_widget_data_get(obj);
333 Evas_Object *icon_edje;
334 icon_edje = _els_smart_icon_edje_get(wd->img);
335 if (!icon_edje) return;
336 edje_object_signal_callback_add(icon_edje, emission, source, func_cb, data);
340 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
342 Widget_Data *wd = elm_widget_data_get(obj);
344 Evas_Object *icon_edje;
345 icon_edje = _els_smart_icon_edje_get(wd->img);
346 if (!icon_edje) return;
347 edje_object_signal_callback_del_full(icon_edje, emission, source, func_cb,
352 _sizing_eval(Evas_Object *obj)
354 Widget_Data *wd = elm_widget_data_get(obj);
356 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
360 _els_smart_icon_size_get(wd->img, &w, &h);
362 if (wd->freedesktop.use && wd->stdicon)
365 /* This icon has been set to a freedesktop icon, and the requested
366 appears to have a different size than the requested size, so try to
367 request another, higher resolution, icon.
368 FIXME: Find a better heuristic to determine if there should be
369 an icon with a different resolution. */
370 size = ((w / 16) + 1) * 16;
371 _icon_freedesktop_set(wd, obj, wd->stdicon, size);
374 _els_smart_icon_scale_up_set(wd->img, wd->scale_up);
375 _els_smart_icon_scale_down_set(wd->img, wd->scale_down);
376 _els_smart_icon_smooth_scale_set(wd->img, wd->smooth);
377 _els_smart_icon_fill_inside_set(wd->img, !(wd->fill_outside));
378 if (wd->no_scale) _els_smart_icon_scale_set(wd->img, 1.0);
381 _els_smart_icon_scale_set(wd->img, elm_widget_scale_get(obj) *
383 _els_smart_icon_size_get(wd->img, &w, &h);
395 evas_object_size_hint_min_set(obj, minw, minh);
396 evas_object_size_hint_max_set(obj, maxw, maxh);
401 _mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
403 Evas_Event_Mouse_Up *ev = event_info;
404 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
405 evas_object_smart_callback_call(data, SIG_CLICKED, event_info);
409 _elm_icon_animate_cb(void *data)
411 Widget_Data *wd = data;
412 Evas_Object *img_obj;
414 if (!wd) return ECORE_CALLBACK_CANCEL;
415 if (!wd->anim) return ECORE_CALLBACK_CANCEL;
417 img_obj = _els_smart_icon_object_get(wd->img);
419 if (wd->cur_frame > wd->frame_count)
420 wd->cur_frame = wd->cur_frame % wd->frame_count;
421 evas_object_image_animated_frame_set(img_obj, wd->cur_frame);
423 wd->duration = evas_object_image_animated_frame_duration_get(img_obj, wd->cur_frame, 0);
425 if (wd->duration > 0)
426 ecore_timer_interval_set(wd->timer, wd->duration);
427 return ECORE_CALLBACK_RENEW;
431 _icon_standard_set(Widget_Data *wd, Evas_Object *obj, const char *name)
433 if (_elm_theme_object_icon_set(obj, wd->img, name, "default"))
436 /* TODO: elm_unneed_efreet() */
437 wd->freedesktop.use = EINA_FALSE;
446 _icon_file_set(Widget_Data *wd, Evas_Object *obj, const char *path)
448 _icon_file_set(Widget_Data *wd __UNUSED__, Evas_Object *obj, const char *path)
451 if (elm_icon_file_set(obj, path, NULL))
454 /* TODO: elm_unneed_efreet() */
455 wd->freedesktop.use = EINA_FALSE;
464 _icon_freedesktop_set(Widget_Data *wd, Evas_Object *obj, const char *name, int size)
466 _icon_freedesktop_set(Widget_Data *wd __UNUSED__, Evas_Object *obj __UNUSED__, const char *name __UNUSED__, int size __UNUSED__)
473 if (icon_theme == NON_EXISTING) return EINA_FALSE;
476 Efreet_Icon_Theme *theme;
477 /* TODO: Listen for EFREET_EVENT_ICON_CACHE_UPDATE */
478 theme = efreet_icon_theme_find(getenv("E_ICON_THEME"));
482 static const char *themes[] = {
483 "gnome", "Human", "oxygen", "hicolor", NULL
485 for (itr = themes; *itr; itr++)
487 theme = efreet_icon_theme_find(*itr);
494 icon_theme = NON_EXISTING;
498 icon_theme = eina_stringshare_add(theme->name.internal);
500 path = efreet_icon_path_find(icon_theme, name, size);
501 wd->freedesktop.use = !!path;
502 if (wd->freedesktop.use)
504 wd->freedesktop.requested_size = size;
505 elm_icon_file_set(obj, path, NULL);
513 _elm_icon_standard_set(Widget_Data *wd, Evas_Object *obj, const char *name, Eina_Bool *fdo)
518 /* try locating the icon using the specified lookup order */
519 switch (wd->lookup_order)
521 case ELM_ICON_LOOKUP_FDO:
522 ret = _icon_freedesktop_set(wd, obj, name, _icon_size_min_get(wd->img));
523 if (ret && fdo) *fdo = EINA_TRUE;
525 case ELM_ICON_LOOKUP_THEME:
526 ret = _icon_standard_set(wd, obj, name);
528 case ELM_ICON_LOOKUP_THEME_FDO:
529 ret = _icon_standard_set(wd, obj, name);
532 ret = _icon_freedesktop_set(wd, obj, name, _icon_size_min_get(wd->img));
533 if (ret && fdo) *fdo = EINA_TRUE;
536 case ELM_ICON_LOOKUP_FDO_THEME:
538 ret = _icon_freedesktop_set(wd, obj, name, _icon_size_min_get(wd->img));
540 ret = _icon_standard_set(wd, obj, name);
548 eina_stringshare_replace(&wd->stdicon, name);
549 if (!wd->in_eval) _sizing_eval(obj);
553 if (_path_is_absolute(name))
554 return _icon_file_set(wd, obj, name);
556 /* if that fails, see if icon name is in the format size/name. if so,
557 try locating a fallback without the size specification */
558 if (!(tmp = strchr(name, '/'))) return EINA_FALSE;
560 if (*tmp) return elm_icon_standard_set(obj, tmp);
566 _elm_icon_standard_resize(void *data,
569 void *event_info __UNUSED__)
571 Widget_Data *wd = data;
572 const char *refup = eina_stringshare_ref(wd->stdicon);
573 Eina_Bool fdo = EINA_FALSE;
575 if (!_elm_icon_standard_set(wd, obj, wd->stdicon, &fdo) || (!fdo))
576 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
577 _elm_icon_standard_resize, wd);
578 eina_stringshare_del(refup);
581 #ifdef HAVE_ELEMENTARY_ETHUMB
583 _elm_icon_thumb_resize(void *data,
586 void *event_info __UNUSED__)
588 Widget_Data *wd = data;
590 if (wd->thumb.file.path)
591 elm_icon_thumb_set(obj, wd->thumb.file.path, wd->thumb.file.key);
596 elm_icon_add(Evas_Object *parent)
602 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
604 ELM_SET_WIDTYPE(widtype, "icon");
605 elm_widget_type_set(obj, "icon");
606 elm_widget_can_focus_set(obj, EINA_FALSE);
607 elm_widget_sub_object_add(parent, obj);
608 elm_widget_data_set(obj, wd);
609 elm_widget_del_hook_set(obj, _del_hook);
610 elm_widget_theme_hook_set(obj, _theme_hook);
611 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
612 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
613 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
615 wd->lookup_order = ELM_ICON_LOOKUP_THEME_FDO;
616 wd->img = _els_smart_icon_add(e);
617 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
619 evas_object_repeat_events_set(wd->img, EINA_TRUE);
620 elm_widget_resize_object_set(obj, wd->img);
622 evas_object_smart_callbacks_descriptions_set(obj, _signals);
624 #ifdef HAVE_ELEMENTARY_ETHUMB
625 wd->thumb.request = NULL;
628 wd->smooth = EINA_TRUE;
629 wd->scale_up = EINA_TRUE;
630 wd->scale_down = EINA_TRUE;
637 elm_icon_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key)
639 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
640 Widget_Data *wd = elm_widget_data_get(obj);
643 if (!wd) return EINA_FALSE;
644 EINA_SAFETY_ON_NULL_RETURN_VAL(img, EINA_FALSE);
645 EINA_SAFETY_ON_TRUE_RETURN_VAL(!size, EINA_FALSE);
646 eina_stringshare_del(wd->stdicon);
648 ret = _els_smart_icon_memfile_set(wd->img, img, size, format, key);
649 if (!wd->in_eval) _sizing_eval(obj);
654 elm_icon_file_set(Evas_Object *obj, const char *file, const char *group)
656 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
657 Widget_Data *wd = elm_widget_data_get(obj);
660 if (!wd) return EINA_FALSE;
661 EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE);
664 if (!wd->freedesktop.use)
666 if (wd->stdicon) eina_stringshare_del(wd->stdicon);
670 if (eina_str_has_extension(file, ".edj"))
671 ret = _els_smart_icon_file_edje_set(wd->img, file, group);
673 ret = _els_smart_icon_file_key_set(wd->img, file, group);
674 if (!wd->in_eval) _sizing_eval(obj);
679 elm_icon_file_get(const Evas_Object *obj, const char **file, const char **group)
681 ELM_CHECK_WIDTYPE(obj, widtype);
682 Widget_Data *wd = elm_widget_data_get(obj);
684 _els_smart_icon_file_get(wd->img, file, group);
688 elm_icon_thumb_set(Evas_Object *obj, const char *file, const char *group)
690 ELM_CHECK_WIDTYPE(obj, widtype);
691 Widget_Data *wd = elm_widget_data_get(obj);
694 #ifdef HAVE_ELEMENTARY_ETHUMB
695 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
696 _elm_icon_standard_resize, wd);
697 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
698 _elm_icon_thumb_resize, wd);
700 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
701 _elm_icon_thumb_resize, wd);
703 eina_stringshare_replace(&wd->thumb.file.path, file);
704 eina_stringshare_replace(&wd->thumb.file.key, group);
706 if (elm_thumb_ethumb_client_connected_get())
708 _icon_thumb_apply(wd);
714 wd->thumb.eeh = ecore_event_handler_add(ELM_ECORE_EVENT_ETHUMB_CONNECT, _icon_thumb_apply_cb, wd);
725 elm_icon_animated_available_get(const Evas_Object *obj)
727 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
728 Evas_Object *img_obj ;
729 Widget_Data *wd = elm_widget_data_get(obj);
730 if (!wd) return EINA_FALSE;
732 img_obj = _els_smart_icon_object_get(wd->img);
734 return evas_object_image_animated_get(img_obj);
738 elm_icon_animated_set(Evas_Object *obj, Eina_Bool anim)
740 ELM_CHECK_WIDTYPE(obj, widtype);
741 Evas_Object *img_obj ;
742 Widget_Data *wd = elm_widget_data_get(obj);
744 if (wd->anim == anim) return;
746 img_obj = _els_smart_icon_object_get(wd->img);
747 if (!evas_object_image_animated_get(img_obj)) return;
750 wd->frame_count = evas_object_image_animated_frame_count_get(img_obj);
752 wd->duration = evas_object_image_animated_frame_duration_get(img_obj, wd->cur_frame, 0);
753 evas_object_image_animated_frame_set(img_obj, wd->cur_frame);
757 wd->frame_count = -1;
766 elm_icon_animated_get(const Evas_Object *obj)
768 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
769 Widget_Data *wd = elm_widget_data_get(obj);
770 if (!wd) return EINA_FALSE;
775 elm_icon_animated_play_set(Evas_Object *obj, Eina_Bool play)
777 ELM_CHECK_WIDTYPE(obj, widtype);
778 Widget_Data *wd = elm_widget_data_get(obj);
780 if (!wd->anim) return;
781 if (wd->play == play) return;
785 wd->timer = ecore_timer_add(wd->duration, _elm_icon_animate_cb, wd);
791 ecore_timer_del(wd->timer);
800 elm_icon_animated_play_get(const Evas_Object *obj)
802 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
803 Widget_Data *wd = elm_widget_data_get(obj);
804 if (!wd) return EINA_FALSE;
809 elm_icon_standard_set(Evas_Object *obj, const char *name)
811 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
812 Widget_Data *wd = elm_widget_data_get(obj);
813 Eina_Bool fdo = EINA_FALSE;
816 if ((!wd) || (!name)) return EINA_FALSE;
818 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
819 _elm_icon_standard_resize, wd);
821 ret = _elm_icon_standard_set(wd, obj, name, &fdo);
824 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
825 _elm_icon_standard_resize, wd);
831 elm_icon_standard_get(const Evas_Object *obj)
833 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
834 Widget_Data *wd = elm_widget_data_get(obj);
835 if (!wd) return NULL;
840 elm_icon_order_lookup_set(Evas_Object *obj, Elm_Icon_Lookup_Order order)
842 ELM_CHECK_WIDTYPE(obj, widtype);
843 Widget_Data *wd = elm_widget_data_get(obj);
844 if (wd) wd->lookup_order = order;
847 EAPI Elm_Icon_Lookup_Order
848 elm_icon_order_lookup_get(const Evas_Object *obj)
850 ELM_CHECK_WIDTYPE(obj, widtype) ELM_ICON_LOOKUP_THEME_FDO;
851 Widget_Data *wd = elm_widget_data_get(obj);
852 if (!wd) return ELM_ICON_LOOKUP_THEME_FDO;
853 return wd->lookup_order;
857 elm_icon_smooth_set(Evas_Object *obj, Eina_Bool smooth)
859 ELM_CHECK_WIDTYPE(obj, widtype);
860 Widget_Data *wd = elm_widget_data_get(obj);
864 if (!wd->in_eval) _sizing_eval(obj);
868 elm_icon_smooth_get(const Evas_Object *obj)
870 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
871 Widget_Data *wd = elm_widget_data_get(obj);
873 if (!wd) return EINA_FALSE;
878 elm_icon_no_scale_set(Evas_Object *obj, Eina_Bool no_scale)
880 ELM_CHECK_WIDTYPE(obj, widtype);
881 Widget_Data *wd = elm_widget_data_get(obj);
884 wd->no_scale = no_scale;
885 if (!wd->in_eval) _sizing_eval(obj);
889 elm_icon_no_scale_get(const Evas_Object *obj)
891 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
892 Widget_Data *wd = elm_widget_data_get(obj);
893 if (!wd) return EINA_FALSE;
898 elm_icon_resizable_set(Evas_Object *obj, Eina_Bool size_up, Eina_Bool size_down)
900 ELM_CHECK_WIDTYPE(obj, widtype);
901 Widget_Data *wd = elm_widget_data_get(obj);
904 wd->scale_up = size_up;
905 wd->scale_down = size_down;
906 if (!wd->in_eval) _sizing_eval(obj);
910 elm_icon_resizable_get(const Evas_Object *obj, Eina_Bool *size_up, Eina_Bool *size_down)
912 ELM_CHECK_WIDTYPE(obj, widtype);
913 Widget_Data *wd = elm_widget_data_get(obj);
915 if (size_up) *size_up = wd->scale_up;
916 if (size_down) *size_down = wd->scale_down;
920 elm_icon_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside)
922 ELM_CHECK_WIDTYPE(obj, widtype);
923 Widget_Data *wd = elm_widget_data_get(obj);
926 wd->fill_outside = fill_outside;
927 if (!wd->in_eval) _sizing_eval(obj);
931 elm_icon_size_get(const Evas_Object *obj, int *w, int *h)
933 ELM_CHECK_WIDTYPE(obj, widtype);
934 Widget_Data *wd = elm_widget_data_get(obj);
937 _els_smart_icon_size_get(wd->img, w, h);
941 elm_icon_fill_outside_get(const Evas_Object *obj)
943 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
944 Widget_Data *wd = elm_widget_data_get(obj);
946 if (!wd) return EINA_FALSE;
947 return wd->fill_outside;
951 elm_icon_prescale_set(Evas_Object *obj, int size)
953 ELM_CHECK_WIDTYPE(obj, widtype);
954 Widget_Data *wd = elm_widget_data_get(obj);
957 _els_smart_icon_scale_size_set(wd->img, size);
961 elm_icon_prescale_get(const Evas_Object *obj)
963 ELM_CHECK_WIDTYPE(obj, widtype) 0;
964 Widget_Data *wd = elm_widget_data_get(obj);
967 return _els_smart_icon_scale_size_get(wd->img);
971 elm_icon_object_get(Evas_Object *obj)
973 ELM_CHECK_WIDTYPE(obj, widtype) 0;
974 Widget_Data *wd = elm_widget_data_get(obj);
976 if (!wd) return NULL;
977 return _els_smart_icon_object_get(wd->img);
981 elm_icon_preload_disabled_set(Evas_Object *obj, Eina_Bool disabled)
983 ELM_CHECK_WIDTYPE(obj, widtype);
984 Widget_Data *wd = elm_widget_data_get(obj);
987 _els_smart_icon_preload_set(wd->img, !!disabled);
991 elm_icon_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed)
993 ELM_CHECK_WIDTYPE(obj, widtype);
994 Widget_Data *wd = elm_widget_data_get(obj);
996 _els_smart_icon_aspect_fixed_set(wd->img, fixed);
1000 elm_icon_aspect_fixed_get(const Evas_Object *obj)
1002 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1003 Widget_Data *wd = elm_widget_data_get(obj);
1004 if (!wd) return EINA_FALSE;
1005 return _els_smart_icon_aspect_fixed_get(wd->img);