[recipes] Avoid ending up on an empty page
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Avoid ending up on an empty page
- Date: Mon, 16 Jan 2017 21:18:56 +0000 (UTC)
commit 2bb537bd48b2dea3830147c03818ce9e5c606aca
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 16 16:17:49 2017 -0500
Avoid ending up on an empty page
When a search is stopped by toggling the search button, we should
go back to where we came from, like we already do when search is
stopped with Esc.
https://bugzilla.gnome.org/show_bug.cgi?id=777297
src/gr-window.c | 14 ++++++++++++++
src/gr-window.ui | 1 +
2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-window.c b/src/gr-window.c
index 0af6b44..b6c9bc5 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -180,6 +180,19 @@ stop_search (GrWindow *window)
}
static void
+search_mode_changed (GrWindow *window)
+{
+ const char *visible;
+
+ visible = gtk_stack_get_visible_child_name (GTK_STACK (window->main_stack));
+
+ if (!gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (window->search_bar)) &&
+ strcmp (visible, "search") == 0) {
+ stop_search (window);
+ }
+}
+
+static void
switch_to_search (GrWindow *window)
{
gtk_stack_set_visible_child_name (GTK_STACK (window->header_start_stack), "main");
@@ -457,6 +470,7 @@ gr_window_class_init (GrWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, hide_or_show_header_end_stack);
gtk_widget_class_bind_template_callback (widget_class, search_changed);
gtk_widget_class_bind_template_callback (widget_class, stop_search);
+ gtk_widget_class_bind_template_callback (widget_class, search_mode_changed);
gtk_widget_class_bind_template_callback (widget_class, window_keypress_handler);
gtk_widget_class_bind_template_callback (widget_class, window_mapped_handler);
gtk_widget_class_bind_template_callback (widget_class, do_undo);
diff --git a/src/gr-window.ui b/src/gr-window.ui
index c7744ee..b29f771 100644
--- a/src/gr-window.ui
+++ b/src/gr-window.ui
@@ -159,6 +159,7 @@
<property name="search-mode-enabled" bind-source="search_button" bind-property="active"
bind-flags="bidirectional"/>
<signal name="changed" handler="search_changed" swapped="yes"/>
<signal name="cancel" handler="stop_search" swapped="yes"/>
+ <signal name="notify::search-mode-enabled" handler="search_mode_changed" swapped="yes"/>
</object>
</child>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]