mountoperation: Stop using ::popup-menu

We can just use a shortcut controller directly.
This commit is contained in:
Matthias Clasen 2020-03-18 22:56:53 -04:00
parent 80b988ef6c
commit 54a0037c45

View File

@ -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);