From c3070a478d5005e64d8be834c9b55a8b904350a3 Mon Sep 17 00:00:00 2001 From: Diego Escalante Urrelo Date: Mon, 16 Oct 2023 17:43:49 +0000 Subject: [PATCH] sysprof: Add missing HIG shortcuts --- src/sysprof/gtk/help-overlay.ui | 49 +++++++++++++++++++++++++++---- src/sysprof/sysprof-application.c | 29 ++++++++++++++++++ src/sysprof/sysprof-greeter.ui | 42 +++++++++++++++++++++++++- src/sysprof/sysprof-window.ui | 36 ++++++++++++++++++++++- 4 files changed, 148 insertions(+), 8 deletions(-) diff --git a/src/sysprof/gtk/help-overlay.ui b/src/sysprof/gtk/help-overlay.ui index 8c0b11ad..832cdae6 100644 --- a/src/sysprof/gtk/help-overlay.ui +++ b/src/sysprof/gtk/help-overlay.ui @@ -1,35 +1,72 @@ + 1 shortcuts 12 - General + Recording View - Show Help - win.help + Start New Recording + <control>n - Keyboard Shortcuts - win.show-help-overlay + Save As + <control>s + + + + + Toggle Visibility of Main Sidebar + F9 + + + + + Toggle Visibility of Stack Trace Sidebar + <control>F9 + + + + + + + General + + + Open Recording + <control>o Close Window window.close + <ctrl>w + + + + + Show Help + F1 + + + + + Show keyboard shortcuts + <ctrl>question Quit - app.quit + <ctrl>q diff --git a/src/sysprof/sysprof-application.c b/src/sysprof/sysprof-application.c index 17f7bf19..860846fe 100644 --- a/src/sysprof/sysprof-application.c +++ b/src/sysprof/sysprof-application.c @@ -190,11 +190,40 @@ sysprof_help (GSimpleAction *action, gtk_uri_launcher_launch (launcher, window, NULL, NULL, NULL); } +static void +sysprof_show_help_overlay (GSimpleAction *action, + GVariant *variant, + gpointer user_data) +{ + SysprofApplication *self = user_data; + g_autoptr(GtkBuilder) builder = NULL; + GtkWindow *window; + GObject *help_overlay; + + g_assert (SYSPROF_IS_APPLICATION (self)); + g_assert (G_IS_SIMPLE_ACTION (action)); + + window = gtk_application_get_active_window (GTK_APPLICATION (self)); + builder = gtk_builder_new_from_resource ("/org/gnome/sysprof/gtk/help-overlay.ui"); + help_overlay = gtk_builder_get_object (builder, "help_overlay"); + + if (GTK_IS_SHORTCUTS_WINDOW (help_overlay)) + { +#if DEVELOPMENT_BUILD + gtk_widget_add_css_class (GTK_WIDGET (help_overlay), "devel"); +#endif + gtk_window_set_transient_for (GTK_WINDOW (help_overlay), GTK_WINDOW (window)); + gtk_window_present (GTK_WINDOW (help_overlay)); + } + +} + static void sysprof_application_init (SysprofApplication *self) { static const GActionEntry actions[] = { { "about", sysprof_about }, + { "show-help-overlay", sysprof_show_help_overlay }, { "help", sysprof_help }, { "quit", sysprof_quit }, }; diff --git a/src/sysprof/sysprof-greeter.ui b/src/sysprof/sysprof-greeter.ui index f2e1e9cd..35e790f5 100644 --- a/src/sysprof/sysprof-greeter.ui +++ b/src/sysprof/sysprof-greeter.ui @@ -19,6 +19,30 @@ action(window.close) + + + <control>q + action(app.quit) + + + + + <control>o + action(win.select-file) + + + + + F1 + action(app.help) + + + + + <ctrl>question + action(app.show-help-overlay) + + @@ -34,6 +58,7 @@ open-menu-symbolic + true primary_menu @@ -609,9 +634,18 @@
+ + Open Recording… + win.select-file + +
+
+ + _Keyboard Shortcuts + app.show-help-overlay + Help - F1 app.help @@ -619,6 +653,12 @@ app.about
+
+ + Quit + app.quit + +
diff --git a/src/sysprof/sysprof-window.ui b/src/sysprof/sysprof-window.ui index 28777196..534ea7f2 100644 --- a/src/sysprof/sysprof-window.ui +++ b/src/sysprof/sysprof-window.ui @@ -20,6 +20,12 @@ action(win.show-left-sidebar) + + + <control>w + action(window.close) + + <ctrl>n @@ -38,6 +44,24 @@ action(win.save-capture) + + + <control>q + action(app.quit) + + + + + F1 + action(app.help) + + + + + <ctrl>question + action(app.show-help-overlay) + + @@ -180,6 +204,7 @@ open-menu-symbolic + true primary_menu Main Menu @@ -369,9 +394,12 @@
+ + _Keyboard Shortcuts + app.show-help-overlay + Help - F1 app.help @@ -379,6 +407,12 @@ app.about
+
+ + _Quit + app.quit + +