diff options
author | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2014-05-01 23:29:32 -0300 |
---|---|---|
committer | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2014-05-05 19:49:21 -0300 |
commit | d27d1dd8d4845a5cb2226ee3e409f6958b120668 (patch) | |
tree | b28d7176f51f36d4d13696c0cf76d4a6a8479817 | |
parent | 43bdd064dc8bbc09ed2652f5fffb4b5c9235185c (diff) | |
download | glade-d27d1dd8d4845a5cb2226ee3e409f6958b120668.tar.gz |
GladeWidgetAdaptor: Fixed glade_widget_adaptor_object_get_children() for internal widgets.
Internal widgets are defined in Glade in the adaptor class that introduced them.
So in order to get internal widgets that are descendant of another internal widget
we need to walk up the adaptor hierarchy to find where internal widgets are defined.
I included this patch in the stable version because without it glade can not access
GtkDialog internal action_area if compiled with gtk master (version 3.13)
-rw-r--r-- | gladeui/glade-widget-adaptor.c | 98 |
1 files changed, 68 insertions, 30 deletions
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c index df877e9b..5f49d3c9 100644 --- a/gladeui/glade-widget-adaptor.c +++ b/gladeui/glade-widget-adaptor.c @@ -257,6 +257,29 @@ glade_abort_if_derived_adaptors_exist (GType type) } } +static GladeInternalChild * +gwa_internal_child_find (GList *list, const gchar *name) +{ + GList *l; + + for (l = list; l; l = g_list_next (l)) + { + GladeInternalChild *data = l->data; + + if (strcmp (data->name, name) == 0) + return data; + + if (data->children) + { + GladeInternalChild *child; + if ((child = gwa_internal_child_find (data->children, name))) + return child; + } + } + + return NULL; +} + /******************************************************************************* Base Object Implementation detail *******************************************************************************/ @@ -1301,13 +1324,14 @@ glade_widget_adaptor_object_create_editable (GladeWidgetAdaptor *adaptor, return (GladeEditable *) glade_editor_table_new (adaptor, type); } -static GList * -glade_widget_adaptor_object_get_children (GladeWidgetAdaptor *adaptor, - GObject *object) +static void +glade_internal_child_append (GladeWidgetAdaptor *adaptor, + GObject *object, + GList *list, + GList **children) { - GList *list = adaptor->priv->internal_children; - GList *l, *children = NULL; - + GList *l; + for (l = list; l; l = g_list_next (l)) { GladeInternalChild *internal = l->data; @@ -1317,8 +1341,45 @@ glade_widget_adaptor_object_get_children (GladeWidgetAdaptor *adaptor, object, internal->name); if (child) - children = g_list_prepend (children, child); + *children = g_list_prepend (*children, child); } +} + +static GList * +glade_widget_adaptor_object_get_children (GladeWidgetAdaptor *adaptor, + GObject *object) +{ + GladeWidget *gwidget = glade_widget_get_from_gobject (object); + GList *children = NULL; + const gchar *name; + + if (gwidget && (name = glade_widget_get_internal (gwidget))) + { + GladeWidget *parent = gwidget; + + /* Get non internal parent */ + while ((parent = glade_widget_get_parent (parent)) && + glade_widget_get_internal (parent)); + + if (parent) + { + GladeWidgetAdaptor *padaptor = glade_widget_get_adaptor (parent); + GladeInternalChild *internal; + + internal = gwa_internal_child_find (padaptor->priv->internal_children, + name); + + if (internal && internal->children) + glade_internal_child_append (padaptor, glade_widget_get_object (parent), + internal->children, &children); + } + + return children; + } + + glade_internal_child_append (adaptor, object, + adaptor->priv->internal_children, + &children); return children; } @@ -2306,29 +2367,6 @@ gwa_set_signals_from_node (GladeWidgetAdaptor *adaptor, } } -static GladeInternalChild * -gwa_internal_child_find (GList *list, gchar *name) -{ - GList *l; - - for (l = list; l; l = g_list_next (l)) - { - GladeInternalChild *data = l->data; - - if (strcmp (data->name, name) == 0) - return data; - - if (data->children) - { - GladeInternalChild *child; - if ((child = gwa_internal_child_find (data->children, name))) - return child; - } - } - - return NULL; -} - static GList * gwa_internal_children_update_from_node (GList *internal_children, GladeXmlNode *node) |