help-overlay: Some shortcuts improvements

This commit is contained in:
Sabri Ünal
2022-12-09 23:19:42 +00:00
committed by Christian Hergert
parent 67797056ca
commit 8d3838d3aa
3 changed files with 54 additions and 64 deletions

View File

@ -3,46 +3,39 @@
<object class="GtkShortcutsWindow" id="help_overlay">
<child>
<object class="GtkShortcutsSection">
<property name="visible">1</property>
<property name="section-name">sysprof</property>
<property name="title" translatable="yes" context="shortcut window">Sysprof Shortcuts</property>
<property name="section-name">shortcuts</property>
<property name="max-height">12</property>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Files</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Save Recording</property>
<property name="subtitle" translatable="yes" context="shortcut window">Saves the current recording</property>
<property name="accelerator">&lt;Primary&gt;s</property>
<property name="action-name">win.save-capture</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Open recording</property>
<property name="subtitle" translatable="yes" context="shortcut window">Opens a previously saved recording</property>
<property name="accelerator">&lt;Primary&gt;o</property>
<property name="action-name">app.open-capture</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Recording</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Record again</property>
<property name="subtitle" translatable="yes" context="shortcut window">Starts a new recording</property>
<property name="accelerator">&lt;Primary&gt;r</property>
<property name="action-name">win.replay-capture</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Stop recording</property>
<property name="accelerator">Escape</property>
</object>
@ -51,11 +44,9 @@
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Callgraph</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Expand function</property>
<property name="subtitle" translatable="yes" context="shortcut window">Shows the direct descendants of the callgraph function</property>
<property name="accelerator">Right</property>
@ -63,7 +54,6 @@
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Collapse function</property>
<property name="subtitle" translatable="yes" context="shortcut window">Hides all callgraph descendants below the selected function</property>
<property name="accelerator">Left</property>
@ -71,7 +61,6 @@
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Jump into function</property>
<property name="subtitle" translatable="yes" context="shortcut window">Selects the function or file as the top of the callgraph</property>
<property name="accelerator">Return</property>
@ -81,31 +70,74 @@
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Visualizers</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Zoom in</property>
<property name="accelerator">&lt;primary&gt;plus</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Zoom out</property>
<property name="accelerator">&lt;primary&gt;minus</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Reset zoom</property>
<property name="accelerator">&lt;primary&gt;0</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">Show Help</property>
<property name="action-name">app.help</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>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">New Tab</property>
<property name="action-name">win.new-tab</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Switch Tab</property>
<property name="accelerator">&lt;alt&gt;1...9</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">New Window</property>
<property name="action-name">app.new-window</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Close Window</property>
<property name="action-name">win.close-tab</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Quit</property>
<property name="action-name">app.quit</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>

View File

@ -5,50 +5,42 @@
<item>
<attribute name="label" translatable="yes">New Tab</attribute>
<attribute name="action">win.new-tab</attribute>
<attribute name="accel">&lt;primary&gt;t</attribute>
</item>
<item>
<attribute name="label" translatable="yes">New Window</attribute>
<attribute name="action">app.new-window</attribute>
<attribute name="accel">&lt;primary&gt;n</attribute>
</item>
</section>
<section id="win-menu-file">
<item>
<attribute name="label" translatable="yes">Open Recording…</attribute>
<attribute name="action">app.open-capture</attribute>
<attribute name="accel">&lt;primary&gt;o</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Save Recording…</attribute>
<attribute name="action">win.save-capture</attribute>
<attribute name="accel">&lt;primary&gt;s</attribute>
</item>
</section>
<section id="win-menu-replay">
<item>
<attribute name="label" translatable="yes">Record Again</attribute>
<attribute name="action">win.replay-capture</attribute>
<attribute name="accel">&lt;primary&gt;r</attribute>
</item>
</section>
<section id="win-menu-close">
<item>
<attribute name="label" translatable="yes">Close</attribute>
<attribute name="action">win.close-tab</attribute>
<attribute name="accel">&lt;primary&gt;w</attribute>
</item>
</section>
<section id="win-menu-misc">
<item>
<attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
<attribute name="action">app.show-help-overlay</attribute>
<attribute name="accel">&lt;primary&gt;question</attribute>
<attribute name="action">win.show-help-overlay</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Help</attribute>
<attribute name="action">app.help</attribute>
<attribute name="accel">F1</attribute>
</item>
<item>
<attribute name="label" translatable="yes">About Sysprof</attribute>

View File

@ -37,6 +37,7 @@ struct {
const gchar *accels[12];
} default_accels[] = {
{ "app.help", { "F1", NULL } },
{ "app.quit", { "<Primary>q", NULL } },
{ "app.new-window", { "<Primary>n", NULL } },
{ "app.open-capture", { "<Primary>o", NULL } },
{ "zoom.zoom-in", { "<Primary>plus", "<Primary>KP_Add", "<Primary>equal", "ZoomIn", NULL } },
@ -266,40 +267,6 @@ sysprof_open_capture (GSimpleAction *action,
}
}
static void
sysprof_show_help_overlay (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
{
GtkApplication *app = user_data;
SysprofWindow *window = NULL;
g_assert (G_IS_APPLICATION (app));
g_assert (G_IS_SIMPLE_ACTION (action));
g_assert (variant == NULL);
for (GList *list = gtk_application_get_windows (app); list; list = list->next)
{
GtkWindow *element = list->data;
if (SYSPROF_IS_WINDOW (element))
{
window = SYSPROF_WINDOW (element);
break;
}
}
if (window == NULL)
{
window = SYSPROF_WINDOW (sysprof_window_new (SYSPROF_APPLICATION (app)));
gtk_window_present (GTK_WINDOW (window));
}
g_assert (g_action_group_has_action (G_ACTION_GROUP (window), "show-help-overlay"));
g_action_group_activate_action (G_ACTION_GROUP (window), "show-help-overlay", NULL);
}
static void
sysprof_application_init (SysprofApplication *self)
{
@ -308,7 +275,6 @@ sysprof_application_init (SysprofApplication *self)
{ "new-window", sysprof_new_window },
{ "open-capture", sysprof_open_capture },
{ "help", sysprof_help },
{ "show-help-overlay", sysprof_show_help_overlay },
{ "quit", sysprof_quit },
};