From f56c36b054dc3ee1948edc193623bc67c0c1203b Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 28 Sep 2021 13:00:08 -0700 Subject: [PATCH] callgraphpage: remove dazzle for shortcuts We can do this manually with a key controller. In the future, we will do this with GTK 4's shortcut controller. --- src/libsysprof-ui/sysprof-callgraph-page.c | 39 ++++++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/libsysprof-ui/sysprof-callgraph-page.c b/src/libsysprof-ui/sysprof-callgraph-page.c index 354cdf1c..6db7e850 100644 --- a/src/libsysprof-ui/sysprof-callgraph-page.c +++ b/src/libsysprof-ui/sysprof-callgraph-page.c @@ -39,7 +39,6 @@ #include "config.h" -#include #include #include "../stackstash.h" @@ -769,6 +768,25 @@ sysprof_callgraph_page_copy_cb (GtkWidget *widget, copy_tree_view_selection (priv->functions_view); } +static gboolean +on_key_pressed_cb (SysprofCallgraphPage *self, + guint keyval, + guint keycode, + GdkModifierType state, + GtkEventControllerKey *controller) +{ + g_assert (SYSPROF_IS_CALLGRAPH_PAGE (self)); + g_assert (GTK_IS_EVENT_CONTROLLER_KEY (controller)); + + if ((state & GDK_CONTROL_MASK) != 0 && keyval == GDK_KEY_c) + { + sysprof_callgraph_page_copy_cb (GTK_WIDGET (self), self); + return GDK_EVENT_STOP; + } + + return GDK_EVENT_PROPAGATE; +} + static void sysprof_callgraph_page_generate_cb (GObject *object, GAsyncResult *result, @@ -937,7 +955,7 @@ static void sysprof_callgraph_page_init (SysprofCallgraphPage *self) { SysprofCallgraphPagePrivate *priv = sysprof_callgraph_page_get_instance_private (self); - DzlShortcutController *controller; + GtkEventController *controller; GtkTreeSelection *selection; GtkCellRenderer *cell; @@ -992,15 +1010,14 @@ sysprof_callgraph_page_init (SysprofCallgraphPage *self) gtk_tree_selection_set_mode (gtk_tree_view_get_selection (priv->descendants_view), GTK_SELECTION_MULTIPLE); - controller = dzl_shortcut_controller_find (GTK_WIDGET (self)); - - dzl_shortcut_controller_add_command_callback (controller, - "org.gnome.sysprof3.capture.copy", - "c", - DZL_SHORTCUT_PHASE_BUBBLE, - (GtkCallback) sysprof_callgraph_page_copy_cb, - self, - NULL); + controller = gtk_event_controller_key_new (GTK_WIDGET (self)); + gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_BUBBLE); + g_signal_connect_object (controller, + "key-pressed", + G_CALLBACK (on_key_pressed_cb), + self, + G_CONNECT_SWAPPED); + g_object_unref (controller); } typedef struct _Descendant Descendant;