[gnome-builder/wip/chergert/shortcuts: 22/24] shortcuts: update window title when stack child changes



commit eecd5e7af7df00f59d447e96cf440d7b9835217e
Author: Christian Hergert <christian hergert me>
Date:   Sat Aug 29 00:16:17 2015 -0700

    shortcuts: update window title when stack child changes

 src/keybindings/gb-shortcuts-window.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/keybindings/gb-shortcuts-window.c b/src/keybindings/gb-shortcuts-window.c
index e43df20..2e3b2fe 100644
--- a/src/keybindings/gb-shortcuts-window.c
+++ b/src/keybindings/gb-shortcuts-window.c
@@ -417,6 +417,24 @@ gb_shortcuts_window__search_entry__changed (GbShortcutsWindow *self,
 }
 
 static void
+gb_shortcuts_window__stack__notify_visible_child (GbShortcutsWindow *self,
+                                                  GParamSpec        *pspec,
+                                                  GtkStack          *stack)
+{
+  g_autofree gchar *title = NULL;
+  GtkWidget *visible_child;
+
+  g_assert (GB_IS_SHORTCUTS_WINDOW (self));
+  g_assert (GTK_IS_STACK (stack));
+
+  visible_child = gtk_stack_get_visible_child (stack);
+  gtk_container_child_get (GTK_CONTAINER (stack), visible_child,
+                           "title", &title,
+                           NULL);
+  gtk_button_set_label (GTK_BUTTON (self->menu_button), title);
+}
+
+static void
 gb_shortcuts_window_constructed (GObject *object)
 {
   GbShortcutsWindow *self = (GbShortcutsWindow *)object;
@@ -468,4 +486,10 @@ gb_shortcuts_window_init (GbShortcutsWindow *self)
                            G_CALLBACK (gb_shortcuts_window__search_entry__changed),
                            self,
                            G_CONNECT_SWAPPED);
+
+  g_signal_connect_object (self->stack,
+                           "notify::visible-child",
+                           G_CALLBACK (gb_shortcuts_window__stack__notify_visible_child),
+                           self,
+                           G_CONNECT_SWAPPED);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]