[recipes] window: Listen for shopping title changes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] window: Listen for shopping title changes
- Date: Mon, 16 Jan 2017 13:35:33 +0000 (UTC)
commit 88d7439d36941587113f9129cfadb9cf30bf5a03
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 16 08:34:51 2017 -0500
window: Listen for shopping title changes
...and update the title, when appropriate.
https://bugzilla.gnome.org/show_bug.cgi?id=777301
src/gr-window.c | 18 +++++++++++++++++-
src/gr-window.ui | 4 +++-
2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/gr-window.c b/src/gr-window.c
index 4611e46..3740d7b 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -404,6 +404,21 @@ gr_window_offer_undelete (GrWindow *window,
}
static void
+shopping_title_changed (GrWindow *window)
+{
+ const char *page;
+
+ page = gtk_stack_get_visible_child_name (GTK_STACK (window->main_stack));
+
+ if (strcmp (page, "shopping") == 0) {
+ g_autofree char *title = NULL;
+
+ g_object_get (window->shopping_page, "title", &title, NULL);
+ gtk_window_set_title (GTK_WINDOW (window), title);
+ }
+}
+
+static void
gr_window_class_init (GrWindowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -444,6 +459,7 @@ gr_window_class_init (GrWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, window_mapped_handler);
gtk_widget_class_bind_template_callback (widget_class, do_undo);
gtk_widget_class_bind_template_callback (widget_class, close_undo);
+ gtk_widget_class_bind_template_callback (widget_class, shopping_title_changed);
}
static void
@@ -640,13 +656,13 @@ gr_window_show_shopping (GrWindow *window)
save_back_entry (window);
gtk_header_bar_set_title (GTK_HEADER_BAR (window->header), _("Cook it later"));
- gr_shopping_page_populate (GR_SHOPPING_PAGE (window->shopping_page));
gtk_stack_set_visible_child_name (GTK_STACK (window->header_start_stack), "back");
gtk_stack_set_visible_child_name (GTK_STACK (window->header_title_stack), "title");
gtk_stack_set_visible_child_name (GTK_STACK (window->header_end_stack), "list");
gtk_stack_set_visible_child_name (GTK_STACK (window->main_stack), "shopping");
+ gr_shopping_page_populate (GR_SHOPPING_PAGE (window->shopping_page));
}
void
diff --git a/src/gr-window.ui b/src/gr-window.ui
index 2c4afbf..d3bc755 100644
--- a/src/gr-window.ui
+++ b/src/gr-window.ui
@@ -237,7 +237,9 @@
</packing>
</child>
<child>
- <object class="GrShoppingPage" id="shopping_page"/>
+ <object class="GrShoppingPage" id="shopping_page">
+ <signal name="notify::title" handler="shopping_title_changed" swapped="yes"/>
+ </object>
<packing>
<property name="name">shopping</property>
</packing>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]