[gtk/wip/carlosg/gesture-state-in-entries: 4/4] gtksearchentry: Add a "catchall" click gesture handler
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/gesture-state-in-entries: 4/4] gtksearchentry: Add a "catchall" click gesture handler
- Date: Mon, 23 Aug 2021 13:35:19 +0000 (UTC)
commit b4aac15d2dda11693e0b4b911986c7fdb0b5d64f
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Aug 23 15:33:32 2021 +0200
gtksearchentry: Add a "catchall" click gesture handler
This gesture is set on the whole widget surface, since there's
multiple input targets inside an entry (icons, the GtkText itself)
it makes sense to consider the full entry an area handling clicks.
Ensure these events don't propagate further up, and result in other
actions.
gtk/gtksearchentry.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtksearchentry.c b/gtk/gtksearchentry.c
index 99ca693e91..63eec62256 100644
--- a/gtk/gtksearchentry.c
+++ b/gtk/gtksearchentry.c
@@ -570,11 +570,21 @@ activate_cb (GtkText *text,
g_signal_emit (data, signals[ACTIVATE], 0);
}
+static void
+catchall_click_press (GtkGestureClick *gesture,
+ int n_press,
+ double x,
+ double y,
+ gpointer user_data)
+{
+ gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
+}
+
static void
gtk_search_entry_init (GtkSearchEntry *entry)
{
GtkWidget *icon;
- GtkGesture *press;
+ GtkGesture *press, *catchall;
/* The search icon is purely presentational */
icon = g_object_new (GTK_TYPE_IMAGE,
@@ -605,6 +615,12 @@ gtk_search_entry_init (GtkSearchEntry *entry)
g_signal_connect (press, "released", G_CALLBACK (gtk_search_entry_icon_release), entry);
gtk_widget_add_controller (entry->icon, GTK_EVENT_CONTROLLER (press));
+ catchall = gtk_gesture_click_new ();
+ g_signal_connect (catchall, "pressed",
+ G_CALLBACK (catchall_click_press), entry);
+ gtk_widget_add_controller (GTK_WIDGET (entry),
+ GTK_EVENT_CONTROLLER (catchall));
+
gtk_widget_add_css_class (GTK_WIDGET (entry), I_("search"));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]