From 544fedaeba445609ca285e939db0742730137199 Mon Sep 17 00:00:00 2001 From: Daniel Hirt Date: Tue, 4 Jul 2017 12:54:44 +0300 Subject: [PATCH] Elm layout: only allow legacy for using NULL text parts This is a follow-up to a4b79fdbe16e1495c187dc4f9da99924cf51e539. efl_part no longer supports NULL parts. NULL text parts are now aliased in legacy code beforehand. Signed-off-by: Jean-Philippe Andre --- src/lib/elementary/elc_popup.c | 12 +++++++++--- src/lib/elementary/elm_actionslider.c | 8 ++++++-- src/lib/elementary/elm_bubble.c | 7 +++---- src/lib/elementary/elm_label.c | 13 ------------- src/lib/elementary/elm_label.eo | 1 - src/lib/elementary/elm_layout.c | 21 ++++++++++++++++++--- src/lib/elementary/elm_part_helper.h | 6 ++++++ src/lib/elementary/elm_widget.c | 3 +++ src/lib/elementary/elm_widget.h | 1 + 9 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/lib/elementary/elc_popup.c b/src/lib/elementary/elc_popup.c index f693de9..2369edf 100644 --- a/src/lib/elementary/elc_popup.c +++ b/src/lib/elementary/elc_popup.c @@ -1057,12 +1057,15 @@ end: return EINA_TRUE; } -EOLIAN static Eina_Bool +static Eina_Bool _elm_popup_text_set(Eo *obj, Elm_Popup_Data *_pd, const char *part, const char *label) { Eina_Bool int_ret = EINA_FALSE; - if (!part || !strcmp(part, "default") || !strcmp(part, "elm.text")) + if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE)) + return EINA_FALSE; + + if (!strcmp(part, "elm.text")) int_ret = _content_text_set(obj, label); else if (!strcmp(part, "title,text")) int_ret = _title_text_set(obj, label); @@ -1096,7 +1099,10 @@ _elm_popup_text_get(Eo *obj EINA_UNUSED, Elm_Popup_Data *_pd, const char *part) { const char *text = NULL; - if (!part || !strcmp(part, "default")) + if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE)) + return NULL; + + if (!strcmp(part, "elm.text")) text = _content_text_get(_pd); else if (!strcmp(part, "title,text")) text = _title_text_get(_pd); diff --git a/src/lib/elementary/elm_actionslider.c b/src/lib/elementary/elm_actionslider.c index 80888bb..7739684 100644 --- a/src/lib/elementary/elm_actionslider.c +++ b/src/lib/elementary/elm_actionslider.c @@ -456,9 +456,11 @@ _elm_actionslider_text_set(Eo *obj, Elm_Actionslider_Data *_pd EINA_UNUSED, cons { Eina_Bool int_ret = EINA_TRUE; + if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE)) + return EINA_FALSE; + _mirrored_part_fix(obj, &part); - if (!part || !strcmp(part, "elm.text")) part = _text_aliases[0].real_part; efl_text_set(efl_part(efl_super(obj, MY_CLASS), part), text); return int_ret; @@ -469,9 +471,11 @@ _elm_actionslider_text_get(Eo *obj, Elm_Actionslider_Data *_pd EINA_UNUSED, cons { const char *text = NULL; + if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE)) + return NULL; + _mirrored_part_fix(obj, &part); - if (!part) part = _text_aliases[0].real_part; text = efl_text_get(efl_part(efl_super(obj, MY_CLASS), part)); return text; diff --git a/src/lib/elementary/elm_bubble.c b/src/lib/elementary/elm_bubble.c index 51f2de1..084fcd7 100644 --- a/src/lib/elementary/elm_bubble.c +++ b/src/lib/elementary/elm_bubble.c @@ -119,13 +119,12 @@ _elm_bubble_elm_widget_focus_direction(Eo *obj, Elm_Bubble_Data *_pd EINA_UNUSED EOLIAN static Eina_Bool _elm_bubble_text_set(Eo *obj, Elm_Bubble_Data *_pd EINA_UNUSED, const char *part, const char *label) { - Eina_Bool int_ret = EINA_TRUE; + if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE)) + return EINA_FALSE; - if (!part) part = _text_aliases[0].real_part; efl_text_set(efl_part(efl_super(obj, MY_CLASS), part), label); - if (!int_ret) return EINA_FALSE; - if (part && (!strcmp(part, "info") || !strcmp(part, "elm.info"))) + if (!strcmp(part, "elm.info")) { if (label) elm_layout_signal_emit(obj, "elm,state,info,visible", "elm"); diff --git a/src/lib/elementary/elm_label.c b/src/lib/elementary/elm_label.c index 7a5f65e..2d8f07a 100644 --- a/src/lib/elementary/elm_label.c +++ b/src/lib/elementary/elm_label.c @@ -27,12 +27,6 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = { {NULL, NULL} }; -static const Elm_Layout_Part_Alias_Description _text_aliases[] = -{ - {"default", "elm.text"}, - {NULL, NULL} -}; - static void _recalc(void *data) { @@ -348,7 +342,6 @@ _elm_label_text_set(Eo *obj, Elm_Label_Data *sd, const char *part, const char *l if (!label) label = ""; _label_format_set(wd->resize_obj, sd->format); - if (!part) part = _text_aliases[0].real_part; efl_text_set(efl_part(efl_super(obj, MY_CLASS), part), label); if (int_ret) @@ -623,12 +616,6 @@ _elm_label_slide_duration_get(Eo *obj EINA_UNUSED, Elm_Label_Data *sd) return sd->slide_duration; } -EOLIAN static const Elm_Layout_Part_Alias_Description* -_elm_label_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Label_Data *_pd EINA_UNUSED) -{ - return _text_aliases; -} - EOLIAN static Eina_Bool _elm_label_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Label_Data *_pd EINA_UNUSED) { diff --git a/src/lib/elementary/elm_label.eo b/src/lib/elementary/elm_label.eo index c6525c3..bfb4a41 100644 --- a/src/lib/elementary/elm_label.eo +++ b/src/lib/elementary/elm_label.eo @@ -127,7 +127,6 @@ class Elm.Label (Elm.Layout) Elm.Widget.focus_next_manager_is; Elm.Widget.focus_direction_manager_is; Elm.Widget.theme_apply; - Elm.Layout.text_aliases { get; } Elm.Layout.sizing_eval; Efl.Part.part; } diff --git a/src/lib/elementary/elm_layout.c b/src/lib/elementary/elm_layout.c index ad5de01..5353a7c 100644 --- a/src/lib/elementary/elm_layout.c +++ b/src/lib/elementary/elm_layout.c @@ -2332,7 +2332,11 @@ elm_layout_table_clear(Elm_Layout *obj, const char *part, Eina_Bool clear) EAPI Eina_Bool elm_layout_text_set(Elm_Layout *obj, const char *part, const char *text) { - if (!part) part = "elm.text"; + if (!part) + { + part = elm_widget_default_text_part_get(obj); + if (!part) return EINA_FALSE; + } efl_text_set(efl_part(obj, part), text); return EINA_TRUE; } @@ -2340,9 +2344,10 @@ elm_layout_text_set(Elm_Layout *obj, const char *part, const char *text) EAPI const char * elm_layout_text_get(const Elm_Layout *obj, const char *part) { - if (!part || (*part == '\0')) + if (!part) { - part = "elm.text"; + part = elm_widget_default_text_part_get(obj); + if (!part) return NULL; } return efl_text_get(efl_part(obj, part)); } @@ -2392,6 +2397,15 @@ _elm_layout_default_content_part_get(const Eo *obj, Elm_Layout_Smart_Data *sd EI return part; } +static const char * +_elm_layout_default_text_part_get(const Eo *obj, Elm_Layout_Smart_Data *sd EINA_UNUSED) +{ + const char *part = NULL; + if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE)) + return NULL; + return part; +} + ELM_PART_IMPLEMENT_DESTRUCTOR(elm_layout, ELM_LAYOUT, Elm_Layout_Smart_Data, Elm_Part_Data) ELM_PART_IMPLEMENT_CONTENT_SET(elm_layout, ELM_LAYOUT, Elm_Layout_Smart_Data, Elm_Part_Data) ELM_PART_IMPLEMENT_CONTENT_GET(elm_layout, ELM_LAYOUT, Elm_Layout_Smart_Data, Elm_Part_Data) @@ -2408,6 +2422,7 @@ ELM_PART_IMPLEMENT_TEXT_GET(elm_layout, ELM_LAYOUT, Elm_Layout_Smart_Data, Elm_P #define ELM_LAYOUT_EXTRA_OPS \ EFL_CANVAS_GROUP_ADD_DEL_OPS(elm_layout), \ ELM_PART_CONTENT_DEFAULT_OPS(elm_layout), \ + ELM_PART_TEXT_DEFAULT_OPS(elm_layout), \ EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _elm_layout_efl_object_dbg_info_get) #include "elm_layout.eo.c" diff --git a/src/lib/elementary/elm_part_helper.h b/src/lib/elementary/elm_part_helper.h index 930ff6d..55c50f3 100644 --- a/src/lib/elementary/elm_part_helper.h +++ b/src/lib/elementary/elm_part_helper.h @@ -97,6 +97,12 @@ _ ## type ## _internal_part_efl_text_text_get(Eo *obj, partdata *pd) \ #define ELM_PART_CONTENT_DEFAULT_OPS(type) \ EFL_OBJECT_OP_FUNC(elm_widget_default_content_part_get, _ ## type ## _default_content_part_get) +#define ELM_PART_TEXT_DEFAULT_GET(type, part) \ + static const char * _ ## type ## _default_text_part_get(const Eo *obj EINA_UNUSED, void *sd EINA_UNUSED) { return part; } + +#define ELM_PART_TEXT_DEFAULT_OPS(type) \ + EFL_OBJECT_OP_FUNC(elm_widget_default_text_part_get, _ ## type ## _default_text_part_get) + // For widgets that inherit from something with parts (eg. from Elm.Layout) #define ELM_PART_OVERRIDE(type, TYPE, SUPER, typedata, partdata) \ static EOLIAN Efl_Object * \ diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c index 8bd35b1..9a3da4e 100644 --- a/src/lib/elementary/elm_widget.c +++ b/src/lib/elementary/elm_widget.c @@ -6546,12 +6546,15 @@ elm_widget_content_part_unset(Evas_Object *obj, /* Internal EO APIs and hidden overrides */ EFL_FUNC_BODY_CONST(elm_widget_default_content_part_get, const char *, NULL) +EFL_FUNC_BODY_CONST(elm_widget_default_text_part_get, const char *, NULL) ELM_PART_CONTENT_DEFAULT_SET(elm_widget, NULL) +ELM_PART_TEXT_DEFAULT_GET(elm_widget, NULL) #define ELM_WIDGET_EXTRA_OPS \ EFL_CANVAS_GROUP_ADD_DEL_OPS(elm_widget), \ ELM_PART_CONTENT_DEFAULT_OPS(elm_widget), \ + ELM_PART_TEXT_DEFAULT_OPS(elm_widget), \ EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _elm_widget_efl_object_dbg_info_get) #include "elm_widget_item.eo.c" diff --git a/src/lib/elementary/elm_widget.h b/src/lib/elementary/elm_widget.h index 01b2ccc..4b7b55c 100644 --- a/src/lib/elementary/elm_widget.h +++ b/src/lib/elementary/elm_widget.h @@ -868,6 +868,7 @@ EAPI Eina_Bool _elm_layout_part_aliasing_eval(const Evas_Object *obj, /* Internal EO APIs */ const char *elm_widget_default_content_part_get(const Eo *obj); +const char *elm_widget_default_text_part_get(const Eo *obj); #define ELM_WIDGET_ITEM_PROTECTED -- 2.7.4