Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/tabs/wig-tab-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,18 @@ void wig_tab_list_set_active(WigTabList *self, WigTab *tab)
g_object_notify_by_pspec(G_OBJECT(self), props[PROP_ACTIVE_TAB]);
}

void wig_tab_switch_active(WigTabList *self, gint offset)
{
WigTab *tab = wig_tab_list_get_active(self);
guint idx = wig_tab_list_index_of(self, tab);
if (idx == GTK_INVALID_LIST_POSITION)
return;
guint n_tabs = wig_tab_list_get_n_tabs(self);
idx = (idx + n_tabs + (guint)offset) % n_tabs;
tab = wig_tab_list_get_nth(self, idx);
wig_tab_list_set_active(self, tab);
}

/* Returns: (transfer full): the selected tabs in list order. They are reffed so
* that callers can move or detach them while walking the result. */
GPtrArray *wig_tab_list_get_selected(WigTabList *self)
Expand Down
1 change: 1 addition & 0 deletions src/tabs/wig-tab-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ WigTab *wig_tab_list_get_by_id(WigTabList *self, guint id);

WigTab *wig_tab_list_get_active(WigTabList *self);
void wig_tab_list_set_active(WigTabList *self, WigTab *tab);
void wig_tab_switch_active(WigTabList *self, gint offset);

GSimpleActionGroup *wig_tab_list_get_action_group(WigTabList *self);

Expand Down
2 changes: 2 additions & 0 deletions src/wig-application.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,8 @@ static void wig_application_startup(GApplication *application)
{ "app.new-window", { "<Primary>n", NULL } },
{ "app.quit", { "<Primary>q", NULL } },
{ "win.close-tab", { "<Primary>w", NULL } },
{ "win.next-tab", { "<Primary>Page_Down", NULL } },
{ "win.prev-tab", { "<Primary>Page_Up", NULL } },
{ "win.reload", { "<Primary>r", "F5", NULL } },
{ "win.reload-bypass-cache", { "<Primary><Shift>r", "<Primary>F5", NULL } },
{ "win.toggle-fullscreen", { "F11", NULL } },
Expand Down
14 changes: 14 additions & 0 deletions src/wig-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,18 @@ static void wig_window_new_tab(GSimpleAction *action, GVariant *parameter, gpoin
gtk_widget_grab_focus(win->url_entry);
}

static void wig_window_next_tab(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
WigWindow *win = WIG_WINDOW(user_data);
wig_tab_switch_active(win->tab_list, 1);
}

static void wig_window_prev_tab(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
WigWindow *win = WIG_WINDOW(user_data);
wig_tab_switch_active(win->tab_list, -1);
}

static void wig_window_focus_entry(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
WigWindow *win = WIG_WINDOW(user_data);
Expand Down Expand Up @@ -731,6 +743,8 @@ static void wig_window_duplicate_active_tab(GSimpleAction *action, GVariant *par

static const GActionEntry actions[] = {
{ "new-tab", wig_window_new_tab },
{ "next-tab", wig_window_next_tab },
{ "prev-tab", wig_window_prev_tab },
{ "focus-entry", wig_window_focus_entry },
{ "find", wig_window_find },
{ "find-next", wig_window_find_next },
Expand Down
Loading