[sysprof] counters: use counter description in menu item
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] counters: use counter description in menu item
- Date: Wed, 22 Jan 2020 05:06:39 +0000 (UTC)
commit 812b0d60a070fd17c14a38c82b386ae4bc646445
Author: Christian Hergert <chergert redhat com>
Date: Tue Jan 21 21:01:47 2020 -0800
counters: use counter description in menu item
src/libsysprof-ui/sysprof-counters-aid.c | 38 +++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
---
diff --git a/src/libsysprof-ui/sysprof-counters-aid.c b/src/libsysprof-ui/sysprof-counters-aid.c
index 86a9f27..2324569 100644
--- a/src/libsysprof-ui/sysprof-counters-aid.c
+++ b/src/libsysprof-ui/sysprof-counters-aid.c
@@ -87,6 +87,42 @@ sysprof_counters_aid_prepare (SysprofAid *self,
{
}
+static gchar *
+build_title (const SysprofCaptureCounter *ctr)
+{
+ GString *str;
+
+ str = g_string_new (NULL);
+
+ if (ctr->category[0] != 0)
+ {
+ if (str->len)
+ g_string_append_c (str, ' ');
+ g_string_append (str, ctr->category);
+ }
+
+ if (ctr->name[0] != 0)
+ {
+ if (str->len)
+ g_string_append (str, " — ");
+ g_string_append (str, ctr->name);
+ }
+
+ if (ctr->description[0] != 0)
+ {
+ if (str->len)
+ g_string_append_printf (str, " (%s)", ctr->description);
+ else
+ g_string_append (str, ctr->description);
+ }
+
+ if (str->len == 0)
+ /* this is untranslated on purpose */
+ g_string_append_printf (str, "Counter %d", ctr->id);
+
+ return g_string_free (str, FALSE);
+}
+
static gboolean
collect_counters (const SysprofCaptureFrame *frame,
gpointer user_data)
@@ -196,7 +232,7 @@ sysprof_counters_aid_present_finish (SysprofAid *aid,
for (guint i = 0; i < counters->len; i++)
{
const SysprofCaptureCounter *ctr = &g_array_index (counters, SysprofCaptureCounter, i);
- g_autofree gchar *title = g_strdup_printf ("%s — %s", ctr->category, ctr->name);
+ g_autofree gchar *title = build_title (ctr);
GtkWidget *row;
GdkRGBA rgba;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]