Kaydet (Commit) 6e58ef37 authored tarafından Colomban Wendling's avatar Colomban Wendling

Don't use the notebook page widget for tab popup

Directly use the GeanyDocument rather than pass the notebook page
widget and get the document from that.  This makes the code more future
proof and less weird.
üst 54724ee2
......@@ -1914,25 +1914,18 @@ G_MODULE_EXPORT void on_search1_activate(GtkMenuItem *menuitem, gpointer user_da
/* simple implementation (vs. close all which doesn't close documents if cancelled),
* if user_data is set, it is a GtkNotebook child widget */
* if user_data is set, it is the GeanyDocument to keep */
G_MODULE_EXPORT void on_close_other_documents1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
guint i;
GeanyDocument *doc, *cur_doc;
GeanyDocument *cur_doc = user_data;
if (user_data != NULL)
{
gint page_num = gtk_notebook_page_num(
GTK_NOTEBOOK(main_widgets.notebook), GTK_WIDGET(user_data));
cur_doc = document_get_from_page(page_num);
}
else
if (cur_doc == NULL)
cur_doc = document_get_current();
for (i = 0; i < documents_array->len; i++)
{
doc = documents[i];
GeanyDocument *doc = documents[i];
if (doc == cur_doc || ! doc->is_valid)
continue;
......
......@@ -445,12 +445,10 @@ static void on_open_in_new_window_activate(GtkMenuItem *menuitem, gpointer user_
}
static void show_tab_bar_popup_menu(GdkEventButton *event, GtkWidget *page)
static void show_tab_bar_popup_menu(GdkEventButton *event, GeanyDocument *doc)
{
GtkWidget *menu_item;
static GtkWidget *menu = NULL;
GeanyDocument *doc = NULL;
gint page_num;
if (menu == NULL)
menu = gtk_menu_new();
......@@ -465,12 +463,6 @@ static void show_tab_bar_popup_menu(GdkEventButton *event, GtkWidget *page)
gtk_widget_show(menu_item);
gtk_container_add(GTK_CONTAINER(menu), menu_item);
if (page != NULL)
{
page_num = gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook), page);
doc = document_get_from_page(page_num);
}
menu_item = ui_image_menu_item_new(GTK_STOCK_OPEN, "Open in New _Window");
gtk_widget_show(menu_item);
gtk_container_add(GTK_CONTAINER(menu), menu_item);
......@@ -488,13 +480,13 @@ static void show_tab_bar_popup_menu(GdkEventButton *event, GtkWidget *page)
gtk_widget_show(menu_item);
gtk_container_add(GTK_CONTAINER(menu), menu_item);
g_signal_connect(menu_item, "activate", G_CALLBACK(notebook_tab_close_clicked_cb), doc);
gtk_widget_set_sensitive(GTK_WIDGET(menu_item), (page != NULL));
gtk_widget_set_sensitive(GTK_WIDGET(menu_item), (doc != NULL));
menu_item = ui_image_menu_item_new(GTK_STOCK_CLOSE, _("Close Ot_her Documents"));
gtk_widget_show(menu_item);
gtk_container_add(GTK_CONTAINER(menu), menu_item);
g_signal_connect(menu_item, "activate", G_CALLBACK(on_close_other_documents1_activate), page);
gtk_widget_set_sensitive(GTK_WIDGET(menu_item), (page != NULL));
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, _("C_lose All"));
gtk_widget_show(menu_item);
......@@ -635,8 +627,7 @@ static gboolean notebook_tab_click(GtkWidget *widget, GdkEventButton *event, gpo
/* right-click is first handled here if it happened on a notebook tab */
if (event->button == 3)
{
/* show_tab_bar_popup_menu() needs the tab widget (GtkBox, parent of scintilla) */
show_tab_bar_popup_menu(event, gtk_widget_get_parent(GTK_WIDGET(doc->editor->sci)));
show_tab_bar_popup_menu(event, doc);
return TRUE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment