From a4f37fd740c40c306048434f240bc4bbeccc728b Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 16 May 2025 15:01:36 -0700 Subject: [PATCH] sysprof: make descendants menu translatable Fixes: #144 --- po/POTFILES.in | 1 + src/sysprof/gtk/menus.ui | 42 ++++++++++++++++++++++++ src/sysprof/sysprof-application.c | 40 ++++++++++++++++++++++- src/sysprof/sysprof-callgraph-view.ui | 47 ++++----------------------- src/sysprof/sysprof.gresource.xml | 1 + 5 files changed, 90 insertions(+), 41 deletions(-) create mode 100644 src/sysprof/gtk/menus.ui diff --git a/po/POTFILES.in b/po/POTFILES.in index 5386cabb..2462c244 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -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 diff --git a/src/sysprof/gtk/menus.ui b/src/sysprof/gtk/menus.ui new file mode 100644 index 00000000..eb1d5ef6 --- /dev/null +++ b/src/sysprof/gtk/menus.ui @@ -0,0 +1,42 @@ + + + +
+ + Make Function Root + callgraph.make-descendant-root + +
+
+ Options + + Categorize Frames + win.callgraph.categorize-frames + + + Hide System Libraries + win.callgraph.hide-system-libraries + + + Include Threads + win.callgraph.include-threads + + + Bottom Up + win.callgraph.bottom-up + + + Ignore Kernel Processes + win.callgraph.ignore-kernel-processes + + + Ignore Process 0 + win.callgraph.ignore-process-0 + + + Merge Similar Processes + win.callgraph.merge-similar-processes + +
+
+
diff --git a/src/sysprof/sysprof-application.c b/src/sysprof/sysprof-application.c index b1ec0160..151c80b6 100644 --- a/src/sysprof/sysprof-application.c +++ b/src/sysprof/sysprof-application.c @@ -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 diff --git a/src/sysprof/sysprof-callgraph-view.ui b/src/sysprof/sysprof-callgraph-view.ui index 494d75a4..dd4061f6 100644 --- a/src/sysprof/sysprof-callgraph-view.ui +++ b/src/sysprof/sysprof-callgraph-view.ui @@ -158,7 +158,13 @@ true - menu_model + + + + expander + + + true @@ -246,45 +252,6 @@ - -
- - Make Function Root - callgraph.make-descendant-root - -
-
- Options - - Categorize Frames - win.callgraph.categorize-frames - - - Hide System Libraries - win.callgraph.hide-system-libraries - - - Include Threads - win.callgraph.include-threads - - - Bottom Up - win.callgraph.bottom-up - - - Ignore Kernel Processes - win.callgraph.ignore-kernel-processes - - - Ignore Process 0 - win.callgraph.ignore-process-0 - - - Merge Similar Processes - win.callgraph.merge-similar-processes - -
-
]]> diff --git a/src/sysprof/sysprof.gresource.xml b/src/sysprof/sysprof.gresource.xml index eb5d9307..e2474bbe 100644 --- a/src/sysprof/sysprof.gresource.xml +++ b/src/sysprof/sysprof.gresource.xml @@ -59,6 +59,7 @@ sysprof-traceables-utility.ui sysprof-weighted-callgraph-view.ui sysprof-window.ui + gtk/menus.ui style.css