sysprof: make descendants menu translatable

Fixes: #144
This commit is contained in:
Christian Hergert
2025-05-16 15:01:36 -07:00
parent 4e199accac
commit a4f37fd740
5 changed files with 90 additions and 41 deletions

View File

@ -19,6 +19,7 @@ src/libsysprof/sysprof-tracer.c
src/sysprof-cli/sysprof-cli.c
src/sysprofd/org.gnome.sysprof3.policy.in
src/sysprof/gtk/help-overlay.ui
src/sysprof/gtk/menus.ui
src/sysprof/sysprof-animation.c
src/sysprof/sysprof-application.c
src/sysprof/sysprof-callgraph-view.ui

42
src/sysprof/gtk/menus.ui Normal file
View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="descendant_menu">
<section>
<item>
<attribute name="label" translatable="yes">Make Function Root</attribute>
<attribute name="action">callgraph.make-descendant-root</attribute>
</item>
</section>
<section>
<attribute name="label" translatable="yes">Options</attribute>
<item>
<attribute name="label" translatable="yes">Categorize Frames</attribute>
<attribute name="action">win.callgraph.categorize-frames</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Hide System Libraries</attribute>
<attribute name="action">win.callgraph.hide-system-libraries</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Include Threads</attribute>
<attribute name="action">win.callgraph.include-threads</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Bottom Up</attribute>
<attribute name="action">win.callgraph.bottom-up</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Ignore Kernel Processes</attribute>
<attribute name="action">win.callgraph.ignore-kernel-processes</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Ignore Process 0</attribute>
<attribute name="action">win.callgraph.ignore-process-0</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Merge Similar Processes</attribute>
<attribute name="action">win.callgraph.merge-similar-processes</attribute>
</item>
</section>
</menu>
</interface>

View File

@ -32,7 +32,7 @@ struct _SysprofApplication
AdwApplication parent_instance;
};
G_DEFINE_TYPE (SysprofApplication, sysprof_application, ADW_TYPE_APPLICATION)
G_DEFINE_FINAL_TYPE (SysprofApplication, sysprof_application, ADW_TYPE_APPLICATION)
static const GOptionEntry option_entries[] = {
{ "greeter", 'g', 0, G_OPTION_ARG_NONE, NULL, N_("Start a new recording") },
@ -40,6 +40,14 @@ static const GOptionEntry option_entries[] = {
{ 0 }
};
enum {
PROP_0,
PROP_DESCENDANT_MENU,
N_PROPS
};
static GParamSpec *properties[N_PROPS];
static void
sysprof_application_activate (GApplication *app)
{
@ -149,18 +157,48 @@ sysprof_application_window_added (GtkApplication *application,
GTK_APPLICATION_CLASS (sysprof_application_parent_class)->window_added (application, window);
}
static void
sysprof_application_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SysprofApplication *self = SYSPROF_APPLICATION (object);
switch (prop_id)
{
case PROP_DESCENDANT_MENU:
g_value_set_object (value, gtk_application_get_menu_by_id (GTK_APPLICATION (self), "descendant_menu"));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
sysprof_application_class_init (SysprofApplicationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GApplicationClass *app_class = G_APPLICATION_CLASS (klass);
GtkApplicationClass *gtk_app_class = GTK_APPLICATION_CLASS (klass);
object_class->get_property = sysprof_application_get_property;
app_class->open = sysprof_application_open;
app_class->activate = sysprof_application_activate;
app_class->command_line = sysprof_application_command_line;
app_class->handle_local_options = sysprof_application_handle_local_options;
gtk_app_class->window_added = sysprof_application_window_added;
properties[PROP_DESCENDANT_MENU] =
g_param_spec_object ("descendant-menu", NULL, NULL,
G_TYPE_MENU_MODEL,
(G_PARAM_READABLE|
G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void

View File

@ -158,7 +158,13 @@
<property name="child">
<object class="SysprofTreeExpander" id="expander">
<property name="focusable">true</property>
<property name="menu-model">menu_model</property>
<binding name="menu-model">
<lookup name="descendant-menu" type="SysprofApplication">
<lookup name="application" type="GtkWindow">
<lookup name="root">expander</lookup>
</lookup>
</lookup>
</binding>
<property name="has-tooltip">true</property>
<binding name="tooltip-text">
<lookup name="tooltip-text" type="SysprofSymbol">
@ -246,45 +252,6 @@
</object>
</property>
</template>
<menu id="menu_model">
<section>
<item>
<attribute name="label" translatable="yes">Make Function Root</attribute>
<attribute name="action">callgraph.make-descendant-root</attribute>
</item>
</section>
<section>
<attribute name="label" translatable="yes">Options</attribute>
<item>
<attribute name="label" translatable="yes">Categorize Frames</attribute>
<attribute name="action">win.callgraph.categorize-frames</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Hide System Libraries</attribute>
<attribute name="action">win.callgraph.hide-system-libraries</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Include Threads</attribute>
<attribute name="action">win.callgraph.include-threads</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Bottom Up</attribute>
<attribute name="action">win.callgraph.bottom-up</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Ignore Kernel Processes</attribute>
<attribute name="action">win.callgraph.ignore-kernel-processes</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Ignore Process 0</attribute>
<attribute name="action">win.callgraph.ignore-process-0</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Merge Similar Processes</attribute>
<attribute name="action">win.callgraph.merge-similar-processes</attribute>
</item>
</section>
</menu>
</interface>
]]></property>
</object>

View File

@ -59,6 +59,7 @@
<file preprocess="xml-stripblanks">sysprof-traceables-utility.ui</file>
<file preprocess="xml-stripblanks">sysprof-weighted-callgraph-view.ui</file>
<file preprocess="xml-stripblanks">sysprof-window.ui</file>
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
<file>style.css</file>
</gresource>
</gresources>