[epiphany] Support Ctrl+Tab in location entry



commit 925c259014ec035c0bca03cbe795fc736c949ead
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Sun Jan 19 15:05:23 2020 +0100

    Support Ctrl+Tab in location entry
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/1051

 src/ephy-header-bar.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)
---
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index e637abf66..12849de44 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -28,6 +28,7 @@
 #include "ephy-embed-utils.h"
 #include "ephy-flatpak-utils.h"
 #include "ephy-location-entry.h"
+#include "ephy-notebook.h"
 #include "ephy-shell.h"
 #include "ephy-title-box.h"
 #include "ephy-title-widget.h"
@@ -157,6 +158,36 @@ update_revealer_visibility (GtkRevealer *revealer)
                           gtk_revealer_get_child_revealed (revealer));
 }
 
+static void
+handle_primary_tab_key (GtkWidget *widget,
+                        gpointer   user_data)
+{
+  EphyHeaderBar *header_bar = EPHY_HEADER_BAR (user_data);
+  GtkWidget *entry = ephy_location_entry_get_entry (EPHY_LOCATION_ENTRY (header_bar->title_widget));
+  GtkWidget *nb;
+
+  nb = ephy_window_get_notebook (header_bar->window);
+  g_assert (nb != NULL);
+
+  ephy_notebook_next_page (EPHY_NOTEBOOK (nb));
+  gtk_widget_grab_focus (entry);
+}
+
+static void
+handle_primary_iso_tab_key (GtkWidget *widget,
+                            gpointer   user_data)
+{
+  EphyHeaderBar *header_bar = EPHY_HEADER_BAR (user_data);
+  GtkWidget *entry = ephy_location_entry_get_entry (EPHY_LOCATION_ENTRY (header_bar->title_widget));
+  GtkWidget *nb;
+
+  nb = ephy_window_get_notebook (header_bar->window);
+  g_assert (nb != NULL);
+
+  ephy_notebook_prev_page (EPHY_NOTEBOOK (nb));
+  gtk_widget_grab_focus (entry);
+}
+
 static void
 ephy_header_bar_constructed (GObject *object)
 {
@@ -195,8 +226,30 @@ ephy_header_bar_constructed (GObject *object)
   /* Title widget (location entry or title box) */
   if (ephy_embed_shell_get_mode (embed_shell) == EPHY_EMBED_SHELL_MODE_APPLICATION)
     header_bar->title_widget = EPHY_TITLE_WIDGET (ephy_title_box_new ());
-  else
+  else {
+    DzlShortcutController *controller;
+    GtkWidget *entry;
+
     header_bar->title_widget = EPHY_TITLE_WIDGET (ephy_location_entry_new ());
+    entry = ephy_location_entry_get_entry (EPHY_LOCATION_ENTRY (header_bar->title_widget));
+    controller = dzl_shortcut_controller_find (entry);
+
+    dzl_shortcut_controller_add_command_callback (controller,
+                                                  "org.gnome.Epiphany.next-tab-pages",
+                                                  "<Primary>Tab",
+                                                  DZL_SHORTCUT_PHASE_DISPATCH,
+                                                  handle_primary_tab_key,
+                                                  header_bar,
+                                                  NULL);
+
+    dzl_shortcut_controller_add_command_callback (controller,
+                                                  "org.gnome.Epiphany.prev-tab-pages",
+                                                  "<Primary>ISO_Left_Tab",
+                                                  DZL_SHORTCUT_PHASE_DISPATCH,
+                                                  handle_primary_iso_tab_key,
+                                                  header_bar,
+                                                  NULL);
+  }
 
   if (is_desktop_pantheon ()) {
     /* Use a full-width entry on Pantheon */


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