Make middle-clicking to close tabs and double-clicking to toggle

widgets work also for the gap between the tab label and close
button (shown when there are more tabs than fit on screen), and
when middle-clicking on the close button.



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3280 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2008-11-26 16:08:42 +00:00
parent 899dce26b6
commit 1fc1a3d31b

View File

@ -417,7 +417,7 @@ static void tab_count_changed(void)
} }
static gboolean notebook_tab_label_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) static gboolean notebook_tab_click(GtkWidget *widget, GdkEventButton *event, gpointer data)
{ {
/* toggle additional widgets on double click */ /* toggle additional widgets on double click */
if (event->type == GDK_2BUTTON_PRESS) if (event->type == GDK_2BUTTON_PRESS)
@ -450,13 +450,15 @@ gint notebook_new_tab(GeanyDocument *this)
this->priv->tab_label = gtk_label_new(NULL); this->priv->tab_label = gtk_label_new(NULL);
/* get button press events for the tab label and the space between it and
* the close button, if any */
ebox = gtk_event_box_new(); ebox = gtk_event_box_new();
GTK_WIDGET_SET_FLAGS(ebox, GTK_NO_WINDOW); GTK_WIDGET_SET_FLAGS(ebox, GTK_NO_WINDOW);
g_signal_connect(ebox, "button-press-event", G_CALLBACK(notebook_tab_label_cb), page); g_signal_connect(ebox, "button-press-event", G_CALLBACK(notebook_tab_click), page);
hbox = gtk_hbox_new(FALSE, 2); hbox = gtk_hbox_new(FALSE, 2);
gtk_container_add(GTK_CONTAINER(ebox), this->priv->tab_label); gtk_box_pack_start(GTK_BOX(hbox), this->priv->tab_label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), ebox, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(ebox), hbox);
if (file_prefs.show_tab_cross) if (file_prefs.show_tab_cross)
{ {
@ -489,9 +491,11 @@ gint notebook_new_tab(GeanyDocument *this)
gtk_box_pack_start(GTK_BOX(hbox), align, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), align, TRUE, TRUE, 0);
g_signal_connect(btn, "clicked", G_CALLBACK(notebook_tab_close_clicked_cb), page); g_signal_connect(btn, "clicked", G_CALLBACK(notebook_tab_close_clicked_cb), page);
/* button overrides event box, so make middle click on button also close tab */
g_signal_connect(btn, "button-press-event", G_CALLBACK(notebook_tab_click), page);
} }
gtk_widget_show_all(hbox); gtk_widget_show_all(ebox);
this->priv->tabmenu_label = gtk_label_new(NULL); this->priv->tabmenu_label = gtk_label_new(NULL);
gtk_misc_set_alignment(GTK_MISC(this->priv->tabmenu_label), 0.0, 0); gtk_misc_set_alignment(GTK_MISC(this->priv->tabmenu_label), 0.0, 0);
@ -500,10 +504,10 @@ gint notebook_new_tab(GeanyDocument *this)
if (file_prefs.tab_order_ltr) if (file_prefs.tab_order_ltr)
tabnum = gtk_notebook_append_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page, tabnum = gtk_notebook_append_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
hbox, this->priv->tabmenu_label); ebox, this->priv->tabmenu_label);
else else
tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page, tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
hbox, this->priv->tabmenu_label, 0); ebox, this->priv->tabmenu_label, 0);
tab_count_changed(); tab_count_changed();