summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2018-08-01 00:35:55 +0200
committerlukefromdc <[email protected]>2018-08-01 14:46:54 -0400
commitc455418207877b4f7f84e86bbdfbd4c667ae8221 (patch)
treeaaad2148623b67476fc4eee66ad3abf02c2175b9
parente740a981b0be879321e5b3837332712d8231b400 (diff)
downloadcaja-c455418207877b4f7f84e86bbdfbd4c667ae8221.tar.bz2
caja-c455418207877b4f7f84e86bbdfbd4c667ae8221.tar.xz
add the ability to switch tabs using [ctrl+tab] and [ctrl+shift+tab]
If true the gsettings key "ctrl-tab-switch-tabs" into "org.mate.caja.preferences" Closes https://github.com/mate-desktop/caja/issues/768
-rw-r--r--libcaja-private/org.mate.caja.gschema.xml5
-rw-r--r--src/caja-navigation-window.c46
2 files changed, 51 insertions, 0 deletions
diff --git a/libcaja-private/org.mate.caja.gschema.xml b/libcaja-private/org.mate.caja.gschema.xml
index d240ae9a..a0108880 100644
--- a/libcaja-private/org.mate.caja.gschema.xml
+++ b/libcaja-private/org.mate.caja.gschema.xml
@@ -76,6 +76,11 @@
<summary>Where to position newly open tabs in browser windows.</summary>
<description>If set to "after-current-tab", then new tabs are inserted after the current tab. If set to "end", then new tabs are appended to the end of the tab list.</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 ability to switch tabs using [ctrl + tab] and [ctrl + shift + tab].</description>
+ </key>
<key name="exit-with-last-window" type="b">
<default>false</default>
<summary>Caja will exit when last window destroyed.</summary>
diff --git a/src/caja-navigation-window.c b/src/caja-navigation-window.c
index a21e1595..57d5e425 100644
--- a/src/caja-navigation-window.c
+++ b/src/caja-navigation-window.c
@@ -520,6 +520,52 @@ caja_navigation_window_key_press_event (GtkWidget *widget,
window = CAJA_NAVIGATION_WINDOW (widget);
+ if (event->state & GDK_CONTROL_MASK)
+ {
+ GSettings *settings = g_settings_new ("org.mate.caja.preferences");
+ gboolean handled = FALSE;
+
+ if (g_settings_get_boolean (settings, "ctrl-tab-switch-tabs"))
+ {
+ CajaWindow *cajawin;
+ CajaWindowSlot *slot;
+ CajaNavigationWindowPane *pane;
+ CajaNotebook *cajanotebook;
+ GtkNotebook *notebook;
+ int pages;
+ int page_num;
+
+ cajawin = CAJA_WINDOW (window);
+ slot = caja_window_get_active_slot (cajawin);
+ pane = CAJA_NAVIGATION_WINDOW_PANE (slot->pane);
+ cajanotebook = CAJA_NOTEBOOK (pane->notebook);
+ notebook = GTK_NOTEBOOK (cajanotebook);
+ pages = gtk_notebook_get_n_pages (notebook);
+ 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));
+ handled = 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);
+ handled = TRUE;
+ }
+ }
+ g_object_unref (settings);
+
+ if (handled)
+ return TRUE;
+ }
+
for (i = 0; i < G_N_ELEMENTS (extra_navigation_window_keybindings); i++)
{
if (extra_navigation_window_keybindings[i].keyval == event->keyval)