elm: refactor legacy _icon_signal_emit

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
This commit is contained in:
Mike Blumenkrantz 2020-05-13 10:02:36 -04:00
parent 6a14507edc
commit cf94110b04
6 changed files with 33 additions and 86 deletions

View File

@ -394,24 +394,6 @@ _efl_ui_button_legacy_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
return 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 */
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 */
@ -422,7 +404,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);
return int_ret;
}
@ -438,7 +420,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;
}
@ -454,7 +436,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;
}

View File

@ -450,26 +450,6 @@ _efl_ui_check_legacy_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
return 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 */
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 */
@ -481,7 +461,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;
}
@ -497,7 +477,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;
}
@ -513,7 +493,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;
}

View File

@ -3297,6 +3297,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)
{

View File

@ -744,23 +744,6 @@ _efl_ui_progressbar_legacy_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
return 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 */
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 */
@ -771,7 +754,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;
}
@ -787,7 +770,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;
}
@ -803,7 +786,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;
}

View File

@ -336,25 +336,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)
{
@ -365,7 +346,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;
}
@ -381,7 +362,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;
}
@ -397,7 +378,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;
}

View File

@ -931,6 +931,7 @@ void _elm_entry_entry_paste(Evas_Object *obj, const char *entry);
double _elm_atof(const char *s);
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);