From 9b3e97a343d654980a60ecbd2004a58939e3227a Mon Sep 17 00:00:00 2001 From: Nathan Dunsworth Date: Sun, 12 Jul 2015 06:26:31 -0500 Subject: [PATCH 1/2] Added "Close Documents To The Right" to document context menu --- src/callbacks.c | 21 +++++++++++++++++++++ src/callbacks.h | 2 ++ src/notebook.c | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/src/callbacks.c b/src/callbacks.c index 0848c7f0c0..7d516e6e19 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -157,6 +157,27 @@ void on_close_all1_activate(GtkMenuItem *menuitem, gpointer user_data) } +void on_close_allafter1_activate(GtkMenuItem *menuitem, gpointer user_data) +{ + guint i; + GeanyDocument *cur_doc = user_data; + + if (cur_doc == NULL) + cur_doc = document_get_current(); + + for (i = cur_doc->index + 1; i < documents_array->len; i++) + { + GeanyDocument *doc = documents[i]; + + if (doc == cur_doc || ! doc->is_valid) + continue; + + if (! document_close(doc)) + break; + } +} + + void on_close1_activate(GtkMenuItem *menuitem, gpointer user_data) { GeanyDocument *doc = document_get_current(); diff --git a/src/callbacks.h b/src/callbacks.h index 6017b1ed80..87ef519aa9 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -47,6 +47,8 @@ void on_close1_activate(GtkMenuItem *menuitem, gpointer user_data); void on_close_all1_activate(GtkMenuItem *menuitem, gpointer user_data); +void on_close_allafter1_activate(GtkMenuItem *menuitem, gpointer user_data); + void on_replace_tabs_activate(GtkMenuItem *menuitem, gpointer user_data); void on_toolbutton_search_clicked(GtkAction *action, gpointer user_data); diff --git a/src/notebook.c b/src/notebook.c index b4c8568a84..275d6b6e49 100644 --- a/src/notebook.c +++ b/src/notebook.c @@ -473,6 +473,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_allafter1_activate), doc); + gtk_widget_set_sensitive(GTK_WIDGET(menu_item), (doc != NULL)); + 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); From 73ab9afa6b54531f991b05a358c02f30f3c5eda3 Mon Sep 17 00:00:00 2001 From: Nathan Dunsworth Date: Sun, 12 Jul 2015 06:29:15 -0500 Subject: [PATCH 2/2] undo --- src/callbacks.c | 21 +++++++++++++++++++++ src/callbacks.h | 2 ++ src/notebook.c | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/src/callbacks.c b/src/callbacks.c index 0848c7f0c0..7d516e6e19 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -157,6 +157,27 @@ void on_close_all1_activate(GtkMenuItem *menuitem, gpointer user_data) } +void on_close_allafter1_activate(GtkMenuItem *menuitem, gpointer user_data) +{ + guint i; + GeanyDocument *cur_doc = user_data; + + if (cur_doc == NULL) + cur_doc = document_get_current(); + + for (i = cur_doc->index + 1; i < documents_array->len; i++) + { + GeanyDocument *doc = documents[i]; + + if (doc == cur_doc || ! doc->is_valid) + continue; + + if (! document_close(doc)) + break; + } +} + + void on_close1_activate(GtkMenuItem *menuitem, gpointer user_data) { GeanyDocument *doc = document_get_current(); diff --git a/src/callbacks.h b/src/callbacks.h index 6017b1ed80..87ef519aa9 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -47,6 +47,8 @@ void on_close1_activate(GtkMenuItem *menuitem, gpointer user_data); void on_close_all1_activate(GtkMenuItem *menuitem, gpointer user_data); +void on_close_allafter1_activate(GtkMenuItem *menuitem, gpointer user_data); + void on_replace_tabs_activate(GtkMenuItem *menuitem, gpointer user_data); void on_toolbutton_search_clicked(GtkAction *action, gpointer user_data); diff --git a/src/notebook.c b/src/notebook.c index b4c8568a84..275d6b6e49 100644 --- a/src/notebook.c +++ b/src/notebook.c @@ -473,6 +473,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_allafter1_activate), doc); + gtk_widget_set_sensitive(GTK_WIDGET(menu_item), (doc != NULL)); + 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);