Skip to content

Commit c455418

Browse files
sc0wlukefromdc
authored andcommitted
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 #768
1 parent e740a98 commit c455418

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

‎libcaja-private/org.mate.caja.gschema.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@
7676
<summary>Where to position newly open tabs in browser windows.</summary>
7777
<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>
7878
</key>
79+
<key name="ctrl-tab-switch-tabs" type="b">
80+
<default>false</default>
81+
<summary>Switch tabs with [ctrl] + [tab]</summary>
82+
<description>If true, it enables the ability to switch tabs using [ctrl + tab] and [ctrl + shift + tab].</description>
83+
</key>
7984
<key name="exit-with-last-window" type="b">
8085
<default>false</default>
8186
<summary>Caja will exit when last window destroyed.</summary>

‎src/caja-navigation-window.c‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,52 @@ caja_navigation_window_key_press_event (GtkWidget *widget,
520520

521521
window = CAJA_NAVIGATION_WINDOW (widget);
522522

523+
if (event->state & GDK_CONTROL_MASK)
524+
{
525+
GSettings *settings = g_settings_new ("org.mate.caja.preferences");
526+
gboolean handled = FALSE;
527+
528+
if (g_settings_get_boolean (settings, "ctrl-tab-switch-tabs"))
529+
{
530+
CajaWindow *cajawin;
531+
CajaWindowSlot *slot;
532+
CajaNavigationWindowPane *pane;
533+
CajaNotebook *cajanotebook;
534+
GtkNotebook *notebook;
535+
int pages;
536+
int page_num;
537+
538+
cajawin = CAJA_WINDOW (window);
539+
slot = caja_window_get_active_slot (cajawin);
540+
pane = CAJA_NAVIGATION_WINDOW_PANE (slot->pane);
541+
cajanotebook = CAJA_NOTEBOOK (pane->notebook);
542+
notebook = GTK_NOTEBOOK (cajanotebook);
543+
pages = gtk_notebook_get_n_pages (notebook);
544+
page_num = gtk_notebook_get_current_page (notebook);
545+
546+
if (event->keyval == GDK_KEY_ISO_Left_Tab)
547+
{
548+
if (page_num != 0)
549+
gtk_notebook_prev_page (notebook);
550+
else
551+
gtk_notebook_set_current_page (notebook, (pages - 1));
552+
handled = TRUE;
553+
}
554+
if (event->keyval == GDK_KEY_Tab)
555+
{
556+
if (page_num != (pages -1))
557+
gtk_notebook_next_page (notebook);
558+
else
559+
gtk_notebook_set_current_page (notebook, 0);
560+
handled = TRUE;
561+
}
562+
}
563+
g_object_unref (settings);
564+
565+
if (handled)
566+
return TRUE;
567+
}
568+
523569
for (i = 0; i < G_N_ELEMENTS (extra_navigation_window_keybindings); i++)
524570
{
525571
if (extra_navigation_window_keybindings[i].keyval == event->keyval)

0 commit comments

Comments
 (0)