From a6f78f815438a264a4c53b351bb07dc7ab81c05a Mon Sep 17 00:00:00 2001 From: Jan-Michael Brummer Date: Sun, 24 Feb 2019 21:23:15 +0000 Subject: [PATCH] page-row: Close on middle click Add a event box around page row to catch button-press-event and allow closing the current item with middle click. Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/643 (cherry picked from commit a15d7030689eb947665fd42ade1c42687201b7b7) --- src/ephy-page-row.c | 17 +++++ src/resources/gtk/page-row.ui | 133 ++++++++++++++++++++++------------ 2 files changed, 103 insertions(+), 47 deletions(-) diff --git a/src/ephy-page-row.c b/src/ephy-page-row.c index 7914f6775..ca63e1697 100644 --- a/src/ephy-page-row.c +++ b/src/ephy-page-row.c @@ -82,6 +82,22 @@ close_clicked_cb (EphyPageRow *self) g_signal_emit (self, signals[CLOSED], 0); } +static gboolean +button_release_event (GtkWidget *widget, + GdkEvent *event, + EphyPageRow *self) +{ + GdkEventButton *button_event = (GdkEventButton *)event; + + if (button_event->button == GDK_BUTTON_MIDDLE) { + g_signal_emit (self, signals[CLOSED], 0); + + return GDK_EVENT_STOP; + } + + return GDK_EVENT_PROPAGATE; +} + static void ephy_page_row_class_init (EphyPageRowClass *klass) { @@ -102,6 +118,7 @@ ephy_page_row_class_init (EphyPageRowClass *klass) gtk_widget_class_bind_template_child (widget_class, EphyPageRow, spinner); gtk_widget_class_bind_template_child (widget_class, EphyPageRow, title); gtk_widget_class_bind_template_callback (widget_class, close_clicked_cb); + gtk_widget_class_bind_template_callback (widget_class, button_release_event); } static void diff --git a/src/resources/gtk/page-row.ui b/src/resources/gtk/page-row.ui index 6bc64369a..2b6fcadfb 100644 --- a/src/resources/gtk/page-row.ui +++ b/src/resources/gtk/page-row.ui @@ -1,70 +1,109 @@ + - +