elm: refactor legacy _icon_signal_emit
authorMike Blumenkrantz <zmike@samsung.com>
Wed, 13 May 2020 14:02:36 +0000 (10:02 -0400)
committerJongmin Lee <jm105.lee@samsung.com>
Wed, 13 May 2020 22:26:09 +0000 (07:26 +0900)
Summary:
this was duplicated for a number of widgets in slightly different ways,
so it can be unified as a private layout function to reduce maintenance
costs

Reviewers: Hermet, YOhoho, Jaehyun_Cho, jsuya

Reviewed By: jsuya

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11818

Change-Id: I5fdacb9b8244eebd585315a565c4291e97cb530a

src/lib/elementary/efl_ui_button.c
src/lib/elementary/efl_ui_check.c
src/lib/elementary/efl_ui_layout.c
src/lib/elementary/efl_ui_progressbar.c
src/lib/elementary/efl_ui_radio.c
src/lib/elementary/elm_priv.h

index 215033d..3115591 100644 (file)
@@ -420,24 +420,6 @@ _efl_ui_button_legacy_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
 /* FIXME: replicated from elm_layout just because button's icon spot
  * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
  * can changed the theme API */
-static void
-_icon_signal_emit(Evas_Object *obj)
-{
-   char buf[64];
-
-   if (!elm_widget_resize_object_get(obj)) return;
-   if (!edje_object_part_exists(obj, "elm.swallow.content")) return;
-   snprintf(buf, sizeof(buf), "elm,state,icon,%s",
-            elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
-
-   elm_layout_signal_emit(obj, buf, "elm");
-   edje_object_message_signal_process(elm_layout_edje_get(obj));
-   efl_canvas_group_change(obj);
-}
-
-/* FIXME: replicated from elm_layout just because button's icon spot
- * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
- * can changed the theme API */
 EOLIAN static Eina_Error
 _efl_ui_button_legacy_efl_ui_widget_theme_apply(Eo *obj, void *_pd EINA_UNUSED)
 {
@@ -445,7 +427,7 @@ _efl_ui_button_legacy_efl_ui_widget_theme_apply(Eo *obj, void *_pd EINA_UNUSED)
 
    int_ret = efl_ui_widget_theme_apply(efl_super(obj, EFL_UI_BUTTON_LEGACY_CLASS));
    if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
-   if (efl_finalized_get(obj)) _icon_signal_emit(obj);
+   if (efl_finalized_get(obj)) _elm_layout_legacy_icon_signal_emit(obj);
 
 #ifdef TIZEN_VECTOR_UX
    tizen_vg_button_set(obj);
@@ -465,7 +447,7 @@ _efl_ui_button_legacy_efl_ui_widget_widget_sub_object_del(Eo *obj, void *_pd EIN
    int_ret = elm_widget_sub_object_del(efl_super(obj, EFL_UI_BUTTON_LEGACY_CLASS), sobj);
    if (!int_ret) return EINA_FALSE;
 
-   _icon_signal_emit(obj);
+   _elm_layout_legacy_icon_signal_emit(obj);
 
    return EINA_TRUE;
 }
@@ -481,7 +463,7 @@ _efl_ui_button_legacy_content_set(Eo *obj, void *_pd EINA_UNUSED, const char *pa
    int_ret = efl_content_set(efl_part(efl_super(obj, EFL_UI_BUTTON_LEGACY_CLASS), part), content);
    if (!int_ret) return EINA_FALSE;
 
-   _icon_signal_emit(obj);
+   _elm_layout_legacy_icon_signal_emit(obj);
 
    return EINA_TRUE;
 }
index 2002170..be1655d 100644 (file)
@@ -456,26 +456,6 @@ _efl_ui_check_legacy_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
 /* FIXME: replicated from elm_layout just because check's icon spot
  * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
  * can changed the theme API */
-static void
-_icon_signal_emit(Evas_Object *obj)
-{
-   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
-   char buf[64];
-
-   if (!elm_widget_resize_object_get(obj)) return;
-   if (!edje_object_part_exists(obj, "elm.swallow.content")) return;
-   snprintf(buf, sizeof(buf), "elm,state,icon,%s",
-            elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
-
-   elm_layout_signal_emit(obj, buf, "elm");
-   edje_object_message_signal_process(wd->resize_obj);
-
-   efl_canvas_group_change(obj);
-}
-
-/* FIXME: replicated from elm_layout just because check's icon spot
- * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
- * can changed the theme API */
 EOLIAN static Eina_Error
 _efl_ui_check_legacy_efl_ui_widget_theme_apply(Eo *obj, void *_pd EINA_UNUSED)
 {
@@ -484,7 +464,7 @@ _efl_ui_check_legacy_efl_ui_widget_theme_apply(Eo *obj, void *_pd EINA_UNUSED)
    int_ret = efl_ui_widget_theme_apply(efl_super(obj, EFL_UI_CHECK_LEGACY_CLASS));
    if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
 
-   if (efl_finalized_get(obj)) _icon_signal_emit(obj);
+   if (efl_finalized_get(obj)) _elm_layout_legacy_icon_signal_emit(obj);
 
    return int_ret;
 }
@@ -500,7 +480,7 @@ _efl_ui_check_legacy_efl_ui_widget_widget_sub_object_del(Eo *obj, void *_pd EINA
    int_ret = elm_widget_sub_object_del(efl_super(obj, EFL_UI_CHECK_LEGACY_CLASS), sobj);
    if (!int_ret) return EINA_FALSE;
 
-   _icon_signal_emit(obj);
+   _elm_layout_legacy_icon_signal_emit(obj);
 
    return EINA_TRUE;
 }
@@ -516,7 +496,7 @@ _efl_ui_check_legacy_content_set(Eo *obj, void *_pd EINA_UNUSED, const char *par
    int_ret = efl_content_set(efl_part(efl_super(obj, EFL_UI_CHECK_LEGACY_CLASS), part), content);
    if (!int_ret) return EINA_FALSE;
 
-   _icon_signal_emit(obj);
+   _elm_layout_legacy_icon_signal_emit(obj);
 
    return EINA_TRUE;
 }
index da93dda..83812f7 100644 (file)
@@ -3565,6 +3565,26 @@ _elm_layout_signal_callback_add_legacy(Eo *obj, Eo *edje, Eina_List **p_edje_sig
                                          _edje_signal_callback, esd);
 }
 
+/* replicated from elm_layout just because legacy widget's icon spot
+ * is elm.swallow.content, not elm.swallow.icon.
+ */
+void
+_elm_layout_legacy_icon_signal_emit(Evas_Object *obj)
+{
+   char buf[63];
+   Eo *edje;
+
+   edje = elm_layout_edje_get(obj);
+   if (!edje) return;
+   if (!edje_object_part_exists(obj, "elm.swallow.content")) return;
+   snprintf(buf, sizeof(buf), "elm,state,icon,%s",
+            elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
+
+   elm_layout_signal_emit(obj, buf, "elm");
+   edje_object_message_signal_process(edje);
+   efl_canvas_group_change(obj);
+}
+
 EAPI void
 elm_layout_signal_callback_add(Eo *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data)
 {
index 2b5239b..eadb0cc 100644 (file)
@@ -804,23 +804,6 @@ _efl_ui_progressbar_legacy_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
 /* FIXME: replicated from elm_layout just because progressbar's icon spot
  * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
  * can changed the theme API */
-static void
-_icon_signal_emit(Evas_Object *obj)
-{
-   char buf[64];
-
-   if (!elm_widget_resize_object_get(obj)) return;
-   snprintf(buf, sizeof(buf), "elm,state,icon,%s",
-            elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
-
-   elm_layout_signal_emit(obj, buf, "elm");
-   edje_object_message_signal_process(elm_layout_edje_get(obj));
-   efl_canvas_group_change(obj);
-}
-
-/* FIXME: replicated from elm_layout just because progressbar's icon spot
- * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
- * can changed the theme API */
 EOLIAN static Eina_Error
 _efl_ui_progressbar_legacy_efl_ui_widget_theme_apply(Eo *obj, void *_pd EINA_UNUSED)
 {
@@ -828,7 +811,7 @@ _efl_ui_progressbar_legacy_efl_ui_widget_theme_apply(Eo *obj, void *_pd EINA_UNU
 
    int_ret = efl_ui_widget_theme_apply(efl_super(obj, EFL_UI_PROGRESSBAR_LEGACY_CLASS));
    if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
-   if (efl_finalized_get(obj)) _icon_signal_emit(obj);
+   if (efl_finalized_get(obj)) _elm_layout_legacy_icon_signal_emit(obj);
 
    return int_ret;
 }
@@ -844,7 +827,7 @@ _efl_ui_progressbar_legacy_efl_ui_widget_widget_sub_object_del(Eo *obj, void *_p
    int_ret = elm_widget_sub_object_del(efl_super(obj, EFL_UI_PROGRESSBAR_LEGACY_CLASS), sobj);
    if (!int_ret) return EINA_FALSE;
 
-   _icon_signal_emit(obj);
+   _elm_layout_legacy_icon_signal_emit(obj);
 
    return EINA_TRUE;
 }
@@ -860,7 +843,7 @@ _efl_ui_progressbar_legacy_content_set(Eo *obj, void *_pd EINA_UNUSED, const cha
    int_ret = efl_content_set(efl_part(efl_super(obj, EFL_UI_PROGRESSBAR_LEGACY_CLASS), part), content);
    if (!int_ret) return EINA_FALSE;
 
-   _icon_signal_emit(obj);
+   _elm_layout_legacy_icon_signal_emit(obj);
 
    return EINA_TRUE;
 }
index ff5bcc3..7eb0fa7 100644 (file)
@@ -337,25 +337,6 @@ _efl_ui_radio_legacy_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
    return obj;
 }
 
-/* FIXME: replicated from elm_layout just because radio's icon spot
- * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
- * can changed the theme API */
-static void
-_icon_signal_emit(Evas_Object *obj)
-{
-   char buf[63];
-   Eo *edje;
-
-   edje = elm_widget_resize_object_get(obj);
-   if (!edje) return;
-   snprintf(buf, sizeof(buf), "elm,state,icon,%s",
-            elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
-
-   elm_layout_signal_emit(obj, buf, "elm");
-   edje_object_message_signal_process(edje);
-   efl_canvas_group_change(obj);
-}
-
 EOLIAN static Eina_Error
 _efl_ui_radio_legacy_efl_ui_widget_theme_apply(Eo *obj, void *_pd EINA_UNUSED)
 {
@@ -366,7 +347,7 @@ _efl_ui_radio_legacy_efl_ui_widget_theme_apply(Eo *obj, void *_pd EINA_UNUSED)
    /* FIXME: replicated from elm_layout just because radio's icon
     * spot is elm.swallow.content, not elm.swallow.icon. Fix that
     * whenever we can changed the theme API */
-   if (efl_finalized_get(obj)) _icon_signal_emit(obj);
+   if (efl_finalized_get(obj)) _elm_layout_legacy_icon_signal_emit(obj);
 
    return int_ret;
 }
@@ -382,7 +363,7 @@ _efl_ui_radio_legacy_efl_ui_widget_widget_sub_object_del(Eo *obj, void *_pd EINA
    int_ret = elm_widget_sub_object_del(efl_super(obj, EFL_UI_RADIO_LEGACY_CLASS), sobj);
    if (!int_ret) return EINA_FALSE;
 
-   _icon_signal_emit(obj);
+   _elm_layout_legacy_icon_signal_emit(obj);
 
    return EINA_TRUE;
 }
@@ -398,7 +379,7 @@ _efl_ui_radio_legacy_content_set(Eo *obj, void *_pd EINA_UNUSED, const char *par
    int_ret = efl_content_set(efl_part(efl_super(obj, EFL_UI_RADIO_LEGACY_CLASS), part), content);
    if (!int_ret) return EINA_FALSE;
 
-   _icon_signal_emit(obj);
+   _elm_layout_legacy_icon_signal_emit(obj);
 
    return EINA_TRUE;
 }
index 9f2dc42..8e8736a 100644 (file)
@@ -987,6 +987,7 @@ void tizen_vg_progressbar_set(Elm_Progressbar *obj);
 void tizen_vg_slider_set(Elm_Slider *obj, Evas_Object *popup);
 #endif
 
+void _elm_layout_legacy_icon_signal_emit(Evas_Object *obj);
 // elm_layout and elm_entry LEGACY signal API (returned the user data pointer)
 void _elm_layout_signal_callback_add_legacy(Eo *obj, Eo *edje, Eina_List **p_edje_signals, const char *emission, const char *source, Edje_Signal_Cb func, void *data);
 void *_elm_layout_signal_callback_del_legacy(Eo *obj, Eo *edje, Eina_List **p_edje_signals, const char *emission, const char *source, Edje_Signal_Cb func);