[geany/geany] a40823: Add "Close Documents to the Right" feature
Matthew Brush
git-noreply at xxxxx
Fri Aug 4 08:55:43 UTC 2017
Branch: refs/heads/master
Author: Matthew Brush <matt at geany.org>
Committer: Matthew Brush <mbrush at codebrainz.ca>
Date: Fri, 04 Aug 2017 08:55:43 UTC
Commit: a40823084e1615e04464f974f616794a7b3570da
https://github.com/geany/geany/commit/a40823084e1615e04464f974f616794a7b3570da
Log Message:
-----------
Add "Close Documents to the Right" feature
Similar to applications like Firefox and Chromium.
Modified Paths:
--------------
src/notebook.c
Modified: src/notebook.c
29 lines changed, 29 insertions(+), 0 deletions(-)
===================================================================
@@ -430,6 +430,29 @@ static void on_open_in_new_window_activate(GtkMenuItem *menuitem, gpointer user_
}
+static gboolean has_tabs_on_right(GeanyDocument *doc)
+{
+ GtkNotebook *nb = GTK_NOTEBOOK(main_widgets.notebook);
+ gint total_pages = gtk_notebook_get_n_pages(nb);
+ gint doc_page = document_get_notebook_page(doc);
+ return total_pages > (doc_page + 1);
+}
+
+
+void on_close_documents_right_activate(GtkMenuItem *menuitem, GeanyDocument *doc)
+{
+ g_return_if_fail(has_tabs_on_right(doc));
+ GtkNotebook *nb = GTK_NOTEBOOK(main_widgets.notebook);
+ gint doc_page = document_get_notebook_page(doc);
+ for (gint i = doc_page + 1; i < gtk_notebook_get_n_pages(nb); )
+ {
+ if (! document_close(document_get_from_page(i)))
+ i++; // only increment if tab wasn't closed
+ }
+ gtk_notebook_set_current_page(nb, doc_page);
+}
+
+
static void show_tab_bar_popup_menu(GdkEventButton *event, GeanyDocument *doc)
{
GtkWidget *menu_item;
@@ -473,6 +496,12 @@ static void show_tab_bar_popup_menu(GdkEventButton *event, GeanyDocument *doc)
g_signal_connect(menu_item, "activate", G_CALLBACK(on_close_other_documents1_activate), doc);
gtk_widget_set_sensitive(GTK_WIDGET(menu_item), (doc != NULL));
+ menu_item = ui_image_menu_item_new(GTK_STOCK_CLOSE, _("Close Documents to the _Right"));
+ gtk_widget_show(menu_item);
+ gtk_container_add(GTK_CONTAINER(menu), menu_item);
+ g_signal_connect(menu_item, "activate", G_CALLBACK(on_close_documents_right_activate), doc);
+ gtk_widget_set_sensitive(GTK_WIDGET(menu_item), has_tabs_on_right(doc));
+
menu_item = ui_image_menu_item_new(GTK_STOCK_CLOSE, _("C_lose All"));
gtk_widget_show(menu_item);
gtk_container_add(GTK_CONTAINER(menu), menu_item);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list