diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2021-08-24 01:13:29 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2021-08-24 01:13:29 +0200 |
commit | e652054d505bf12b52130ec42baf89f9e3753a42 (patch) | |
tree | d850eadffed0f040ee4eaaa503ad6bdaf7da3bf3 | |
parent | 58c31b8627a795c70e5a2ef4b0fdbe4d52bb0023 (diff) | |
download | gtk+-e652054d505bf12b52130ec42baf89f9e3753a42.tar.gz |
gtkpasswordentry: Add a "catchall" click gesture handlerwip/carlosg/gesture-state-in-entries
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.
-rw-r--r-- | gtk/gtkpasswordentry.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gtk/gtkpasswordentry.c b/gtk/gtkpasswordentry.c index ba91de58f4..7e375a05bc 100644 --- a/gtk/gtkpasswordentry.c +++ b/gtk/gtkpasswordentry.c @@ -189,8 +189,19 @@ activate_cb (GtkPasswordEntry *entry) } 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_password_entry_init (GtkPasswordEntry *entry) { + GtkGesture *catchall; GtkEntryBuffer *buffer = gtk_password_entry_buffer_new (); entry->entry = gtk_text_new (); @@ -207,6 +218,12 @@ gtk_password_entry_init (GtkPasswordEntry *entry) gtk_widget_set_cursor (entry->icon, gtk_widget_get_cursor (entry->entry)); gtk_widget_set_parent (entry->icon, GTK_WIDGET (entry)); + 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_("password")); gtk_password_entry_set_extra_menu (entry, NULL); |