diff options
Diffstat (limited to 'src/window-commands.c')
-rw-r--r-- | src/window-commands.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/window-commands.c b/src/window-commands.c index 82906d361..177af0924 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -2359,6 +2359,62 @@ window_cmd_tabs_close (GSimpleAction *action, } void +window_cmd_tabs_close_left (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + EphyWindow *window = user_data; + GtkWidget *notebook; + EphyEmbed *embed; + int n_pages, current_page_no; + GSList *pages_to_close = NULL; + + notebook = ephy_window_get_notebook (window); + n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)); + current_page_no = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); + + for (int i = 0; i < current_page_no; i++) { + embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), i)); + pages_to_close = g_slist_prepend (pages_to_close, embed); + } + + for (GSList *l = pages_to_close; l != NULL; l = l->next) { + g_assert (l->data != NULL); + g_signal_emit_by_name (GTK_NOTEBOOK (notebook), "tab-close-request", l->data); + } + + g_slist_free (pages_to_close); +} + +void +window_cmd_tabs_close_right (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + EphyWindow *window = user_data; + GtkWidget *notebook; + EphyEmbed *embed; + int n_pages, current_page_no; + GSList *pages_to_close = NULL; + + notebook = ephy_window_get_notebook (window); + n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)); + current_page_no = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); + + for (int i = current_page_no + 1; i < n_pages; i++) { + embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), i)); + pages_to_close = g_slist_prepend (pages_to_close, embed); + } + + for (GSList *l = pages_to_close; l != NULL; l = l->next) { + g_assert (l->data != NULL); + g_signal_emit_by_name (GTK_NOTEBOOK (notebook), "tab-close-request", l->data); + } + + g_slist_free (pages_to_close); +} + +void window_cmd_tabs_close_others (GSimpleAction *action, GVariant *parameter, gpointer user_data) |