[balsa] mime-widget-image: Connect to the "pressed" signal
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] mime-widget-image: Connect to the "pressed" signal
- Date: Tue, 2 Jun 2020 14:28:53 +0000 (UTC)
commit 5e8c37eb46fe8bbe24eab808a8a2649062877e6a
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Tue Jun 2 10:27:09 2020 -0400
mime-widget-image: Connect to the "pressed" signal
Connect to the "pressed" signal of a GtkGestureMultiPress instead of the
"button-press-event" widget signal.
* src/balsa-mime-widget-image.c (balsa_image_button_press_cb), (balsa_mime_widget_new_image):
ChangeLog | 9 +++++++++
src/balsa-mime-widget-image.c | 31 ++++++++++++++++++++++---------
2 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bc363f4a3..630fae7de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-06-02 Peter Bloomfield <pbloomfield bellsouth net>
+
+ mime-widget-image: Connect to the "pressed" signal of a
+ GtkGestureMultiPress instead of the "button-press-event" widget
+ signal.
+
+ * src/balsa-mime-widget-image.c (balsa_image_button_press_cb),
+ (balsa_mime_widget_new_image):
+
2020-06-01 Peter Bloomfield <pbloomfield bellsouth net>
balsa-message: Connect to the "pressed" signal of a
diff --git a/src/balsa-mime-widget-image.c b/src/balsa-mime-widget-image.c
index e54c912ec..f358b9457 100644
--- a/src/balsa-mime-widget-image.c
+++ b/src/balsa-mime-widget-image.c
@@ -139,16 +139,26 @@ img_check_size(BalsaMimeWidgetImage * mwi)
return G_SOURCE_REMOVE;
}
-static gboolean
-balsa_image_button_press_cb(GtkWidget * widget, GdkEventButton * event,
- GtkMenu * menu)
+static void
+balsa_image_button_press_cb(GtkGestureMultiPress *multi_press_gesture,
+ gint n_press,
+ gdouble x,
+ gdouble y,
+ gpointer user_data)
{
- if (gdk_event_triggers_context_menu((GdkEvent *) event)) {
- gtk_menu_popup_at_pointer(menu, (GdkEvent *) event);
- return TRUE;
+ GtkMenu *menu = user_data;
+ GtkGesture *gesture;
+ GdkEventSequence *sequence;
+ const GdkEvent *event;
+
+ gesture = GTK_GESTURE(multi_press_gesture);
+ sequence = gtk_gesture_single_get_current_sequence(GTK_GESTURE_SINGLE(multi_press_gesture));
+ event = gtk_gesture_get_last_event(gesture, sequence);
+
+ if (gdk_event_triggers_context_menu(event)) {
+ gtk_menu_popup_at_pointer(menu, event);
+ gtk_gesture_set_sequence_state(gesture, sequence, GTK_EVENT_SEQUENCE_CLAIMED);
}
-
- return FALSE;
}
static void
@@ -174,6 +184,7 @@ balsa_mime_widget_new_image(BalsaMessage * bm,
BalsaMimeWidgetImage *mwi;
BalsaMimeWidget *mw;
GtkWidget *widget;
+ GtkGesture *gesture;
g_return_val_if_fail(mime_body != NULL, NULL);
g_return_val_if_fail(content_type != NULL, NULL);
@@ -197,7 +208,9 @@ balsa_mime_widget_new_image(BalsaMessage * bm,
widget = gtk_event_box_new();
gtk_container_add(GTK_CONTAINER(mw), widget);
- g_signal_connect(widget, "button-press-event",
+ gesture = gtk_gesture_multi_press_new(widget);
+ gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 0);
+ g_signal_connect(gesture, "pressed",
G_CALLBACK(balsa_image_button_press_cb), data);
mwi->image = image = gtk_image_new_from_icon_name("image-missing",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]