From d199c589042077a8f7a0436664c274b5808d497c Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 20 Jul 2012 07:52:53 +0000 Subject: [PATCH] finally kill off the last of the e_icon_object_set uses; this function was being abused in 100% of cases to do something other than the intended use of just setting an evas image into an e_icon. I've added e_icon_edje_object_set which is the edje version and will, hopefully, make things more clear and avoid confusion in the future e_widget_image now calls the proper e_icon functions and is far less likely to trigger a magic failure SVN revision: 74213 --- src/bin/e_icon.c | 33 +++++++++++++++++++++++++++++++-- src/bin/e_icon.h | 3 ++- src/bin/e_widget_image.c | 29 ++++++++--------------------- src/bin/e_widget_image.h | 1 - 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/bin/e_icon.c b/src/bin/e_icon.c index 19e3f4587..7fa926140 100644 --- a/src/bin/e_icon.c +++ b/src/bin/e_icon.c @@ -342,6 +342,35 @@ e_icon_file_key_set(Evas_Object *obj, const char *file, const char *key) return EINA_TRUE; } +EAPI void +e_icon_edje_object_set(Evas_Object *obj, Evas_Object *edje) +{ + E_Smart_Data *sd; + + 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); + sd->loading = 0; + if (sd->fdo) + { + eina_stringshare_del(sd->fdo); + sd->fdo = NULL; + } + + if (sd->timer) ecore_timer_del(sd->timer); + sd->timer = NULL; + sd->frame = 0; + sd->frame_count = 0; + sd->edje = EINA_TRUE; + sd->obj = edje; + + if (evas_object_visible_get(obj)) evas_object_show(sd->obj); + evas_object_smart_member_add(sd->obj, obj); + _e_icon_smart_reconfigure(sd); +} + EAPI Eina_Bool e_icon_file_edje_set(Evas_Object *obj, const char *file, const char *part) { @@ -435,8 +464,8 @@ e_icon_object_set(Evas_Object *obj, Evas_Object *o) if (evas_object_smart_smart_get(obj) != _e_smart) SMARTERR(); if (!(sd = evas_object_smart_data_get(obj))) return; str = evas_object_type_get(o); - if ((!str) || (strcmp(str, "edje") && strcmp(str, "image"))) - printf(EINA_COLOR_RED"******************\ntrying to set an image object of type '%s'! this is not what you want!\n******************\n"EINA_COLOR_RESET, str); + if ((!str) || strcmp(str, "image")) + CRI(EINA_COLOR_RED"******************\ntrying to set an image object of type '%s'! this is not what you want!\n******************\n"EINA_COLOR_RESET, str); if (sd->timer) ecore_timer_del(sd->timer); sd->timer = NULL; diff --git a/src/bin/e_icon.h b/src/bin/e_icon.h index 6e67ffae6..2104a8422 100644 --- a/src/bin/e_icon.h +++ b/src/bin/e_icon.h @@ -11,7 +11,8 @@ 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 void e_icon_edje_object_set(Evas_Object *obj, Evas_Object *edje); +EAPI void e_icon_object_set (Evas_Object *obj, Evas_Object *o) EINA_DEPRECATED; EAPI const char *e_icon_file_get (const Evas_Object *obj); EAPI void e_icon_smooth_scale_set (Evas_Object *obj, Eina_Bool smooth); EAPI Eina_Bool e_icon_smooth_scale_get (const Evas_Object *obj); diff --git a/src/bin/e_widget_image.c b/src/bin/e_widget_image.c index bb57103b4..e626cd077 100644 --- a/src/bin/e_widget_image.c +++ b/src/bin/e_widget_image.c @@ -26,7 +26,7 @@ e_widget_image_add_from_object(Evas *evas, Evas_Object *object, int minw, int mi evas_object_show(object); o = e_icon_add(evas); e_icon_fill_inside_set(o, 1); - e_icon_object_set(o, object); + e_icon_edje_object_set(o, object); wd->img = o; e_widget_data_set(obj, wd); e_widget_can_focus_set(obj, 0); @@ -54,9 +54,13 @@ e_widget_image_add_from_file(Evas *evas, const char *file, int minw, int minh) o = e_icon_add(evas); e_icon_fill_inside_set(o, 1); - o2 = evas_object_image_add(evas); - evas_object_image_file_set(o2, file, NULL); - e_icon_object_set(o, o2); + if (!e_icon_file_set(o, file)) + { + evas_object_del(o); + free(wd); + evas_object_del(obj); + return NULL; + } wd->img = o; evas_object_show(o); @@ -99,23 +103,6 @@ e_widget_image_file_key_set(Evas_Object *obj, const char *file, const char *key) evas_object_show(wd->img); } -EAPI void -e_widget_image_object_set(Evas_Object *obj, Evas_Object *o) -{ - E_Widget_Data *wd; - int mw, mh; - - wd = e_widget_data_get(obj); - e_icon_object_set(wd->img, o); - edje_object_size_min_get(o, &mw, &mh); - if (wd->minw || wd->minh) - e_widget_size_min_set(obj, wd->minw, wd->minh); - else - e_widget_size_min_set(obj, mw, mh); - evas_object_show(wd->img); -} - - static void _e_wid_del_hook(Evas_Object *obj) { diff --git a/src/bin/e_widget_image.h b/src/bin/e_widget_image.h index 2366b2626..04b1c535a 100644 --- a/src/bin/e_widget_image.h +++ b/src/bin/e_widget_image.h @@ -8,7 +8,6 @@ EAPI Evas_Object *e_widget_image_add_from_file(Evas *evas, const char *file, EAPI void e_widget_image_edje_set(Evas_Object *obj, const char *file, const char *part); EAPI void e_widget_image_file_set(Evas_Object *obj, const char *file); EAPI void e_widget_image_file_key_set(Evas_Object *obj, const char *file, const char *key); -EAPI void e_widget_image_object_set(Evas_Object *obj, Evas_Object *o); #endif #endif