diff options
author | Benjamin Otte <otte@redhat.com> | 2018-03-08 03:13:57 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2018-04-26 17:59:41 +0200 |
commit | 9c0acf62b47102e3b16b29839516f8528f5590d3 (patch) | |
tree | 0b8583dc2f6dd51aaac68569dad7da39da530a18 /gtk/gtknotebook.c | |
parent | 9af03fa602b8b0cd72572c64e2e8ed3e63ede03f (diff) | |
download | gtk+-9c0acf62b47102e3b16b29839516f8528f5590d3.tar.gz |
widget: Allow adding event controllers in ui files
Diffstat (limited to 'gtk/gtknotebook.c')
-rw-r--r-- | gtk/gtknotebook.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 57b554adb3..80abd55d56 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -1124,9 +1124,13 @@ gtk_notebook_init (GtkNotebook *notebook) GTK_STYLE_CLASS_FRAME); } +static GtkBuildableIface *parent_buildable_iface; + static void gtk_notebook_buildable_init (GtkBuildableIface *iface) { + parent_buildable_iface = g_type_interface_peek_parent (iface); + iface->add_child = gtk_notebook_buildable_add_child; } @@ -1138,31 +1142,38 @@ gtk_notebook_buildable_add_child (GtkBuildable *buildable, { GtkNotebook *notebook = GTK_NOTEBOOK (buildable); - if (type && strcmp (type, "tab") == 0) + if (GTK_IS_WIDGET (child)) { - GtkWidget * page; - - page = gtk_notebook_get_nth_page (notebook, -1); - /* To set the tab label widget, we must have already a child - * inside the tab container. */ - g_assert (page != NULL); - /* warn when Glade tries to overwrite label */ - if (gtk_notebook_get_tab_label (notebook, page)) - g_warning ("Overriding tab label for notebook"); - gtk_notebook_set_tab_label (notebook, page, GTK_WIDGET (child)); - } - else if (type && strcmp (type, "action-start") == 0) - { - gtk_notebook_set_action_widget (notebook, GTK_WIDGET (child), GTK_PACK_START); + if (type && strcmp (type, "tab") == 0) + { + GtkWidget * page; + + page = gtk_notebook_get_nth_page (notebook, -1); + /* To set the tab label widget, we must have already a child + * inside the tab container. */ + g_assert (page != NULL); + /* warn when Glade tries to overwrite label */ + if (gtk_notebook_get_tab_label (notebook, page)) + g_warning ("Overriding tab label for notebook"); + gtk_notebook_set_tab_label (notebook, page, GTK_WIDGET (child)); + } + else if (type && strcmp (type, "action-start") == 0) + { + gtk_notebook_set_action_widget (notebook, GTK_WIDGET (child), GTK_PACK_START); + } + else if (type && strcmp (type, "action-end") == 0) + { + gtk_notebook_set_action_widget (notebook, GTK_WIDGET (child), GTK_PACK_END); + } + else if (!type) + gtk_notebook_append_page (notebook, GTK_WIDGET (child), NULL); + else + GTK_BUILDER_WARN_INVALID_CHILD_TYPE (notebook, type); } - else if (type && strcmp (type, "action-end") == 0) + else { - gtk_notebook_set_action_widget (notebook, GTK_WIDGET (child), GTK_PACK_END); + parent_buildable_iface->add_child (buildable, builder, child, type); } - else if (!type) - gtk_notebook_append_page (notebook, GTK_WIDGET (child), NULL); - else - GTK_BUILDER_WARN_INVALID_CHILD_TYPE (notebook, type); } static gboolean |