[gnome-software: 1/3] shell: Activate the correct back button




commit 01f78e21ff66a56f0836ea5c5c89c49710992550
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Mar 1 13:55:02 2022 +0100

    shell: Activate the correct back button
    
    This makes the Alt+Left key binding and the "go back" mouse gestures
    activate the correct back button instead of both (contrary to what the
    comments say).

 src/gs-shell.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index ec15c3f13..d8d9254e1 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -1000,6 +1000,17 @@ search_bar_search_mode_enabled_changed_cb (GtkSearchBar *search_bar,
                gs_shell_go_back (shell);
 }
 
+static void
+go_back (GsShell *shell)
+{
+       if (adw_leaflet_get_adjacent_child (shell->details_leaflet,
+                                           ADW_NAVIGATION_DIRECTION_BACK)) {
+               gtk_widget_activate (shell->button_back2);
+       } else {
+               gtk_widget_activate (shell->button_back);
+       }
+}
+
 static gboolean
 window_key_pressed_cb (GtkEventControllerKey *key_controller,
                        guint                  keyval,
@@ -1012,9 +1023,7 @@ window_key_pressed_cb (GtkEventControllerKey *key_controller,
        if ((!is_rtl && state == GDK_ALT_MASK && keyval == GDK_KEY_Left) ||
            (is_rtl && state == GDK_ALT_MASK && keyval == GDK_KEY_Right) ||
            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);
+               go_back (shell);
                return GDK_EVENT_STOP;
        }
 
@@ -1028,9 +1037,7 @@ window_button_pressed_cb (GtkGestureClick *click_gesture,
                           gdouble          y,
                           GsShell         *shell)
 {
-       /* GTK will only actually activate the one which is visible */
-       gtk_widget_activate (shell->button_back);
-       gtk_widget_activate (shell->button_back2);
+       go_back (shell);
 
        gtk_gesture_set_state (GTK_GESTURE (click_gesture), GTK_EVENT_SEQUENCE_CLAIMED);
 }


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