[gnome-disk-utility] gduwindow: Make menus toggleable



commit 6b473d007fc83eb425e0155df5efe0b0938e7323
Author: Manuel Wassermann <manuel wassermann97 gmail com>
Date:   Tue Jul 13 16:07:48 2021 +0200

    gduwindow: Make menus toggleable
    
    When you use the keyboard shortcut to open a menu it is not possible to close
    the menu with the same shortcut.
    
    Make the menus toggleable.

 src/disks/gduwindow.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index ca75470e..0cf82736 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -3239,10 +3239,15 @@ on_volume_menu_open (GSimpleAction *action,
                      GVariant      *parameter,
                      gpointer       user_data)
 {
-  GduWindow *window = GDU_WINDOW (user_data);
+  GduWindow *window;
 
+  window = GDU_WINDOW (user_data);
   update_all (window, FALSE);
-  gtk_popover_popup (GTK_POPOVER (window->volume_menu));
+
+  if (!gtk_widget_get_visible (window->volume_menu))
+    gtk_popover_popup (GTK_POPOVER (window->volume_menu));
+  else
+    gtk_popover_popdown (GTK_POPOVER (window->volume_menu));
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -3252,23 +3257,33 @@ on_drive_menu_open (GSimpleAction *action,
                     GVariant      *parameter,
                     gpointer       user_data)
 {
-  GduWindow *window = GDU_WINDOW (user_data);
+  GduWindow *window;
 
+  window = GDU_WINDOW (user_data);
   update_all (window, FALSE);
-  gtk_popover_popup (GTK_POPOVER (window->drive_menu));
+
+  if (!gtk_widget_get_visible (window->drive_menu))
+    gtk_popover_popup (GTK_POPOVER (window->drive_menu));
+  else
+    gtk_popover_popdown (GTK_POPOVER (window->drive_menu));
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
 
 static void
 on_app_menu_open (GSimpleAction *action,
-                    GVariant      *parameter,
-                    gpointer       user_data)
+                  GVariant      *parameter,
+                  gpointer       user_data)
 {
-  GduWindow *window = GDU_WINDOW (user_data);
+  GduWindow *window;
 
+  window = GDU_WINDOW (user_data);
   update_all (window, FALSE);
-  gtk_popover_popup (GTK_POPOVER (window->app_menu));
+
+  if (!gtk_widget_get_visible (window->app_menu))
+    gtk_popover_popup (GTK_POPOVER (window->app_menu));
+  else
+    gtk_popover_popdown (GTK_POPOVER (window->app_menu));
 }
 
 /* ---------------------------------------------------------------------------------------------------- */


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