diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-04-27 22:59:20 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-04-27 23:09:24 -0400 |
commit | 83245abfea65e666a3664a1dc023203276ae3e4a (patch) | |
tree | e380e0da429b5794c0ef63765f4fc26f7a5631d5 /gtk/gtkcontainer.c | |
parent | 5bd0ec6381f7c2412e540d4b23c1152081bb5292 (diff) | |
download | gtk+-83245abfea65e666a3664a1dc023203276ae3e4a.tar.gz |
GtkContainer: Use _gtk_builder_lookup_object
Diffstat (limited to 'gtk/gtkcontainer.c')
-rw-r--r-- | gtk/gtkcontainer.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 8ad3074f04..fcb8ed1b53 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -764,9 +764,27 @@ static const GMarkupParser packing_parser = typedef struct { + gchar *name; + gint line; + gint col; + } FocusChainWidget; + +static void +focus_chain_widget_free (gpointer data) +{ + FocusChainWidget *fcw = data; + + g_free (fcw->name); + g_free (fcw); +} + +typedef struct + { GSList *items; GObject *object; GtkBuilder *builder; + gint line; + gint col; } FocusChainData; static void @@ -782,6 +800,7 @@ focus_chain_start_element (GMarkupParseContext *context, if (strcmp (element_name, "widget") == 0) { const gchar *name; + FocusChainWidget *fcw; if (!_gtk_builder_check_parent (data->builder, context, "focus-chain", error)) return; @@ -794,7 +813,10 @@ focus_chain_start_element (GMarkupParseContext *context, return; } - data->items = g_slist_prepend (data->items, g_strdup (name)); + fcw = g_new (FocusChainWidget, 1); + fcw->name = g_strdup (name); + g_markup_parse_context_get_position (context, &fcw->line, &fcw->col); + data->items = g_slist_prepend (data->items, fcw); } else if (strcmp (element_name, "focus-chain") == 0) { @@ -897,6 +919,7 @@ gtk_container_buildable_custom_finished (GtkBuildable *buildable, if (strcmp (tagname, "focus-chain") == 0) { FocusChainData *data = (FocusChainData*)parser_data; + FocusChainWidget *fcw; GSList *l; GList *chain; GObject *object; @@ -904,21 +927,17 @@ gtk_container_buildable_custom_finished (GtkBuildable *buildable, chain = NULL; for (l = data->items; l; l = l->next) { - object = gtk_builder_get_object (builder, l->data); + fcw = l->data; + object = _gtk_builder_lookup_object (builder, fcw->name, fcw->line, fcw->col); if (!object) - { - g_warning ("Unknown object %s specified in focus-chain for %s", - (const gchar*)l->data, - gtk_buildable_get_name (GTK_BUILDABLE (data->object))); - continue; - } + continue; chain = g_list_prepend (chain, object); } gtk_container_set_focus_chain (GTK_CONTAINER (data->object), chain); g_list_free (chain); - g_slist_free_full (data->items, g_free); + g_slist_free_full (data->items, focus_chain_widget_free); g_slice_free (FocusChainData, data); return; |