widget: Remove part_text from EO

It should be implemented as a efl_part() API.

For now I've only done a quick hack, as the only overrides were:

 - notify: already a Part implementation. Also it turns out the default
   theme does not even have any text part in the notify group.

 - combobox: not a Part implementation, but also very badly defined wrt.
   parts in general. efl_part() is handled by the parent class (button)
   which makes it tricky to override just for one function.

With this patch I'm trying to keep the same behaviour as earlier (where
efl_part() is used for layouts and there is a special path for
combobox).

Ref T5363
This commit is contained in:
Jean-Philippe Andre 2017-08-30 18:14:29 +09:00
parent c9fcdbc68c
commit a2729d119d
8 changed files with 41 additions and 32 deletions

View File

@ -521,17 +521,21 @@ _elm_combobox_elm_genlist_filter_set(Eo *obj EINA_UNUSED, Elm_Combobox_Data *pd,
elm_obj_genlist_filter_set(pd->genlist, key);
}
EOLIAN void
_elm_combobox_elm_widget_part_text_set(Eo *obj EINA_UNUSED, Elm_Combobox_Data *pd,
const char * part, const char *label)
// FIXME: Combobox part API is badly defined. Efl.Part should be reimplemented
// properly, but this will be tricky: how to set "guide" on the "entry" part?
void
_elm_combobox_part_text_set(Eo *obj, const char * part, const char *label)
{
Elm_Combobox_Data *pd = efl_data_scope_safe_get(obj, MY_CLASS);
if (!pd) return;
elm_object_part_text_set(pd->entry, part, label);
}
EOLIAN const char *
_elm_combobox_elm_widget_part_text_get(Eo *obj EINA_UNUSED, Elm_Combobox_Data *pd,
const char * part)
const char *
_elm_combobox_part_text_get(const Eo *obj, const char *part)
{
Elm_Combobox_Data *pd = efl_data_scope_safe_get(obj, MY_CLASS);
if (!pd) return NULL;
return elm_object_part_text_get(pd->entry, part);
}

View File

@ -39,13 +39,13 @@ class Elm.Combobox (Efl.Ui.Button, Efl.Ui.Selectable,
Efl.Object.constructor;
Efl.Gfx.visible { set; }
Efl.Gfx.size { set; }
Elm.Widget.part_text { get; set; }
Elm.Widget.theme_apply;
Elm.Widget.translate;
Elm.Widget.widget_event;
Efl.Ui.Autorepeat.autorepeat_supported { get; }
Elm.Genlist.filter { set; }
Elm.Interface.Atspi_Widget_Action.elm_actions { get; }
//Efl.Part.part; // TODO?
}
events {
dismissed; [[Called when combobox was dismissed]]

View File

@ -160,14 +160,16 @@ _elm_notify_elm_widget_theme_apply(Eo *obj, Elm_Notify_Data *sd)
return int_ret;
}
EOLIAN static void
_elm_notify_elm_widget_part_text_set(Eo *obj EINA_UNUSED, Elm_Notify_Data *sd, const char *part, const char *label)
/* Legacy compat. Note that notify has no text parts in the default theme... */
static void
_elm_notify_text_set(Eo *obj EINA_UNUSED, Elm_Notify_Data *sd, const char *part, const char *label)
{
edje_object_part_text_set(sd->notify, part, label);
}
EOLIAN static const char*
_elm_notify_elm_widget_part_text_get(Eo *obj EINA_UNUSED, Elm_Notify_Data *sd, const char *part)
/* Legacy compat. Note that notify has no text parts in the default theme... */
static const char*
_elm_notify_text_get(Eo *obj EINA_UNUSED, Elm_Notify_Data *sd, const char *part)
{
return edje_object_part_text_get(sd->notify, part);
}
@ -739,6 +741,8 @@ _elm_notify_class_constructor(Efl_Class *klass)
/* Efl.Part begin */
ELM_PART_IMPLEMENT(elm_notify, ELM_NOTIFY, Elm_Notify_Data, Elm_Part_Data)
ELM_PART_IMPLEMENT_TEXT_SET(elm_notify, ELM_NOTIFY, Elm_Notify_Data, Elm_Part_Data)
ELM_PART_IMPLEMENT_TEXT_GET(elm_notify, ELM_NOTIFY, Elm_Notify_Data, Elm_Part_Data)
ELM_PART_IMPLEMENT_CONTENT_SET(elm_notify, ELM_NOTIFY, Elm_Notify_Data, Elm_Part_Data)
ELM_PART_IMPLEMENT_CONTENT_GET(elm_notify, ELM_NOTIFY, Elm_Notify_Data, Elm_Part_Data)
ELM_PART_IMPLEMENT_CONTENT_UNSET(elm_notify, ELM_NOTIFY, Elm_Notify_Data, Elm_Part_Data)

View File

