[elm] Warn about deprecation of some icon calls
authorGustavo Lima Chaves <glima@profusion.mobi>
Mon, 28 May 2012 20:35:35 +0000 (20:35 +0000)
committerGustavo Lima Chaves <glima@profusion.mobi>
Mon, 28 May 2012 20:35:35 +0000 (20:35 +0000)
The ones just wrapping their image counterparts should die eventually.
The signal callbacks on icons will die, too, eventually.

SVN revision: 71468

src/lib/elm_icon.c
src/lib/elm_icon.h
src/lib/elm_image.c
src/lib/elm_priv.h
src/lib/elm_widget.c
src/lib/elm_widget_image.h

index 693926f..043111a 100644 (file)
@@ -45,9 +45,12 @@ struct _Elm_Icon_Smart_Data
    } freedesktop;
 #endif
 
-   int          in_eval;
+   int        in_eval;
 
-   Eina_Bool    is_video : 1;
+   /* WARNING: to be deprecated */
+   Eina_List *edje_signals;
+
+   Eina_Bool  is_video : 1;
 };
 
 #ifdef HAVE_ELEMENTARY_ETHUMB
@@ -420,7 +423,7 @@ _edje_signals_free(Elm_Icon_Smart_Data *sd)
 {
    Edje_Signal_Data *esd;
 
-   EINA_LIST_FREE (ELM_IMAGE_DATA(sd)->edje_signals, esd)
+   EINA_LIST_FREE (sd->edje_signals, esd)
      {
         eina_stringshare_del(esd->emission);
         eina_stringshare_del(esd->source);
@@ -698,10 +701,11 @@ _elm_icon_smart_del(Evas_Object *obj)
    ELM_WIDGET_CLASS(_elm_icon_parent_sc)->base.del(obj);
 }
 
-static void
-_elm_icon_smart_signal(Evas_Object *obj,
-                       const char *emission,
-                       const char *source)
+/* WARNING: to be deprecated */
+void
+_elm_icon_signal_emit(Evas_Object *obj,
+                      const char *emission,
+                      const char *source)
 {
    ELM_ICON_DATA_GET(obj, sd);
 
@@ -721,12 +725,13 @@ _edje_signal_callback(void *data,
    esd->func(esd->data, esd->obj, emission, source);
 }
 
-static void
-_elm_icon_smart_callback_add(Evas_Object *obj,
-                             const char *emission,
-                             const char *source,
-                             Edje_Signal_Cb func_cb,
-                             void *data)
+/* WARNING: to be deprecated */
+void
+_elm_icon_signal_callback_add(Evas_Object *obj,
+                              const char *emission,
+                              const char *source,
+                              Edje_Signal_Cb func_cb,
+                              void *data)
 {
    Edje_Signal_Data *esd;
 
@@ -742,18 +747,19 @@ _elm_icon_smart_callback_add(Evas_Object *obj,
    esd->emission = eina_stringshare_add(emission);
    esd->source = eina_stringshare_add(source);
    esd->data = data;
-   ELM_IMAGE_DATA(sd)->edje_signals =
-     eina_list_append(ELM_IMAGE_DATA(sd)->edje_signals, esd);
+   sd->edje_signals =
+     eina_list_append(sd->edje_signals, esd);
 
    edje_object_signal_callback_add
      (ELM_IMAGE_DATA(sd)->img, emission, source, _edje_signal_callback, esd);
 }
 
-static void *
-_elm_icon_smart_callback_del(Evas_Object *obj,
-                             const char *emission,
-                             const char *source,
-                             Edje_Signal_Cb func_cb)
+/* WARNING: to be deprecated */
+void *
+_elm_icon_signal_callback_del(Evas_Object *obj,
+                              const char *emission,
+                              const char *source,
+                              Edje_Signal_Cb func_cb)
 {
    Edje_Signal_Data *esd = NULL;
    void *data = NULL;
@@ -763,13 +769,12 @@ _elm_icon_smart_callback_del(Evas_Object *obj,
 
    if (!ELM_IMAGE_DATA(sd)->edje) return NULL;
 
-   EINA_LIST_FOREACH (ELM_IMAGE_DATA(sd)->edje_signals, l, esd)
+   EINA_LIST_FOREACH (sd->edje_signals, l, esd)
      {
         if ((esd->func == func_cb) && (!strcmp(esd->emission, emission)) &&
             (!strcmp(esd->source, source)))
           {
-             ELM_IMAGE_DATA(sd)->edje_signals =
-               eina_list_remove_list(ELM_IMAGE_DATA(sd)->edje_signals, l);
+             sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
              eina_stringshare_del(esd->emission);
              eina_stringshare_del(esd->source);
              data = esd->data;
@@ -794,10 +799,6 @@ _elm_icon_smart_set_user(Elm_Image_Smart_Class *sc)
 
    ELM_WIDGET_CLASS(sc)->theme = _elm_icon_smart_theme;
 
-   sc->callback_add = _elm_icon_smart_callback_add;
-   sc->callback_del = _elm_icon_smart_callback_del;
-   sc->signal = _elm_icon_smart_signal;
-
    sc->file_set = _elm_icon_smart_file_set;
    sc->memfile_set = _elm_icon_smart_memfile_set;
    sc->sizing_eval = _elm_icon_smart_sizing_eval;
@@ -898,7 +899,7 @@ elm_icon_animated_available_get(const Evas_Object *obj)
 {
    ELM_ICON_CHECK(obj) EINA_FALSE;
 
-   return evas_object_image_animated_get(elm_image_object_get(obj));
+   return elm_image_animated_available_get(obj);
 }
 
 EAPI void
index 665988c..ee11b1b 100644 (file)
  * This widget inherits from the @ref Image one, so that all the
  * functions acting on it also work for icon objects.
  *
- * Besides, its API is very similar to the one of its parent object,
- * so that similar calls exist here just wrapping their counterparts
- * on @ref Image.
+ * You should be using an icon, instead of an image, whenever one of
+ * the following apply:
+ * - you need a @b thumbnail version of an original image
+ * - you need freedesktop.org provided icon images
+ * - you need theme provided icon images (Edje groups)
+ *
+ * Various calls on the icon's API are marked as @b deprecated, as
+ * they just wrap the image counterpart functions. Use the ones we
+ * point you to, for each case of deprecation here, instead --
+ * eventually the deprecated ones will be discarded (next major
+ * release).
  *
  * Default images provided by Elementary's default theme are described
  * below.
  *                     (@since 1.1)
  * - @c "thumb,error" - elm_icon_thumb_set() has failed (@since 1.1)
  *
- * Supported elm_object common APIs.
- * @li @ref elm_object_signal_emit
- * @li @ref elm_object_signal_callback_add
- * @li @ref elm_object_signal_callback_del
+ * Elementary icon objects support the following API calls:
+ * @li elm_object_signal_emit()
+ * @li elm_object_signal_callback_add()
+ * @li elm_object_signal_callback_del()
+ * for emmiting and listening to signals on the object, when the
+ * internal image comes from an Edje object. This behavior was added
+ * unintentionally, though, and is @b deprecated. Expect it to be
+ * dropped on future releases.
  *
  * An example of usage for this API follows:
  * @li @ref tutorial_icon
@@ -137,6 +149,8 @@ EAPI Evas_Object          *elm_icon_add(Evas_Object *parent);
  *
  * @see elm_icon_file_get()
  *
+ * @deprecated Use elm_image_file_set() instead.
+ *
  * @ingroup Icon
  */
 EAPI Eina_Bool             elm_icon_file_set(Evas_Object *obj, const char *file, const char *group);
@@ -160,6 +174,8 @@ EAPI Eina_Bool             elm_icon_file_set(Evas_Object *obj, const char *file,
  * @note The icon image set by this function can be changed by
  * elm_icon_standard_set().
  *
+ * @deprecated Use elm_image_memfile_set() instead.
+ *
  * @ingroup Icon
  */
 EAPI Eina_Bool             elm_icon_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key);
@@ -173,6 +189,8 @@ EAPI Eina_Bool             elm_icon_memfile_set(Evas_Object *obj, const void *im
  *
  * @see elm_icon_file_set()
  *
+ * @deprecated Use elm_image_file_get() instead.
+ *
  * @ingroup Icon
  */
 EAPI void                  elm_icon_file_get(const Evas_Object *obj, const char **file, const char **group);
@@ -255,6 +273,8 @@ EAPI const char           *elm_icon_standard_get(const Evas_Object *obj);
  *
  * @see elm_icon_smooth_get()
  *
+ * @deprecated Use elm_image_smooth_set() instead.
+ *
  * @ingroup Icon
  */
 EAPI void                  elm_icon_smooth_set(Evas_Object *obj, Eina_Bool smooth);
@@ -267,6 +287,8 @@ EAPI void                  elm_icon_smooth_set(Evas_Object *obj, Eina_Bool smoot
  *
  * @see elm_icon_smooth_set()
  *
+ * @deprecated Use elm_image_smooth_get() instead.
+ *
  * @ingroup Icon
  */
 EAPI Eina_Bool             elm_icon_smooth_get(const Evas_Object *obj);
@@ -287,6 +309,8 @@ EAPI Eina_Bool             elm_icon_smooth_get(const Evas_Object *obj);
  * @see elm_icon_resizable_set()
  * @see elm_object_scale_set()
  *
+ * @deprecated Use elm_image_no_scale_set() instead.
+ *
  * @ingroup Icon
  */
 EAPI void                  elm_icon_no_scale_set(Evas_Object *obj, Eina_Bool no_scale);
@@ -299,6 +323,8 @@ EAPI void                  elm_icon_no_scale_set(Evas_Object *obj, Eina_Bool no_
  *
  * @see elm_icon_no_scale_set()
  *
+ * @deprecated Use elm_image_no_scale_get() instead.
+ *
  * @ingroup Icon
  */
 EAPI Eina_Bool             elm_icon_no_scale_get(const Evas_Object *obj);
@@ -318,6 +344,8 @@ EAPI Eina_Bool             elm_icon_no_scale_get(const Evas_Object *obj);
  *
  * @see elm_icon_resizable_get()
  *
+ * @deprecated Use elm_image_resizable_set() instead.
+ *
  * @ingroup Icon
  */
 EAPI void                  elm_icon_resizable_set(Evas_Object *obj, Eina_Bool size_up, Eina_Bool size_down);
@@ -331,6 +359,8 @@ EAPI void                  elm_icon_resizable_set(Evas_Object *obj, Eina_Bool si
  *
  * @see elm_icon_resizable_set()
  *
+ * @deprecated Use elm_image_resizable_get() instead.
+ *
  * @ingroup Icon
  */
 EAPI void                  elm_icon_resizable_get(const Evas_Object *obj, Eina_Bool *size_up, Eina_Bool *size_down);
@@ -342,6 +372,8 @@ EAPI void                  elm_icon_resizable_get(const Evas_Object *obj, Eina_B
  * @param w A pointer to store the width in
  * @param h A pointer to store the height in
  *
+ * @deprecated Use elm_image_object_size_get() instead.
+ *
  * @ingroup Icon
  */
 EAPI void                  elm_icon_size_get(const Evas_Object *obj, int *w, int *h);
@@ -376,10 +408,13 @@ EAPI void                  elm_icon_fill_outside_set(Evas_Object *obj, Eina_Bool
  * Get if the object is filled outside.
  *
  * @param obj The icon object
- * @return @c EINA_TRUE if the object is filled outside, @c EINA_FALSE otherwise.
+ * @return @c EINA_TRUE if the object is filled outside, @c EINA_FALSE
+ *         otherwise.
  *
  * @see elm_icon_fill_outside_set()
  *
+ * @deprecated Use elm_image_fill_outside_get() instead.
+ *
  * @ingroup Icon
  */
 EAPI Eina_Bool             elm_icon_fill_outside_get(const Evas_Object *obj);
@@ -404,6 +439,8 @@ EAPI Eina_Bool             elm_icon_fill_outside_get(const Evas_Object *obj);
  * @see elm_icon_prescale_get()
  * @see elm_bg_load_size_set()
  *
+ * @deprecated Use elm_image_prescale_set() instead.
+ *
  * @ingroup Icon
  */
 EAPI void                  elm_icon_prescale_set(Evas_Object *obj, int size);
@@ -416,6 +453,8 @@ EAPI void                  elm_icon_prescale_set(Evas_Object *obj, int size);
  *
  * @see elm_icon_prescale_set()
  *
+ * @deprecated Use elm_image_prescale_get() instead.
+ *
  * @ingroup Icon
  */
 EAPI int                   elm_icon_prescale_get(const Evas_Object *obj);
@@ -426,6 +465,8 @@ EAPI int                   elm_icon_prescale_get(const Evas_Object *obj);
  * @param obj The icon object
  * @return The internal icon object
  *
+ * @deprecated Use elm_image_object_get() instead.
+ *
  * @ingroup Icon
  */
 EAPI Evas_Object          *elm_icon_object_get(Evas_Object *obj);
@@ -464,6 +505,9 @@ EAPI Elm_Icon_Lookup_Order elm_icon_order_lookup_get(const Evas_Object *obj);
  * @param obj The icon object
  * @param disabled If EINA_TRUE, preloading will be disabled
  * @ingroup Icon
+ *
+ * @deprecated Use elm_image_preload_disabled_set() instead.
+ *
  */
 EAPI void                  elm_icon_preload_disabled_set(Evas_Object *obj, Eina_Bool disabled);
 
@@ -478,6 +522,9 @@ EAPI void                  elm_icon_preload_disabled_set(Evas_Object *obj, Eina_
  * supports gif animation. If the return value is EINA_FALSE, other
  * elm_icon_animated_xxx APIs won't work.
  * @ingroup Icon
+ *
+ * @deprecated Use elm_image_animated_available_get() instead.
+ *
  */
 EAPI Eina_Bool             elm_icon_animated_available_get(const Evas_Object *obj);
 
@@ -494,6 +541,9 @@ EAPI Eina_Bool             elm_icon_animated_available_get(const Evas_Object *ob
  * on the icon.
  * Set it to EINA_TRUE when the icon needs to be animated.
  * @ingroup Icon
+ *
+ * @deprecated Use elm_image_animated_set() instead.
+ *
  */
 EAPI void                  elm_icon_animated_set(Evas_Object *obj, Eina_Bool animated);
 
@@ -504,6 +554,9 @@ EAPI void                  elm_icon_animated_set(Evas_Object *obj, Eina_Bool ani
  * @return The animation mode of the icon object
  * @see elm_icon_animated_set
  * @ingroup Icon
+ *
+ * @deprecated Use elm_image_animated_get() instead.
+ *
  */
 EAPI Eina_Bool             elm_icon_animated_get(const Evas_Object *obj);
 
@@ -526,6 +579,9 @@ EAPI Eina_Bool             elm_icon_animated_get(const Evas_Object *obj);
  * 3. If elm icon was playing, set play to EINA_FALSE.
  *    Then animation will be stopped and vice versa
  * @ingroup Icon
+ *
+ * @deprecated Use elm_image_animated_play_set() instead.
+ *
  */
 EAPI void                  elm_icon_animated_play_set(Evas_Object *obj, Eina_Bool play);
 
@@ -537,6 +593,9 @@ EAPI void                  elm_icon_animated_play_set(Evas_Object *obj, Eina_Boo
  *
  * @see elm_icon_animated_play_get
  * @ingroup Icon
+ *
+ * @deprecated Use elm_image_animated_play_get() instead.
+ *
  */
 EAPI Eina_Bool             elm_icon_animated_play_get(const Evas_Object *obj);
 
@@ -556,8 +615,11 @@ EAPI Eina_Bool             elm_icon_animated_play_get(const Evas_Object *obj);
  * @see elm_icon_fill_outside_set()
  *
  * @ingroup Icon
+ *
+ * @deprecated Use elm_image_aspect_fixed_set() instead.
+ *
  */
-EAPI void             elm_icon_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed);
+EAPI void                  elm_icon_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed);
 
 /**
  * Get if the object retains the original aspect ratio.
@@ -566,9 +628,11 @@ EAPI void             elm_icon_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixe
  * @return @c EINA_TRUE if the object keeps the original aspect, @c EINA_FALSE
  * otherwise.
  *
+ * @deprecated Use elm_image_aspect_fixed_get() instead.
+ *
  * @ingroup Icon
  */
-EAPI Eina_Bool        elm_icon_aspect_fixed_get(const Evas_Object *obj);
+EAPI Eina_Bool             elm_icon_aspect_fixed_get(const Evas_Object *obj);
 
 /**
  * @}
index cb160c2..fb9aaee 100644 (file)
@@ -989,42 +989,6 @@ _elm_image_smart_aspect_fixed_get(const Evas_Object *obj)
 }
 
 static void
-_unimplemented_smart_callback_add(Evas_Object *obj,
-                                  const char *emission __UNUSED__,
-                                  const char *source __UNUSED__,
-                                  Edje_Signal_Cb func __UNUSED__,
-                                  void *data __UNUSED__)
-{
-   WRN("The %s widget does not implement the \"callback_add()\" function.",
-       elm_widget_type_get(obj));
-
-   return;
-}
-
-static void *
-_unimplemented_smart_callback_del(Evas_Object *obj,
-                                  const char *emission __UNUSED__,
-                                  const char *source __UNUSED__,
-                                  Edje_Signal_Cb func __UNUSED__)
-{
-   WRN("The %s widget does not implement the \"callback_del()\" function.",
-       elm_widget_type_get(obj));
-
-   return NULL;
-}
-
-static void
-_unimplemented_smart_signal(Evas_Object *obj,
-                            const char *emission __UNUSED__,
-                            const char *source __UNUSED__)
-{
-   WRN("The %s widunadd does not implement the \"signal()\" function.",
-       elm_widget_type_get(obj));
-
-   return;
-}
-
-static void
 _elm_image_smart_set_user(Elm_Image_Smart_Class *sc)
 {
    ELM_WIDGET_CLASS(sc)->base.add = _elm_image_smart_add;
@@ -1064,10 +1028,6 @@ _elm_image_smart_set_user(Elm_Image_Smart_Class *sc)
    sc->sizing_eval = _elm_image_smart_sizing_eval;
    sc->smooth_scale_get = _elm_image_smart_smooth_scale_get;
    sc->smooth_scale_set = _elm_image_smart_smooth_scale_set;
-
-   sc->signal = _unimplemented_smart_signal;
-   sc->callback_add = _unimplemented_smart_callback_add;
-   sc->callback_del = _unimplemented_smart_callback_del;
 }
 
 EAPI const Elm_Image_Smart_Class *
index fa989bf..ae6c20c 100644 (file)
@@ -299,6 +299,21 @@ Eina_List           *_elm_config_color_list_get(const char *palette_name);
 void                 _elm_config_color_set(const char *palette_name, int r, int g, int b, int a);
 void                 _elm_config_colors_free(const char *palette_name);
 
+/* DEPRECATED, will be removed on next release */
+void                 _elm_icon_signal_emit(Evas_Object *obj,
+                                           const char *emission,
+                                           const char *source);
+void                 _elm_icon_signal_callback_add(Evas_Object *obj,
+                                                   const char *emission,
+                                                   const char *source,
+                                                   Edje_Signal_Cb func_cb,
+                                                   void *data);
+void                *_elm_icon_signal_callback_del(Evas_Object *obj,
+                                                   const char *emission,
+                                                   const char *source,
+                                                   Edje_Signal_Cb func_cb);
+/* end of DEPRECATED */
+
 extern char *_elm_appname;
 extern Elm_Config *_elm_config;
 extern const char *_elm_data_dir;
index e9e5eb8..65e387c 100644 (file)
@@ -1,7 +1,6 @@
 #include <Elementary.h>
 #include "elm_priv.h"
 #include "elm_widget_container.h"
-#include "elm_widget_image.h"
 
 static const char SMART_NAME[] = "elm_widget";
 static const char SMART_NAME_COMPAT[] = "elm_widget_compat";
@@ -2509,8 +2508,12 @@ elm_widget_signal_emit(Evas_Object *obj,
      COMPAT_SMART_DATA(sd)->signal(obj, emission, source);
    else if (evas_object_smart_type_check(obj, "elm_layout"))
      elm_layout_signal_emit(obj, emission, source);
-   else if (evas_object_smart_type_check(obj, "elm_image"))
-     ELM_IMAGE_CLASS(sd->api)->signal(obj, emission, source);
+   else if (evas_object_smart_type_check(obj, "elm_icon"))
+     {
+        WRN("Deprecated function. This functionality on icon objects"
+            " will be dropped on a next release.");
+        _elm_icon_signal_emit(obj, emission, source);
+     }
 }
 
 static void
@@ -2556,8 +2559,13 @@ elm_widget_signal_callback_add(Evas_Object   *obj,
 
    else if (!evas_object_smart_type_check(obj, "elm_layout"))
      elm_layout_signal_callback_add(obj, emission, source, func, data);
-   else if (evas_object_smart_type_check(obj, "elm_image"))
-     ELM_IMAGE_CLASS(sd->api)->callback_add(obj, emission, source, func, data);
+   else if (evas_object_smart_type_check(obj, "elm_icon"))
+     {
+        WRN("Deprecated function. This functionality on icon objects"
+            " will be dropped on a next release.");
+
+        _elm_icon_signal_callback_add(obj, emission, source, func, data);
+     }
 }
 
 EAPI void *
@@ -2593,11 +2601,15 @@ elm_widget_signal_callback_del(Evas_Object   *obj,
         COMPAT_SMART_DATA(sd)->callback_del
           (obj, emission, source, _edje_signal_callback, esd);
      }
-
    else if (!evas_object_smart_type_check(obj, "elm_layout"))
      elm_layout_signal_callback_del(obj, emission, source, func);
-   else if (evas_object_smart_type_check(obj, "elm_image"))
-     ELM_IMAGE_CLASS(sd->api)->callback_del(obj, emission, source, func);
+   else if (evas_object_smart_type_check(obj, "elm_icon"))
+     {
+        WRN("Deprecated function. This functionality on icon objects"
+            " will be dropped on a next release.");
+
+        _elm_icon_signal_callback_del(obj, emission, source, func);
+     }
 
    return data;
 }
index 23b8285..b2c1ce4 100644 (file)
@@ -69,7 +69,7 @@
 #define ELM_IMAGE_SMART_CLASS_INIT(smart_class_init)                        \
   {smart_class_init, ELM_IMAGE_SMART_CLASS_VERSION, NULL, NULL, NULL, NULL, \
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,  \
-   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
+   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
 
 /**
  * @def ELM_IMAGE_SMART_CLASS_INIT_NULL
@@ -120,18 +120,6 @@ typedef struct _Elm_Image_Smart_Class
    int                    version; /**< Version of this smart class definition */
 
    void                 (*sizing_eval)(Evas_Object *obj); /* 'Virtual' function on evalutating the object's final geometry */
-   void                 (*signal)(Evas_Object *obj,
-                                  const char *emission,
-                                  const char *source); /* 'Virtual' function on emitting an (Edje) signal to the object, acting on its internal layout */
-   void                 (*callback_add)(Evas_Object *obj,
-                                        const char *emission,
-                                        const char *source,
-                                        Edje_Signal_Cb func,
-                                        void *data); /* 'Virtual' function on adding an (Edje) signal callback to the object, proxyed from its internal layout */
-   void                *(*callback_del)(Evas_Object * obj,
-                                        const char *emission,
-                                        const char *source,
-                                        Edje_Signal_Cb func); /* 'Virtual' function on deleting an (Edje) signal callback on the object, proxyed from its internal layout */
    Eina_Bool            (*memfile_set)(Evas_Object *obj,
                                        const void *img,
                                        size_t size,
@@ -204,8 +192,6 @@ struct _Elm_Image_Smart_Data
    double                scale;
    Elm_Image_Orient      orient;
 
-   Eina_List            *edje_signals;
-
    int                   frame_count;
    int                   cur_frame;
    double                frame_duration;