[gnome-software: 2/5] shell: Switch to the search mode with Ctrl+F




commit 18e8e797d1e74dbcb148f421e7b2546d2fa64f3f
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Aug 5 13:32:27 2021 +0200

    shell: Switch to the search mode with Ctrl+F
    
    When in a mode without a search button, switch directly to the search
    page to avoid showing the search bar without a search button.

 src/gs-shell.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index cf6d7097b..a0733656b 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -906,8 +906,24 @@ window_keypress_handler (GtkWidget *window, GdkEvent *event, GsShell *shell)
                if ((e->state & GDK_CONTROL_MASK) > 0 &&
                    e->keyval == GDK_KEY_f) {
                        if (!hdy_search_bar_get_search_mode (HDY_SEARCH_BAR (shell->search_bar))) {
+                               GsShellMode mode = gs_shell_get_mode (shell);
+
                                hdy_search_bar_set_search_mode (HDY_SEARCH_BAR (shell->search_bar), TRUE);
                                gtk_widget_grab_focus (shell->entry_search);
+
+                               /* If the mode doesn't have a search button,
+                                * switch to the search page right away,
+                                * otherwise we would show the search bar
+                                * without a button to toggle it. */
+                               switch (mode) {
+                               case GS_SHELL_MODE_OVERVIEW:
+                               case GS_SHELL_MODE_INSTALLED:
+                               case GS_SHELL_MODE_SEARCH:
+                                       break;
+                               default:
+                                       gs_shell_show_search (shell, "");
+                                       break;
+                               }
                        } else {
                                hdy_search_bar_set_search_mode (HDY_SEARCH_BAR (shell->search_bar), FALSE);
                        }


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