[gtk/wip/carlosg/gesture-state-in-entries] gtkpasswordentry: Consume click events after pressing on icon



commit 58c31b8627a795c70e5a2ef4b0fdbe4d52bb0023
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Aug 24 01:12:31 2021 +0200

    gtkpasswordentry: Consume click events after pressing on icon
    
    This may result in user actions, so the gesture should consume the
    events.

 gtk/gtkpasswordentry.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/gtk/gtkpasswordentry.c b/gtk/gtkpasswordentry.c
index 0e66499c69..ba91de58f4 100644
--- a/gtk/gtkpasswordentry.c
+++ b/gtk/gtkpasswordentry.c
@@ -141,6 +141,12 @@ focus_changed (GtkWidget *widget)
     caps_lock_state_changed (entry->keyboard, NULL, widget);
 }
 
+static void
+gtk_password_entry_icon_press (GtkGesture *gesture)
+{
+  gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_CLAIMED);
+}
+
 /*< private >
  * gtk_password_entry_toggle_peek:
  * @entry: a `GtkPasswordEntry`
@@ -607,6 +613,8 @@ gtk_password_entry_set_show_peek_icon (GtkPasswordEntry *entry,
       gtk_widget_set_parent (entry->peek_icon, GTK_WIDGET (entry));
 
       press = gtk_gesture_click_new ();
+      g_signal_connect (press, "pressed",
+                        G_CALLBACK (gtk_password_entry_icon_press), entry);
       g_signal_connect_swapped (press, "released",
                                 G_CALLBACK (gtk_password_entry_toggle_peek), entry);
       gtk_widget_add_controller (entry->peek_icon, GTK_EVENT_CONTROLLER (press));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]