summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2017-11-10 00:40:58 +0100
committerraveit65 <[email protected]>2017-11-20 09:41:08 +0100
commit7ebc9d18b3abd2d1f3baa3a8e80b1fd9cb6e0621 (patch)
tree6868ce36688c1a07d39d2e4f07a0443671fb5b23 /src
parentca53774e9fcb7ab8fb4402ac09db5ed3f6489c21 (diff)
downloadmate-terminal-7ebc9d18b3abd2d1f3baa3a8e80b1fd9cb6e0621.tar.bz2
mate-terminal-7ebc9d18b3abd2d1f3baa3a8e80b1fd9cb6e0621.tar.xz
add the abbility to switch tabs using [ctrl+tab] and [ctrl+shift+tab]
If true the gsettings key "ctrl-tab-switch-tabs" into "org.mate.terminal.global" Closes https://github.com/mate-desktop/mate-terminal/issues/98
Diffstat (limited to 'src')
-rw-r--r--src/org.mate.terminal.gschema.xml.in5
-rw-r--r--src/terminal-window.c44
2 files changed, 49 insertions, 0 deletions
diff --git a/src/org.mate.terminal.gschema.xml.in b/src/org.mate.terminal.gschema.xml.in
index 0a45fc8..84efea2 100644
--- a/src/org.mate.terminal.gschema.xml.in
+++ b/src/org.mate.terminal.gschema.xml.in
@@ -74,6 +74,11 @@
<summary>Whether to ask for confirmation when closing terminal windows</summary>
<description>Whether to ask for confirmation when closing a terminal window which has more than one open tab.</description>
</key>
+ <key name="ctrl-tab-switch-tabs" type="b">
+ <default>false</default>
+ <summary>Switch tabs with [ctrl] + [tab]</summary>
+ <description>If true, it enables the abbility to switch tabs using [ctrl + tab] and [ctrl + shift + tab].</description>
+ </key>
</schema>
<schema id="org.mate.terminal.profiles" path="/org/mate/terminal/profiles/">
</schema>
diff --git a/src/terminal-window.c b/src/terminal-window.c
index db561b7..84fc65b 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -160,6 +160,9 @@ static gboolean terminal_window_focus_in_event (GtkWidget *widget,
static gboolean notebook_button_press_cb (GtkWidget *notebook,
GdkEventButton *event,
TerminalWindow *window);
+static gboolean window_key_press_cb (GtkWidget *notebook,
+ GdkEventKey *event,
+ TerminalWindow *window);
static gboolean notebook_popup_menu_cb (GtkWidget *notebook,
TerminalWindow *window);
static void notebook_page_selected_callback (GtkWidget *notebook,
@@ -2220,6 +2223,8 @@ terminal_window_init (TerminalWindow *window)
gtk_notebook_set_group_name (GTK_NOTEBOOK (priv->notebook), I_("mate-terminal-window"));
g_signal_connect (priv->notebook, "button-press-event",
G_CALLBACK (notebook_button_press_cb), window);
+ g_signal_connect (window, "key-press-event",
+ G_CALLBACK (window_key_press_cb), window);
g_signal_connect (priv->notebook, "popup-menu",
G_CALLBACK (notebook_popup_menu_cb), window);
g_signal_connect_after (priv->notebook, "switch-page",
@@ -2998,6 +3003,45 @@ notebook_button_press_cb (GtkWidget *widget,
}
static gboolean
+window_key_press_cb (GtkWidget *widget,
+ GdkEventKey *event,
+ TerminalWindow *window)
+{
+ GSettings *settings;
+
+ settings = g_settings_new ("org.mate.terminal.global");
+
+ if (g_settings_get_boolean (settings, "ctrl-tab-switch-tabs") &&
+ event->state & GDK_CONTROL_MASK)
+ {
+ TerminalWindowPrivate *priv = window->priv;
+ GtkNotebook *notebook = GTK_NOTEBOOK (priv->notebook);
+
+ int pages = gtk_notebook_get_n_pages (notebook);
+ int page_num = gtk_notebook_get_current_page (notebook);
+
+ if (event->keyval == GDK_KEY_ISO_Left_Tab)
+ {
+ if (page_num != 0)
+ gtk_notebook_prev_page (notebook);
+ else
+ gtk_notebook_set_current_page (notebook, (pages - 1));
+ return TRUE;
+ }
+
+ if (event->keyval == GDK_KEY_Tab)
+ {
+ if (page_num != (pages -1))
+ gtk_notebook_next_page (notebook);
+ else
+ gtk_notebook_set_current_page (notebook, 0);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static gboolean
notebook_popup_menu_cb (GtkWidget *widget,
TerminalWindow *window)
{