sysprof: add D-Bus Message section to window

This commit is contained in:
Christian Hergert
2023-07-27 14:21:15 -07:00
parent 19c3d90886
commit bc17b6d316
8 changed files with 744 additions and 0 deletions

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<filter id="a" height="100%" width="100%" x="0%" y="0%">
<feColorMatrix in="SourceGraphic" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
</filter>
<mask id="b">
<g filter="url(#a)">
<rect fill-opacity="0.170685" height="16" width="16"/>
</g>
</mask>
<clipPath id="c">
<rect height="152" width="192"/>
</clipPath>
<g clip-path="url(#c)" mask="url(#b)" transform="matrix(1 0 0 1 -168 -16)">
<path d="m 111.730469 76.027344 l -79.699219 -0.070313 l -0.140625 8.210938 l 80.160156 12.03125 z m 0 0"/>
</g>
<path d="m 4 2 v 4 h -2.5 c -0.277344 0 -0.5 0.222656 -0.5 0.5 s 0.222656 0.5 0.5 0.5 h 2.5 v 3.660156 l -2 -0.660156 v 5 h 12 v -5 l -2 0.671875 v -3.671875 h 2.5 c 0.277344 0 0.5 -0.222656 0.5 -0.5 s -0.222656 -0.5 -0.5 -0.5 h -2.5 v -4 l -4 2 z m 1 6 h 6 c 0 0.714844 -0.285156 1.375 -0.75 1.734375 c -0.464844 0.355469 -1.035156 0.355469 -1.5 0 c -0.464844 -0.359375 -0.75 -1.019531 -0.75 -1.734375 c 0 0.714844 -0.285156 1.375 -0.75 1.734375 c -0.464844 0.355469 -1.035156 0.355469 -1.5 0 c -0.464844 -0.359375 -0.75 -1.019531 -0.75 -1.734375 z m 0 0" fill-opacity="0.987422"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -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',

View File

