[Xfce4-commits] [apps/xfce4-terminal] 01/01: Enable Ctrl+(Shift)+Tab as Next/Prev Tab shortcuts

noreply at xfce.org noreply at xfce.org
Sat Mar 2 17:59:47 CET 2019


This is an automated email from the git hooks/post-receive script.

f   2   4   0   4       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-terminal.

commit 205c8ed4223655f2a46e601edc013e2d205a2a21
Author: Igor <f2404 at yandex.ru>
Date:   Sat Mar 2 11:57:15 2019 -0500

    Enable Ctrl+(Shift)+Tab as Next/Prev Tab shortcuts
    
    Add a hidden option MiscUseTabKeyToCycleTabs (defaulted to FALSE) to enable
    Ctrl+Tab/Ctrl+Shift+Tab as Next/Prev Tab shortcuts, respectively.
    
    Fixes bug #15092
---
 terminal/terminal-preferences.c | 11 +++++++++++
 terminal/terminal-window.c      | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c
index aa7dfb2..b0d1f08 100644
--- a/terminal/terminal-preferences.c
+++ b/terminal/terminal-preferences.c
@@ -114,6 +114,7 @@ enum
   PROP_MISC_SLIM_TABS,
   PROP_MISC_NEW_TAB_ADJACENT,
   PROP_MISC_SEARCH_DIALOG_OPACITY,
+  PROP_MISC_USE_TAB_KEY_TO_CYCLE_TABS,
   PROP_SCROLLING_BAR,
   PROP_SCROLLING_LINES,
   PROP_SCROLLING_ON_OUTPUT,
@@ -1070,6 +1071,16 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
                          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
+   * TerminalPreferences:misc-use-tab-key-to-cycle-tabs:
+   **/
+  preferences_props[PROP_MISC_USE_TAB_KEY_TO_CYCLE_TABS] =
+      g_param_spec_boolean ("misc-use-tab-key-to-cycle-tabs",
+                            NULL,
+                            "MiscUseTabKeyToCycleTabs",
+                            FALSE,
+                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+  /**
    * TerminalPreferences:scrolling-bar:
    **/
   preferences_props[PROP_SCROLLING_BAR] =
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index e1b927e..4b4a2e3 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -111,6 +111,8 @@ static gboolean     terminal_window_map_event                     (GtkWidget
                                                                    GdkEventAny         *event);
 static gboolean     terminal_window_focus_in_event                (GtkWidget           *widget,
                                                                    GdkEventFocus       *event);
+static gboolean     terminal_window_key_press_event               (GtkWidget           *widget,
+                                                                   GdkEventKey         *event);
 static gint         terminal_window_confirm_close                 (TerminalScreen      *screen,
                                                                    TerminalWindow      *window);
 static void         terminal_window_size_push                     (TerminalWindow      *window);
@@ -401,6 +403,7 @@ terminal_window_class_init (TerminalWindowClass *klass)
   gtkwidget_class->scroll_event = terminal_window_scroll_event;
   gtkwidget_class->map_event = terminal_window_map_event;
   gtkwidget_class->focus_in_event = terminal_window_focus_in_event;
+  gtkwidget_class->key_press_event = terminal_window_key_press_event;
 
   /**
    * TerminalWindow::new-window
@@ -769,6 +772,36 @@ terminal_window_focus_in_event (GtkWidget     *widget,
 
 
 
+static gboolean
+terminal_window_key_press_event (GtkWidget   *widget,
+                                 GdkEventKey *event)
+{
+  TerminalWindow *window = TERMINAL_WINDOW (widget);
+  const guint     modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
+  gboolean        use_tab;
+
+  /* whether to use Ctrl+Tab/Ctrl+Shift+Tab as Next/Prev Tab shortcuts, respectively */
+  g_object_get (G_OBJECT (window->priv->preferences), "misc-use-tab-key-to-cycle-tabs", &use_tab, NULL);
+
+  if (G_UNLIKELY (use_tab && (event->keyval == GDK_KEY_Tab || event->keyval == GDK_KEY_ISO_Left_Tab)))
+    {
+      if (modifiers == (GDK_CONTROL_MASK | GDK_SHIFT_MASK))
+        {
+          terminal_window_action_prev_tab (NULL, window);
+          return TRUE;
+        }
+      else if (modifiers == GDK_CONTROL_MASK)
+        {
+          terminal_window_action_next_tab (NULL, window);
+          return TRUE;
+        }
+    }
+
+  return (*GTK_WIDGET_CLASS (terminal_window_parent_class)->key_press_event) (widget, event);
+}
+
+
+
 static gint
 terminal_window_confirm_close (TerminalScreen *screen,
                                TerminalWindow *window)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list