summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-05-30 10:38:19 +0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-06-12 13:59:19 +0200
commitcaa9bdfe13a83bb646d60eb8609cb34ef8987f87 (patch)
tree8c33fbca367633167fa8ab4200c9e496b98d1ba5
parentde0dd85096457e658b012656cb840f75ce0c49b3 (diff)
downloadefl-caa9bdfe13a83bb646d60eb8609cb34ef8987f87.tar.gz
elm_widget: add signal for parent changes
Summary: this signal is emitted when a new subobject is added by calling elm_widget_sub_object_add. Reviewers: raster Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D3992
-rw-r--r--src/lib/elementary/elm_widget.c28
-rw-r--r--src/lib/elementary/elm_widget.eo6
2 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c
index 7aa146bc69..8b87d8ed24 100644
--- a/src/lib/elementary/elm_widget.c
+++ b/src/lib/elementary/elm_widget.c
@@ -1118,10 +1118,13 @@ _elm_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj
if (_elm_widget_is(sobj))
{
ELM_WIDGET_DATA_GET(sobj, sdc);
+ Eo *old_parent;
+ Elm_Parent_Change change;
if (sdc->parent_obj == obj) goto end;
if (sdc->parent_obj)
{
+ old_parent = obj;
if (!elm_widget_sub_object_del(sdc->parent_obj, sobj))
return EINA_FALSE;
}
@@ -1159,6 +1162,11 @@ _elm_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj
sdp->child_can_focus = EINA_TRUE;
}
}
+ //drop a event because of this change
+ change.child = sobj;
+ change.old_parent = old_parent;
+
+ eo_event_callback_call(sobj, ELM_WIDGET_EVENT_PARENT_CHANGED, &change);
}
else
{
@@ -5766,6 +5774,24 @@ elm_widget_tree_dot_dump(const Evas_Object *top,
#endif
}
+static Eina_Bool
+_parent_changed(void *data EINA_UNUSED, const Eo_Event *event)
+{
+ ELM_WIDGET_DATA_GET(event->object, pd);
+ Elm_Parent_Change *change = event->info;
+ Eina_List *node;
+ Elm_Widget *sobj;
+
+ printf("PARENT CHANGE %p\n", change);
+
+ EINA_LIST_FOREACH(pd->subobjs, node, sobj)
+ {
+ eo_event_callback_call(sobj, ELM_WIDGET_EVENT_PARENT_CHANGED, event->info);
+ }
+
+ return EO_CALLBACK_CONTINUE;
+}
+
EOLIAN static Eo *
_elm_widget_eo_base_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
{
@@ -5779,6 +5805,8 @@ _elm_widget_eo_base_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
elm_obj_widget_parent_set(obj, parent);
sd->on_create = EINA_FALSE;
+ eo_event_callback_add(obj, ELM_WIDGET_EVENT_PARENT_CHANGED, _parent_changed, NULL);
+
elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_UNKNOWN);
return obj;
}
diff --git a/src/lib/elementary/elm_widget.eo b/src/lib/elementary/elm_widget.eo
index ccf3799bdd..56e62e8461 100644
--- a/src/lib/elementary/elm_widget.eo
+++ b/src/lib/elementary/elm_widget.eo
@@ -17,6 +17,11 @@ enum Elm.Activate
back,
}
+struct Elm.Parent_Change {
+ child : Elm.Widget; [[the child where the parent changed]]
+ old_parent : Elm.Widget; [[the old parent which was changed]]
+}
+
struct Elm.Tooltip;
struct Elm.Cursor;
struct @extern Elm.Theme;
@@ -877,5 +882,6 @@ abstract Elm.Widget (Evas.Object.Smart, Elm.Interface.Atspi_Accessible, Elm.Inte
unfocused;
language,changed;
access,changed;
+ parent,changed : Elm.Parent_Change*;
}
}