[gnome-software: 3/4] gs-shell: Fix keyboard shortcut for back button




commit 173147fd21e08347893be46926fa7ef8af37ed72
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Aug 17 11:07:52 2021 +0100

    gs-shell: Fix keyboard shortcut for back button
    
    Since rearranging the header bar, there are actually two back buttons,
    shown in different header bars at different times.
    
    The key press handling code was only activating one of them, so pressing
    Alt+Left (for example) worked when on a category page, but not when on a
    details page.
    
    Activate both back buttons so that it works on all pages. GTK will
    ensure that only the back button which is visible is actually activated.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 src/gs-shell.c  | 6 ++++++
 src/gs-shell.ui | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 5038e88df..d81657d38 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -94,6 +94,7 @@ struct _GsShell
        GtkWidget               *entry_search;
        GtkWidget               *search_bar;
        GtkWidget               *button_back;
+       GtkWidget               *button_back2;
        GtkWidget               *notification_event;
        GtkWidget               *button_events_sources;
        GtkWidget               *button_events_no_space;
@@ -981,7 +982,9 @@ window_key_press_event (GtkWidget *win, GdkEventKey *event, GsShell *shell)
        if ((!is_rtl && state == GDK_MOD1_MASK && event->keyval == GDK_KEY_Left) ||
            (is_rtl && state == GDK_MOD1_MASK && event->keyval == GDK_KEY_Right) ||
            event->keyval == GDK_KEY_Back) {
+               /* GTK will only actually activate the one which is visible */
                gtk_widget_activate (shell->button_back);
+               gtk_widget_activate (shell->button_back2);
                return GDK_EVENT_STOP;
        }
 
@@ -995,7 +998,9 @@ window_button_press_event (GtkWidget *win, GdkEventButton *event, GsShell *shell
        if (event->button != 8)
                return GDK_EVENT_PROPAGATE;
 
+       /* GTK will only actually activate the one which is visible */
        gtk_widget_activate (shell->button_back);
+       gtk_widget_activate (shell->button_back2);
        return GDK_EVENT_STOP;
 }
 
@@ -2566,6 +2571,7 @@ gs_shell_class_init (GsShellClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsShell, entry_search);
        gtk_widget_class_bind_template_child (widget_class, GsShell, search_bar);
        gtk_widget_class_bind_template_child (widget_class, GsShell, button_back);
+       gtk_widget_class_bind_template_child (widget_class, GsShell, button_back2);
        gtk_widget_class_bind_template_child (widget_class, GsShell, notification_event);
        gtk_widget_class_bind_template_child (widget_class, GsShell, button_events_sources);
        gtk_widget_class_bind_template_child (widget_class, GsShell, button_events_no_space);
diff --git a/src/gs-shell.ui b/src/gs-shell.ui
index 45f3dd4a7..5b18e3364 100644
--- a/src/gs-shell.ui
+++ b/src/gs-shell.ui
@@ -455,7 +455,7 @@
                         <property name="show-close-button">True</property>
                         <property name="title" bind-source="details_page" bind-property="title" 
bind-flags="sync-create"/>
                         <child>
-                          <object class="GtkButton">
+                          <object class="GtkButton" id="button_back2">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <signal name="clicked" handler="gs_shell_details_back_button_cb"/>


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