Merge branch 'diegoe_missing-hig-shortcuts' into 'master'

sysprof: Add missing HIG shortcuts

See merge request GNOME/sysprof!80
This commit is contained in:
Christian Hergert
2023-10-16 17:43:49 +00:00
4 changed files with 148 additions and 8 deletions

View File

@ -1,35 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkShortcutsWindow" id="help_overlay">
<property name="modal">1</property>
<child>
<object class="GtkShortcutsSection">
<property name="section-name">shortcuts</property>
<property name="max-height">12</property>
<child>
<object class="GtkShortcutsGroup">
<property name="title" translatable="yes" context="shortcut window">General</property>
<property name="title" translatable="yes" context="shortcut window">Recording View</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Show Help</property>
<property name="action-name">win.help</property>
<property name="title" translatable="yes" context="shortcut window">Start New Recording</property>
<property name="accelerator">&lt;control&gt;n</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Keyboard Shortcuts</property>
<property name="action-name">win.show-help-overlay</property>
<property name="title" translatable="yes" context="shortcut window">Save As</property>
<property name="accelerator">&lt;control&gt;s</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Toggle Visibility of Main Sidebar</property>
<property name="accelerator">F9</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Toggle Visibility of Stack Trace Sidebar</property>
<property name="accelerator">&lt;control&gt;F9</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="title" translatable="yes" context="shortcut window">General</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Open Recording</property>
<property name="accelerator">&lt;control&gt;o</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Close Window</property>
<property name="action-name">window.close</property>
<property name="accelerator">&lt;ctrl&gt;w</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Show Help</property>
<property name="accelerator">F1</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Show keyboard shortcuts</property>
<property name="accelerator">&lt;ctrl&gt;question</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Quit</property>
<property name="action-name">app.quit</property>
<property name="accelerator">&lt;ctrl&gt;q</property>
</object>
</child>
</object>

View File

@ -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 },
};

View File

@ -19,6 +19,30 @@
<property name="action">action(window.close)</property>
</object>
</child>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;control&gt;q</property>
<property name="action">action(app.quit)</property>
</object>
</child>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;control&gt;o</property>
<property name="action">action(win.select-file)</property>
</object>
</child>
<child>
<object class="GtkShortcut">
<property name="trigger">F1</property>
<property name="action">action(app.help)</property>
</object>
</child>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;ctrl&gt;question</property>
<property name="action">action(app.show-help-overlay)</property>
</object>
</child>
</object>
</child>
<property name="content">
@ -34,6 +58,7 @@
<child type="end">
<object class="GtkMenuButton">
<property name="icon-name">open-menu-symbolic</property>
<property name="primary">true</property>
<property name="menu-model">primary_menu</property>
</object>
</child>
@ -609,9 +634,18 @@
</template>
<menu id="primary_menu">
<section>
<item>
<attribute name="label" translatable="yes">Open Recording…</attribute>
<attribute name="action">win.select-file</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">app.show-help-overlay</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Help</attribute>
<attribute name="accel">F1</attribute>
<attribute name="action">app.help</attribute>
</item>
<item>
@ -619,6 +653,12 @@
<attribute name="action">app.about</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Quit</attribute>
<attribute name="action">app.quit</attribute>
</item>
</section>
</menu>
<object class="SysprofRecordingTemplate" id="recording_template">
</object>

View File

@ -20,6 +20,12 @@
<property name="action">action(win.show-left-sidebar)</property>
</object>
</child>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;control&gt;w</property>
<property name="action">action(window.close)</property>
</object>
</child>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;ctrl&gt;n</property>
@ -38,6 +44,24 @@
<property name="action">action(win.save-capture)</property>
</object>
</child>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;control&gt;q</property>
<property name="action">action(app.quit)</property>
</object>
</child>
<child>
<object class="GtkShortcut">
<property name="trigger">F1</property>
<property name="action">action(app.help)</property>
</object>
</child>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;ctrl&gt;question</property>
<property name="action">action(app.show-help-overlay)</property>
</object>
</child>
</object>
</child>
<property name="content">
@ -180,6 +204,7 @@
<child type="end">
<object class="GtkMenuButton">
<property name="icon-name">open-menu-symbolic</property>
<property name="primary">true</property>
<property name="menu-model">primary_menu</property>
<property name="tooltip-text" translatable="yes">Main Menu</property>
</object>
@ -369,9 +394,12 @@
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">app.show-help-overlay</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Help</attribute>
<attribute name="accel">F1</attribute>
<attribute name="action">app.help</attribute>
</item>
<item>
@ -379,6 +407,12 @@
<attribute name="action">app.about</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
</item>
</section>
</menu>
<menu id="view_menu">
<section>