@ -90,7 +90,6 @@ class Elm.Notify (Elm.Widget, Efl.Container, Efl.Part)
Elm.Widget.focus_next_manager_is;
Elm.Widget.focus_next;
Elm.Widget.widget_sub_object_del;
Elm.Widget.part_text { get; set; }
Efl.Container.content { get; set; }
Efl.Container.content_unset;
Efl.Part.part;

View File

@ -1,9 +1,10 @@
class Elm.Notify.Internal.Part (Efl.Object, Efl.Container)
class Elm.Notify.Internal.Part (Efl.Object, Efl.Container, Efl.Text)
{
[[Elementary notification internel part class]]
data: Elm_Part_Data;
implements {
Efl.Object.destructor;
Efl.Text.text { get; set; }
Efl.Container.content { get; set; }
Efl.Container.content_unset;
}

View File

@ -547,6 +547,10 @@ void _elm_win_wl_cursor_set(Evas_Object *obj, const char *cursor
void _efl_ui_focus_manager_redirect_events_del(Efl_Ui_Focus_Manager *manager, Eo *obj);
void _efl_ui_focus_manager_redirect_events_add(Efl_Ui_Focus_Manager *manager, Eo *obj);
/* Combobox: no proper support for Efl.Part API yet. */
void _elm_combobox_part_text_set(Eo *obj, const char * part, const char *label);
const char *_elm_combobox_part_text_get(const Eo *obj, const char *part);
/* DEPRECATED, will be removed on next release */
void _elm_icon_signal_emit(Evas_Object *obj,
const char *emission,

View File

@ -3632,17 +3632,23 @@ elm_widget_theme_set(Evas_Object *obj, Elm_Theme *th)
elm_obj_widget_theme_set(obj, th);
}
EOLIAN static void
_elm_widget_part_text_set(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *part, const char *label)
EAPI void
elm_widget_part_text_set(Eo *obj, const char *part, const char *label)
{
if (evas_object_smart_type_check(obj, "elm_layout"))
/* legacy support: combobox was special (internal entry is text object). */
if (efl_isa(obj, ELM_COMBOBOX_CLASS))
_elm_combobox_part_text_set(obj, part, label);
else if (efl_isa(obj, EFL_UI_LAYOUT_CLASS))
elm_layout_text_set(obj, part, label);
}
EOLIAN static const char*
_elm_widget_part_text_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const char *part)
EAPI const char*
elm_widget_part_text_get(const Eo *obj, const char *part)
{
if (evas_object_smart_type_check(obj, "elm_layout"))
/* legacy support: combobox was special (internal entry is text object). */
if (efl_isa(obj, ELM_COMBOBOX_CLASS))
return _elm_combobox_part_text_get(obj, part);
else if (efl_isa(obj, EFL_UI_LAYOUT_CLASS))
return elm_layout_text_get(obj, part);
return NULL;
@ -3729,7 +3735,7 @@ _elm_widget_domain_translatable_part_text_set(Eo *obj, Elm_Widget_Smart_Data *sd
}
sd->on_translate = EINA_TRUE;
elm_obj_widget_part_text_set(obj, part, label);
elm_widget_part_text_set(obj, part, label);
sd->on_translate = EINA_FALSE;
}
@ -3755,7 +3761,7 @@ _elm_widget_domain_part_text_translatable_set(Eo *obj, Elm_Widget_Smart_Data *sd
if (!ts->domain) ts->domain = eina_stringshare_add(domain);
else eina_stringshare_replace(&ts->domain, domain);
text = elm_obj_widget_part_text_get(obj, part);
text = elm_widget_part_text_get(obj, part);
if (!text || !text[0]) return;
if (!ts->string) ts->string = eina_stringshare_add(text);
@ -3765,7 +3771,7 @@ _elm_widget_domain_part_text_translatable_set(Eo *obj, Elm_Widget_Smart_Data *sd
text = dgettext(domain, text);
#endif
sd->on_translate = EINA_TRUE;
elm_obj_widget_part_text_set(obj, part, text);
elm_widget_part_text_set(obj, part, text);
sd->on_translate = EINA_FALSE;
}
@ -3825,7 +3831,7 @@ _elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSE
if (!ts->string) continue;
const char *s = dgettext(ts->domain, ts->string);
sd->on_translate = EINA_TRUE;
elm_obj_widget_part_text_set(obj, ts->id, s);
elm_widget_part_text_set(obj, ts->id, s);
sd->on_translate = EINA_FALSE;
}
#endif

View File

@ -293,15 +293,6 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible,
translatable: bool; [[$true if translatable, $false otherwise]]
}
}
@property part_text {
[[Part text property]]
keys {
part: string; [[Part name]]
}
values {
label: string; [[Label]]
}
}
translatable_part_text_get @const {
[[Get translatable part text]]
return: string; [[Part text]]