[gtk/wip/baedert/for-master: 3/3] modelbutton: Reset active menu item on pointer leave




commit 416b5b3858b82531fca16f070f783bec06a7c404
Author: Timm Bäder <mail baedert org>
Date:   Sun Nov 29 09:49:08 2020 +0100

    modelbutton: Reset active menu item on pointer leave
    
    We don't want to leave an active menu item behind if the pointer doesn't
    enter another menu item.
    This matches the old GtkMenu behavior

 gtk/gtkmodelbutton.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c
index 6c4f2185f5..20ffea7a6f 100644
--- a/gtk/gtkmodelbutton.c
+++ b/gtk/gtkmodelbutton.c
@@ -1387,18 +1387,16 @@ pointer_cb (GObject    *object,
             GParamSpec *pspec,
             gpointer    data)
 {
+  GtkWidget *target = GTK_WIDGET (data);
+  GtkWidget *popover;
   gboolean contains;
 
   contains = gtk_event_controller_motion_get_contains_pointer (GTK_EVENT_CONTROLLER_MOTION (object));
 
+  popover = gtk_widget_get_ancestor (target, GTK_TYPE_POPOVER_MENU);
+
   if (contains)
     {
-      GtkWidget *target;
-      GtkWidget *popover;
-
-      target = GTK_WIDGET (data);
-      popover = gtk_widget_get_ancestor (target, GTK_TYPE_POPOVER_MENU);
-
       if (popover)
         {
           if (gtk_popover_menu_get_open_submenu (GTK_POPOVER_MENU (popover)) != NULL)
@@ -1412,6 +1410,7 @@ pointer_cb (GObject    *object,
       GtkModelButton *button = data;
 
       stop_open (button);
+      gtk_popover_menu_set_active_item (GTK_POPOVER_MENU (popover), NULL);
     }
 }
 


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