@ -0,0 +1,166 @@
/* sysprof-dbus-section.c
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* 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);
}

View File

@ -0,0 +1,32 @@
/* sysprof-dbus-section.h
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* 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

View File

@ -0,0 +1,513 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="SysprofDBusSection" parent="SysprofSection">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="SysprofTimeScrubber" id="scrubber">
<binding name="session">
<lookup name="session">SysprofDBusSection</lookup>
</binding>
<child type="chart">
<object class="SysprofChart">
<binding name="session">
<lookup name="session">SysprofDBusSection</lookup>
</binding>
<property name="height-request">32</property>
<child>
<object class="SysprofTimeSpanLayer">
<binding name="axis">
<lookup name="visible-time-axis" type="SysprofSession">
<lookup name="session">SysprofDBusSection</lookup>
</lookup>
</binding>
<property name="series">
<object class="SysprofTimeSeries">
<property name="begin-time-expression">
<lookup name="time" type="SysprofDocumentFrame"/>
</property>
<property name="end-time-expression">
<lookup name="time" type="SysprofDocumentFrame"/>
</property>
<binding name="model">
<lookup name="dbus-messages" type="SysprofDocument">
<lookup name="document" type="SysprofSession">
<lookup name="session">SysprofDBusSection</lookup>
</lookup>
</lookup>
</binding>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparator"/>
</child>
<child>
<object class="AdwViewStack" id="stack">
<property name="vexpand">true</property>
<child>
<object class="AdwViewStackPage">
<property name="child">
<object class="GtkScrolledWindow">
<child>
<object class="GtkColumnView" id="column_view">
<style>
<class name="data-table"/>
</style>
<property name="show-column-separators">true</property>
<property name="show-row-separators">true</property>
<property name="model">
<object class="GtkSingleSelection">
<property name="model">
<object class="GtkSortListModel">
<binding name="sorter">
<lookup name="sorter">column_view</lookup>
</binding>
<property name="model">
<object class="SysprofTimeFilterModel">
<binding name="time-span">
<lookup name="selected-time" type="SysprofSession">
<lookup name="session">SysprofDBusSection</lookup>
</lookup>
</binding>
<binding name="model">
<lookup name="dbus-messages" type="SysprofDocument">
<lookup name="document" type="SysprofSession">
<lookup name="session">SysprofDBusSection</lookup>
</lookup>
</lookup>
</binding>
</object>
</property>
</object>
</property>
</object>
</property>
<child>
<object class="GtkColumnViewColumn" id="time_column">
<property name="title" translatable="yes">Time</property>
<property name="sorter">
<object class="GtkNumericSorter">
<property name="sort-order">ascending</property>
<property name="expression">
<lookup name="time-offset" type="SysprofDocumentDBusMessage"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="SysprofTimeLabel">
<binding name="time-offset">
<lookup name="time-offset" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title" translatable="yes">Serial</property>
<property name="sorter">
<object class="GtkNumericSorter">
<property name="sort-order">ascending</property>
<property name="expression">
<lookup name="serial" type="SysprofDocumentDBusMessage"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<closure type="gchararray" function="format_serial">
<lookup name="serial" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</closure>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title" translatable="yes">Reply</property>
<property name="sorter">
<object class="GtkNumericSorter">
<property name="sort-order">ascending</property>
<property name="expression">
<lookup name="reply-serial" type="SysprofDocumentDBusMessage"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<closure type="gchararray" function="format_serial">
<lookup name="reply-serial" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</closure>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title" translatable="yes">Flags</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<closure type="gchararray" function="format_flags">
<lookup name="flags" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</closure>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title" translatable="yes">Size</property>
<property name="sorter">
<object class="GtkNumericSorter">
<property name="expression">
<lookup name="message-length" type="SysprofDocumentDBusMessage"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<closure type="gchararray" function="format_size">
<lookup name="message-length" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</closure>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title" translatable="yes">Type</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<closure type="gchararray" function="format_message_type">
<lookup name="message-type" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</closure>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title" translatable="yes">Sender</property>
<property name="sorter">
<object class="GtkStringSorter">
<property name="expression">
<lookup name="sender" type="SysprofDocumentDBusMessage"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="sender" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title" translatable="yes">Destination</property>
<property name="sorter">
<object class="GtkStringSorter">
<property name="expression">
<lookup name="destination" type="SysprofDocumentDBusMessage"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="destination" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title" translatable="yes">Path</property>
<property name="sorter">
<object class="GtkStringSorter">
<property name="expression">
<lookup name="path" type="SysprofDocumentDBusMessage"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="path" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title" translatable="yes">Interface</property>
<property name="sorter">
<object class="GtkStringSorter">
<property name="expression">
<lookup name="destination" type="SysprofDocumentDBusMessage"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="interface" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title" translatable="yes">Member</property>
<property name="sorter">
<object class="GtkStringSorter">
<property name="expression">
<lookup name="member" type="SysprofDocumentDBusMessage"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="member" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title" translatable="yes">Signature</property>
<property name="sorter">
<object class="GtkStringSorter">
<property name="expression">
<lookup name="signature" type="SysprofDocumentDBusMessage"/>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="signature" type="SysprofDocumentDBusMessage">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@ -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);

View File

@ -206,6 +206,16 @@
</binding>
</object>
</child>
<child>
<object class="SysprofDBusSection">
<property name="title" translatable="yes">D-Bus Messages</property>
<property name="category">processes</property>
<property name="icon-name">dbus-symbolic</property>
<binding name="session">
<lookup name="session">SysprofWindow</lookup>
</binding>
</object>
</child>
<child>
<object class="SysprofCpuSection">
<property name="title" translatable="yes">CPU Usage</property>

View File

@ -4,6 +4,7 @@
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/address-layout-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/dbus-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/empty-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/energy-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/graphics-symbolic.svg</file>
@ -20,6 +21,7 @@
<file preprocess="xml-stripblanks">sysprof-counters-section.ui</file>
<file preprocess="xml-stripblanks">sysprof-cpu-section.ui</file>
<file preprocess="xml-stripblanks">sysprof-cpu-section-counter.ui</file>
<file preprocess="xml-stripblanks">sysprof-dbus-section.ui</file>
<file preprocess="xml-stripblanks">sysprof-energy-section.ui</file>
<file preprocess="xml-stripblanks">sysprof-energy-section-counter.ui</file>
<file preprocess="xml-stripblanks">sysprof-files-section.ui</file>