From bc17b6d316736fbc354580a189828265d50f00b6 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 27 Jul 2023 14:21:15 -0700 Subject: [PATCH] sysprof: add D-Bus Message section to window --- .../icons/scalable/actions/dbus-symbolic.svg | 18 + src/sysprof/meson.build | 1 + src/sysprof/sysprof-dbus-section.c | 166 ++++++ src/sysprof/sysprof-dbus-section.h | 32 ++ src/sysprof/sysprof-dbus-section.ui | 513 ++++++++++++++++++ src/sysprof/sysprof-window.c | 2 + src/sysprof/sysprof-window.ui | 10 + src/sysprof/sysprof.gresource.xml | 2 + 8 files changed, 744 insertions(+) create mode 100644 src/sysprof/icons/scalable/actions/dbus-symbolic.svg create mode 100644 src/sysprof/sysprof-dbus-section.c create mode 100644 src/sysprof/sysprof-dbus-section.h create mode 100644 src/sysprof/sysprof-dbus-section.ui diff --git a/src/sysprof/icons/scalable/actions/dbus-symbolic.svg b/src/sysprof/icons/scalable/actions/dbus-symbolic.svg new file mode 100644 index 00000000..f160d690 --- /dev/null +++ b/src/sysprof/icons/scalable/actions/dbus-symbolic.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/sysprof/meson.build b/src/sysprof/meson.build index 92d86e4e..6a246d9e 100644 --- a/src/sysprof/meson.build +++ b/src/sysprof/meson.build @@ -14,6 +14,7 @@ sysprof_sources = [ 'sysprof-counters-section.c', 'sysprof-cpu-section.c', 'sysprof-css.c', + 'sysprof-dbus-section.c', 'sysprof-duplex-layer.c', 'sysprof-energy-section.c', 'sysprof-files-section.c', diff --git a/src/sysprof/sysprof-dbus-section.c b/src/sysprof/sysprof-dbus-section.c new file mode 100644 index 00000000..4439384a --- /dev/null +++ b/src/sysprof/sysprof-dbus-section.c @@ -0,0 +1,166 @@ +/* sysprof-dbus-section.c + * + * Copyright 2023 Christian Hergert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include "config.h" + +#include "sysprof-chart.h" +#include "sysprof-dbus-section.h" +#include "sysprof-line-layer.h" +#include "sysprof-time-filter-model.h" +#include "sysprof-time-scrubber.h" +#include "sysprof-time-series.h" +#include "sysprof-time-span-layer.h" +#include "sysprof-value-axis.h" +#include "sysprof-xy-series.h" + +struct _SysprofDBusSection +{ + SysprofSection parent_instance; + + SysprofTimeScrubber *scrubber; + GtkColumnView *column_view; + GtkColumnViewColumn *time_column; +}; + +G_DEFINE_FINAL_TYPE (SysprofDBusSection, sysprof_dbus_section, SYSPROF_TYPE_SECTION) + +static char * +format_size (gpointer data, + guint size) +{ + if (size == 0) + return NULL; + return g_format_size (size); +} + +static char * +format_serial (gpointer data, + guint serial) +{ + if (serial == 0 || serial == (guint)-1) + return NULL; + return g_strdup_printf ("0x%x", serial); +} + +static char * +format_message_type (gpointer data, + GDBusMessageType type) +{ + static GEnumClass *klass; + GEnumValue *value; + + if (klass == NULL) + klass = g_type_class_ref (G_TYPE_DBUS_MESSAGE_TYPE); + + if ((value = g_enum_get_value (klass, type))) + return g_strdup (value->value_nick); + + return NULL; +} + +char * +flags_to_string (GType type, + guint value) +{ + GFlagsClass *flags_class; + GFlagsValue *val; + GString *str; + + g_return_val_if_fail (G_TYPE_IS_FLAGS (type), NULL); + + if (value == 0) + return NULL; + + if (!(flags_class = g_type_class_ref (type))) + return NULL; + + if (flags_class == NULL) + return NULL; + + str = g_string_new (NULL); + + while ((str->len == 0 || value != 0) && + (val = g_flags_get_first_value (flags_class, value))) + { + if (str->len > 0) + g_string_append_c (str, '|'); + g_string_append (str, val->value_nick); + value &= ~val->value; + } + + if (value) + { + if (str->len > 0) + g_string_append_c (str, '|'); + g_string_append_printf (str, "0x%x", value); + } + + return g_string_free (str, FALSE); +} + +static char * +format_flags (gpointer data, + guint flags) +{ + if (flags == 0) + return NULL; + + return flags_to_string (G_TYPE_DBUS_MESSAGE_FLAGS, flags); +} + +static void +sysprof_dbus_section_dispose (GObject *object) +{ + SysprofDBusSection *self = (SysprofDBusSection *)object; + + gtk_widget_dispose_template (GTK_WIDGET (self), SYSPROF_TYPE_DBUS_SECTION); + + G_OBJECT_CLASS (sysprof_dbus_section_parent_class)->dispose (object); +} + +static void +sysprof_dbus_section_class_init (SysprofDBusSectionClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->dispose = sysprof_dbus_section_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-dbus-section.ui"); + gtk_widget_class_bind_template_child (widget_class, SysprofDBusSection, column_view); + gtk_widget_class_bind_template_child (widget_class, SysprofDBusSection, scrubber); + gtk_widget_class_bind_template_child (widget_class, SysprofDBusSection, time_column); + gtk_widget_class_bind_template_callback (widget_class, format_flags); + gtk_widget_class_bind_template_callback (widget_class, format_serial); + gtk_widget_class_bind_template_callback (widget_class, format_size); + gtk_widget_class_bind_template_callback (widget_class, format_message_type); + + g_type_ensure (SYSPROF_TYPE_CHART); + g_type_ensure (SYSPROF_TYPE_DOCUMENT_MARK); + g_type_ensure (SYSPROF_TYPE_DOCUMENT_DBUS_MESSAGE); +} + +static void +sysprof_dbus_section_init (SysprofDBusSection *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); + + gtk_column_view_sort_by_column (self->column_view, self->time_column, GTK_SORT_ASCENDING); +} diff --git a/src/sysprof/sysprof-dbus-section.h b/src/sysprof/sysprof-dbus-section.h new file mode 100644 index 00000000..de4b31eb --- /dev/null +++ b/src/sysprof/sysprof-dbus-section.h @@ -0,0 +1,32 @@ +/* sysprof-dbus-section.h + * + * Copyright 2023 Christian Hergert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "sysprof-section.h" + +G_BEGIN_DECLS + +#define SYSPROF_TYPE_DBUS_SECTION (sysprof_dbus_section_get_type()) + +G_DECLARE_FINAL_TYPE (SysprofDBusSection, sysprof_dbus_section, SYSPROF, DBUS_SECTION, SysprofSection) + +G_END_DECLS + diff --git a/src/sysprof/sysprof-dbus-section.ui b/src/sysprof/sysprof-dbus-section.ui new file mode 100644 index 00000000..3fb9872b --- /dev/null +++ b/src/sysprof/sysprof-dbus-section.ui @@ -0,0 +1,513 @@ + + + + + + + + diff --git a/src/sysprof/sysprof-window.c b/src/sysprof/sysprof-window.c index 27ad126e..cae586d4 100644 --- a/src/sysprof/sysprof-window.c +++ b/src/sysprof/sysprof-window.c @@ -24,6 +24,7 @@ #include "sysprof-counters-section.h" #include "sysprof-cpu-section.h" +#include "sysprof-dbus-section.h" #include "sysprof-energy-section.h" #include "sysprof-files-section.h" #include "sysprof-graphics-section.h" @@ -414,6 +415,7 @@ sysprof_window_class_init (SysprofWindowClass *klass) g_type_ensure (SYSPROF_TYPE_COUNTERS_SECTION); g_type_ensure (SYSPROF_TYPE_CPU_SECTION); + g_type_ensure (SYSPROF_TYPE_DBUS_SECTION); g_type_ensure (SYSPROF_TYPE_DOCUMENT); g_type_ensure (SYSPROF_TYPE_ENERGY_SECTION); g_type_ensure (SYSPROF_TYPE_FILES_SECTION); diff --git a/src/sysprof/sysprof-window.ui b/src/sysprof/sysprof-window.ui index a907bd9e..4b8c0485 100644 --- a/src/sysprof/sysprof-window.ui +++ b/src/sysprof/sysprof-window.ui @@ -206,6 +206,16 @@ + + + D-Bus Messages + processes + dbus-symbolic + + SysprofWindow + + + CPU Usage diff --git a/src/sysprof/sysprof.gresource.xml b/src/sysprof/sysprof.gresource.xml index 323f1fae..9f80c1e9 100644 --- a/src/sysprof/sysprof.gresource.xml +++ b/src/sysprof/sysprof.gresource.xml @@ -4,6 +4,7 @@ gtk/help-overlay.ui gtk/menus.ui icons/scalable/actions/address-layout-symbolic.svg + icons/scalable/actions/dbus-symbolic.svg icons/scalable/actions/empty-symbolic.svg icons/scalable/actions/energy-symbolic.svg icons/scalable/actions/graphics-symbolic.svg @@ -20,6 +21,7 @@ sysprof-counters-section.ui sysprof-cpu-section.ui sysprof-cpu-section-counter.ui + sysprof-dbus-section.ui sysprof-energy-section.ui sysprof-energy-section-counter.ui sysprof-files-section.ui