[epiphany] ephy-window: execute Ctrl+Tab shortcuts regardless of focused widget



commit 41be855177371acf35cea29653b76492917be4e0
Author: Yetizone <andreii lisita gmail com>
Date:   Tue Apr 7 15:51:27 2020 +0300

    ephy-window: execute Ctrl+Tab shortcuts regardless of focused widget
    
    If the focused widget was the location entry or the WebKitWebView then
    Ctrl+Tab would be handled properly, but if there was another widget focused
    for example the hamburger button then the first Ctrl+Tab would not be handled.
    
    Instead what would happen was that the focused widget would be changed until
    it would be the location entry and only then Ctrl+Tab would be handled properly.
    
    https://gitlab.gnome.org/GNOME/epiphany/issues/911

 src/ephy-window.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 76e976895..ccb4dbe5d 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2553,6 +2553,13 @@ tab_accels_update (EphyWindow *window)
   g_strfreev (actions);
 }
 
+static void
+accel_cb_tabs_next (GtkWidget *widget,
+                    gpointer   user_data)
+{
+  window_cmd_tabs_next (NULL, NULL, user_data);
+}
+
 #define TAB_ACCELS_N 10
 
 static void
@@ -2561,6 +2568,7 @@ setup_tab_accels (EphyWindow *window)
   GActionGroup *action_group;
   GApplication *app;
   guint i;
+  DzlShortcutController *controller = dzl_shortcut_controller_find (GTK_WIDGET (window));
 
   action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "tab");
   app = g_application_get_default ();
@@ -2590,6 +2598,26 @@ setup_tab_accels (EphyWindow *window)
     g_free (action_name);
     g_free (action_name_with_tab);
   }
+
+  /* We have to setup the Ctrl + Tab shortcut in the window's ShortcutController
+   * because otherwise libdazzle would handle this shortcut by changing
+   * the focused widget instead of switching between the browser tabs
+   */
+  dzl_shortcut_controller_add_command_callback (controller,
+                                                "org.gnome.Epiphany.next-tab-pages",
+                                                "<Primary>Tab",
+                                                DZL_SHORTCUT_PHASE_DISPATCH,
+                                                accel_cb_tabs_next,
+                                                window,
+                                                NULL);
+
+  dzl_shortcut_controller_add_command_callback (controller,
+                                                "org.gnome.Epiphany.prev-tab-pages",
+                                                "<Primary>ISO_Left_Tab",
+                                                DZL_SHORTCUT_PHASE_DISPATCH,
+                                                accel_cb_tabs_next,
+                                                window,
+                                                NULL);
 }
 
 static gboolean


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