Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/ad321c1b83299b72dc0dce03e852c857469b794f
...commit
http://git.netsurf-browser.org/netsurf.git/commit/ad321c1b83299b72dc0dce03e852c857469b794f
...tree
http://git.netsurf-browser.org/netsurf.git/tree/ad321c1b83299b72dc0dce03e852c857469b794f
The branch, master has been updated
via ad321c1b83299b72dc0dce03e852c857469b794f (commit)
from 4a1ca97c65a7f266b60d57fc484fe154dbbc855d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=ad321c1b83299b72dc0dce03e852c857469b794f
commit ad321c1b83299b72dc0dce03e852c857469b794f
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
make gtk tab closeable with middle click
Implements feature request "Please add middle-click on tab to close."
Fixes: #2720.
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index 76fd02f..4fa109b 100644
--- a/frontends/gtk/tabs.c
+++ b/frontends/gtk/tabs.c
@@ -72,6 +72,25 @@ nsgtk_tab_update_size(GtkWidget *hbox,
/**
+ * gtk event handler for button release on tab hbox
+ */
+static gboolean
+nsgtk_tab_button_release(GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ GtkWidget *page;
+
+ if ((event->type == GDK_BUTTON_RELEASE) && (event->button == 2)) {
+ page = (GtkWidget *)user_data;
+ gtk_widget_destroy(page);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/**
* Create a notebook tab label
*
* \param page The page content widget
@@ -83,11 +102,16 @@ nsgtk_tab_label_setup(GtkWidget *page,
const char *title,
GdkPixbuf *icon_pixbuf)
{
- GtkWidget *hbox, *favicon, *label, *button, *close;
+ GtkWidget *ebox, *hbox, *favicon, *label, *button, *close;
/* horizontal box */
hbox = nsgtk_hbox_new(FALSE, 3);
+ /* event box */
+ ebox = gtk_event_box_new();
+ gtk_widget_set_events(ebox, GDK_BUTTON_PRESS_MASK);
+ gtk_container_add(GTK_CONTAINER(ebox), hbox);
+
/* construct a favicon */
favicon = gtk_image_new();
if (icon_pixbuf != NULL) {
@@ -102,7 +126,7 @@ nsgtk_tab_label_setup(GtkWidget *page,
nsgtk_widget_set_margins(label, 0, 0);
gtk_widget_show(label);
- /* construct a close button and attach signals */
+ /* construct a close button */
button = gtk_button_new();
close = nsgtk_image_new_from_stock(NSGTK_STOCK_CLOSE,
@@ -112,26 +136,34 @@ nsgtk_tab_label_setup(GtkWidget *page,
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
gtk_widget_set_tooltip_text(button, "Close this tab.");
+ /* pack the widgets into the label box */
+ gtk_box_pack_start(GTK_BOX(hbox), favicon, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+
+ /* make the icon and label widgets findable by name */
+ g_object_set_data(G_OBJECT(ebox), "favicon", favicon);
+ g_object_set_data(G_OBJECT(ebox), "label", label);
+
+ /* attach signal handlers */
g_signal_connect_swapped(button,
"clicked",
G_CALLBACK(gtk_widget_destroy), page);
+
g_signal_connect(hbox,
"style-set",
G_CALLBACK(nsgtk_tab_update_size),
button);
- /* pack the widgets into the label box */
- gtk_box_pack_start(GTK_BOX(hbox), favicon, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+ g_signal_connect(ebox,
+ "button-release-event",
+ G_CALLBACK(nsgtk_tab_button_release),
+ page);
- g_object_set_data(G_OBJECT(hbox), "favicon", favicon);
- g_object_set_data(G_OBJECT(hbox), "label", label);
- g_object_set_data(G_OBJECT(hbox), "close-button", button);
- gtk_widget_show_all(hbox);
+ gtk_widget_show_all(ebox);
- return hbox;
+ return ebox;
}
-----------------------------------------------------------------------
Summary of changes:
frontends/gtk/tabs.c | 54 ++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 43 insertions(+), 11 deletions(-)
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index 76fd02f..4fa109b 100644
--- a/frontends/gtk/tabs.c
+++ b/frontends/gtk/tabs.c
@@ -72,6 +72,25 @@ nsgtk_tab_update_size(GtkWidget *hbox,
/**
+ * gtk event handler for button release on tab hbox
+ */
+static gboolean
+nsgtk_tab_button_release(GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ GtkWidget *page;
+
+ if ((event->type == GDK_BUTTON_RELEASE) && (event->button == 2)) {
+ page = (GtkWidget *)user_data;
+ gtk_widget_destroy(page);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/**
* Create a notebook tab label
*
* \param page The page content widget
@@ -83,11 +102,16 @@ nsgtk_tab_label_setup(GtkWidget *page,
const char *title,
GdkPixbuf *icon_pixbuf)
{
- GtkWidget *hbox, *favicon, *label, *button, *close;
+ GtkWidget *ebox, *hbox, *favicon, *label, *button, *close;
/* horizontal box */
hbox = nsgtk_hbox_new(FALSE, 3);
+ /* event box */
+ ebox = gtk_event_box_new();
+ gtk_widget_set_events(ebox, GDK_BUTTON_PRESS_MASK);
+ gtk_container_add(GTK_CONTAINER(ebox), hbox);
+
/* construct a favicon */
favicon = gtk_image_new();
if (icon_pixbuf != NULL) {
@@ -102,7 +126,7 @@ nsgtk_tab_label_setup(GtkWidget *page,
nsgtk_widget_set_margins(label, 0, 0);
gtk_widget_show(label);
- /* construct a close button and attach signals */
+ /* construct a close button */
button = gtk_button_new();
close = nsgtk_image_new_from_stock(NSGTK_STOCK_CLOSE,
@@ -112,26 +136,34 @@ nsgtk_tab_label_setup(GtkWidget *page,
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
gtk_widget_set_tooltip_text(button, "Close this tab.");
+ /* pack the widgets into the label box */
+ gtk_box_pack_start(GTK_BOX(hbox), favicon, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+
+ /* make the icon and label widgets findable by name */
+ g_object_set_data(G_OBJECT(ebox), "favicon", favicon);
+ g_object_set_data(G_OBJECT(ebox), "label", label);
+
+ /* attach signal handlers */
g_signal_connect_swapped(button,
"clicked",
G_CALLBACK(gtk_widget_destroy), page);
+
g_signal_connect(hbox,
"style-set",
G_CALLBACK(nsgtk_tab_update_size),
button);
- /* pack the widgets into the label box */
- gtk_box_pack_start(GTK_BOX(hbox), favicon, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+ g_signal_connect(ebox,
+ "button-release-event",
+ G_CALLBACK(nsgtk_tab_button_release),
+ page);
- g_object_set_data(G_OBJECT(hbox), "favicon", favicon);
- g_object_set_data(G_OBJECT(hbox), "label", label);
- g_object_set_data(G_OBJECT(hbox), "close-button", button);
- gtk_widget_show_all(hbox);
+ gtk_widget_show_all(ebox);
- return hbox;
+ return ebox;
}
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org