[gtk/wip/matthiasc/shortcut-4: 106/139] mountoperation: Stop using ::popup-menu



commit 46608fbdfbb48af1f3080c27d9d6aafcfd9111c7
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Mar 18 22:56:53 2020 -0400

    mountoperation: Stop using ::popup-menu
    
    We can just use a shortcut controller directly.

 gtk/gtkmountoperation.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c
index 51d926c401..a3debb0861 100644
--- a/gtk/gtkmountoperation.c
+++ b/gtk/gtkmountoperation.c
@@ -57,6 +57,10 @@
 #include "gtkpopover.h"
 #include "gtksnapshot.h"
 #include "gdktextureprivate.h"
+#include "gtkshortcutcontroller.h"
+#include "gtkshortcuttrigger.h"
+#include "gtkshortcutaction.h"
+#include "gtkshortcut.h"
 #include <glib/gprintf.h>
 
 /**
@@ -1458,6 +1462,7 @@ do_popup_menu_for_process_tree_view (GtkWidget         *widget,
 
 static gboolean
 on_popup_menu_for_process_tree_view (GtkWidget *widget,
+                                     GVariant  *args,
                                      gpointer   user_data)
 {
   GtkMountOperation *op = GTK_MOUNT_OPERATION (user_data);
@@ -1503,6 +1508,10 @@ create_show_processes_dialog (GtkMountOperation *op,
   gchar *s;
   gboolean use_header;
   GtkGesture *gesture;
+  GtkEventController *controller;
+  GtkShortcutTrigger *trigger;
+  GtkShortcutAction *action;
+  GtkShortcut *shortcut;
 
   priv = op->priv;
 
@@ -1589,9 +1598,15 @@ create_show_processes_dialog (GtkMountOperation *op,
   gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
   gtk_container_add (GTK_CONTAINER (vbox), scrolled_window);
 
-  g_signal_connect (tree_view, "popup-menu",
-                    G_CALLBACK (on_popup_menu_for_process_tree_view),
-                    op);
+  controller = gtk_shortcut_controller_new ();
+  trigger = gtk_alternative_trigger_new (gtk_keyval_trigger_new (GDK_KEY_F10, GDK_SHIFT_MASK),
+                                         gtk_keyval_trigger_new (GDK_KEY_Menu, 0));
+  action = gtk_callback_action_new (on_popup_menu_for_process_tree_view,
+                                    op,
+                                    NULL);
+  shortcut = gtk_shortcut_new_with_arguments (trigger, action, "s", "sv");
+  gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
+  gtk_widget_add_controller (GTK_WIDGET (tree_view), controller);
 
   gesture = gtk_gesture_click_new ();
   gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);


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