diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-11-20 14:59:56 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-11-20 15:31:00 -0500 |
commit | 159a13a065bf1c2ee490cca6c897ce47949ccf7c (patch) | |
tree | ae8b7d4d54580fd9721fa5cc95384a7312b2431b | |
parent | d75989a52b6e19aa53de3c8d08ae47c6441882ed (diff) | |
download | gtk+-159a13a065bf1c2ee490cca6c897ce47949ccf7c.tar.gz |
shortcuts window: More complete container implementation
To give glade a chance to work with GtkShortcutsWindow, the
container implementation needs to be a bit more complete.
-rw-r--r-- | gtk/gtkshortcutswindow.c | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/gtk/gtkshortcutswindow.c b/gtk/gtkshortcutswindow.c index 721fc483bd..2b3b7cd635 100644 --- a/gtk/gtkshortcutswindow.c +++ b/gtk/gtkshortcutswindow.c @@ -94,6 +94,7 @@ typedef struct GtkSearchBar *search_bar; GtkSearchEntry *search_entry; GtkHeaderBar *header_bar; + GtkWidget *main_box; GtkPopover *popover; GtkListBox *list_box; GtkBox *search_gestures; @@ -332,6 +333,52 @@ gtk_shortcuts_window_add (GtkContainer *container, } static void +gtk_shortcuts_window_remove (GtkContainer *container, + GtkWidget *widget) +{ + GtkShortcutsWindow *self = (GtkShortcutsWindow *)container; + GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); + + gtk_container_remove (GTK_CONTAINER (priv->stack), widget); +} + +static void +gtk_shortcuts_window_forall (GtkContainer *container, + gboolean include_internal, + GtkCallback callback, + gpointer callback_data) +{ + GtkShortcutsWindow *self = (GtkShortcutsWindow *)container; + GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); + + if (include_internal) + { + callback (GTK_WIDGET (priv->header_bar), callback_data); + callback (GTK_WIDGET (priv->main_box), callback_data); + } + + if (priv->stack) + { + GList *children, *l; + GtkWidget *search; + GtkWidget *empty; + + search = gtk_stack_get_child_by_name (GTK_STACK (priv->stack), "internal-search"); + empty = gtk_stack_get_child_by_name (GTK_STACK (priv->stack), "no-search-results"); + children = gtk_container_get_children (GTK_CONTAINER (priv->stack)); + for (l = children; l; l = l->next) + { + GtkWidget *child = l->data; + + if (include_internal || + (child != search && child != empty)) + callback (child, callback_data); + } + g_list_free (children); + } +} + +static void gtk_shortcuts_window_set_view_name (GtkShortcutsWindow *self, const gchar *view_name) { @@ -605,7 +652,9 @@ gtk_shortcuts_window_class_init (GtkShortcutsWindowClass *klass) widget_class->unmap = gtk_shortcuts_window_unmap; container_class->add = gtk_shortcuts_window_add; + container_class->remove = gtk_shortcuts_window_remove; container_class->child_type = gtk_shortcuts_window_child_type; + container_class->forall = gtk_shortcuts_window_forall; klass->close = gtk_shortcuts_window_close; klass->search = gtk_shortcuts_window_search; @@ -700,7 +749,6 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self) { GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); GtkToggleButton *search_button; - GtkBox *main_box; GtkBox *menu_box; GtkBox *box; GtkArrow *arrow; @@ -736,11 +784,11 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self) NULL); gtk_container_add (GTK_CONTAINER (priv->header_bar), GTK_WIDGET (search_button)); - main_box = g_object_new (GTK_TYPE_BOX, + priv->main_box = g_object_new (GTK_TYPE_BOX, "orientation", GTK_ORIENTATION_VERTICAL, "visible", TRUE, NULL); - GTK_CONTAINER_CLASS (gtk_shortcuts_window_parent_class)->add (GTK_CONTAINER (self), GTK_WIDGET (main_box)); + GTK_CONTAINER_CLASS (gtk_shortcuts_window_parent_class)->add (GTK_CONTAINER (self), GTK_WIDGET (priv->main_box)); priv->search_bar = g_object_new (GTK_TYPE_SEARCH_BAR, "visible", TRUE, @@ -748,7 +796,7 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self) g_object_bind_property (priv->search_bar, "search-mode-enabled", search_button, "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); - gtk_container_add (GTK_CONTAINER (main_box), GTK_WIDGET (priv->search_bar)); + gtk_container_add (GTK_CONTAINER (priv->main_box), GTK_WIDGET (priv->search_bar)); priv->stack = g_object_new (GTK_TYPE_STACK, "expand", TRUE, @@ -756,7 +804,7 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self) "transition-type", GTK_STACK_TRANSITION_TYPE_CROSSFADE, "visible", TRUE, NULL); - gtk_container_add (GTK_CONTAINER (main_box), GTK_WIDGET (priv->stack)); + gtk_container_add (GTK_CONTAINER (priv->main_box), GTK_WIDGET (priv->stack)); priv->title_stack = g_object_new (GTK_TYPE_STACK, "visible", TRUE, |