mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
sysprof: add dbus utility
This allows viewing the message contents that were captured in a textview within the utility pane. We already limit the max size of a message in the capture file, so presumably messages are relatively small enough to fit here.
This commit is contained in:
@ -51,6 +51,7 @@ enum {
|
|||||||
PROP_SIGNATURE,
|
PROP_SIGNATURE,
|
||||||
PROP_SENDER,
|
PROP_SENDER,
|
||||||
PROP_SERIAL,
|
PROP_SERIAL,
|
||||||
|
PROP_STRING,
|
||||||
N_PROPS
|
N_PROPS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -130,6 +131,10 @@ sysprof_document_dbus_message_get_property (GObject *object,
|
|||||||
g_value_set_string (value, sysprof_document_dbus_message_get_signature (self));
|
g_value_set_string (value, sysprof_document_dbus_message_get_signature (self));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_STRING:
|
||||||
|
g_value_take_string (value, sysprof_document_dbus_message_dup_string (self));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
}
|
}
|
||||||
@ -214,6 +219,11 @@ sysprof_document_dbus_message_class_init (SysprofDocumentDBusMessageClass *klass
|
|||||||
0,
|
0,
|
||||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties[PROP_STRING] =
|
||||||
|
g_param_spec_string ("string", NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,3 +454,16 @@ sysprof_document_dbus_message_get_bus_type (SysprofDocumentDBusMessage *self)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
sysprof_document_dbus_message_dup_string (SysprofDocumentDBusMessage *self)
|
||||||
|
{
|
||||||
|
g_autoptr(GDBusMessage) message = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_DBUS_MESSAGE (self), NULL);
|
||||||
|
|
||||||
|
if (!(message = sysprof_document_dbus_message_dup_message (self)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return g_dbus_message_print (message, 0);
|
||||||
|
}
|
||||||
|
|||||||
@ -65,6 +65,8 @@ SYSPROF_AVAILABLE_IN_ALL
|
|||||||
GDBusMessageFlags sysprof_document_dbus_message_get_flags (SysprofDocumentDBusMessage *self);
|
GDBusMessageFlags sysprof_document_dbus_message_get_flags (SysprofDocumentDBusMessage *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
GBusType sysprof_document_dbus_message_get_bus_type (SysprofDocumentDBusMessage *self);
|
GBusType sysprof_document_dbus_message_get_bus_type (SysprofDocumentDBusMessage *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
char *sysprof_document_dbus_message_dup_string (SysprofDocumentDBusMessage *self);
|
||||||
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofDocumentDBusMessage, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofDocumentDBusMessage, g_object_unref)
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,7 @@ sysprof_sources = [
|
|||||||
'sysprof-cpu-section.c',
|
'sysprof-cpu-section.c',
|
||||||
'sysprof-css.c',
|
'sysprof-css.c',
|
||||||
'sysprof-dbus-section.c',
|
'sysprof-dbus-section.c',
|
||||||
|
'sysprof-dbus-utility.c',
|
||||||
'sysprof-duplex-layer.c',
|
'sysprof-duplex-layer.c',
|
||||||
'sysprof-energy-section.c',
|
'sysprof-energy-section.c',
|
||||||
'sysprof-files-section.c',
|
'sysprof-files-section.c',
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "sysprof-chart.h"
|
#include "sysprof-chart.h"
|
||||||
#include "sysprof-dbus-section.h"
|
#include "sysprof-dbus-section.h"
|
||||||
|
#include "sysprof-dbus-utility.h"
|
||||||
#include "sysprof-line-layer.h"
|
#include "sysprof-line-layer.h"
|
||||||
#include "sysprof-time-filter-model.h"
|
#include "sysprof-time-filter-model.h"
|
||||||
#include "sysprof-time-scrubber.h"
|
#include "sysprof-time-scrubber.h"
|
||||||
@ -184,6 +185,7 @@ sysprof_dbus_section_class_init (SysprofDBusSectionClass *klass)
|
|||||||
gtk_widget_class_bind_template_callback (widget_class, format_message_type);
|
gtk_widget_class_bind_template_callback (widget_class, format_message_type);
|
||||||
|
|
||||||
g_type_ensure (SYSPROF_TYPE_CHART);
|
g_type_ensure (SYSPROF_TYPE_CHART);
|
||||||
|
g_type_ensure (SYSPROF_TYPE_DBUS_UTILITY);
|
||||||
g_type_ensure (SYSPROF_TYPE_DOCUMENT_MARK);
|
g_type_ensure (SYSPROF_TYPE_DOCUMENT_MARK);
|
||||||
g_type_ensure (SYSPROF_TYPE_DOCUMENT_DBUS_MESSAGE);
|
g_type_ensure (SYSPROF_TYPE_DOCUMENT_DBUS_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,7 +74,7 @@
|
|||||||
<property name="show-column-separators">true</property>
|
<property name="show-column-separators">true</property>
|
||||||
<property name="show-row-separators">true</property>
|
<property name="show-row-separators">true</property>
|
||||||
<property name="model">
|
<property name="model">
|
||||||
<object class="GtkSingleSelection">
|
<object class="GtkSingleSelection" id="selection">
|
||||||
<property name="model">
|
<property name="model">
|
||||||
<object class="GtkSortListModel">
|
<object class="GtkSortListModel">
|
||||||
<binding name="sorter">
|
<binding name="sorter">
|
||||||
@ -555,9 +555,12 @@
|
|||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<property name="utility">
|
||||||
|
<object class="SysprofDBusUtility">
|
||||||
|
<binding name="message">
|
||||||
|
<lookup name="selected-item">selection</lookup>
|
||||||
|
</binding>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
</template>
|
</template>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
133
src/sysprof/sysprof-dbus-utility.c
Normal file
133
src/sysprof/sysprof-dbus-utility.c
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/* sysprof-dbus-utility.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-dbus-utility.h"
|
||||||
|
|
||||||
|
struct _SysprofDBusUtility
|
||||||
|
{
|
||||||
|
GtkWidget parent_instance;
|
||||||
|
SysprofDocumentDBusMessage *message;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_MESSAGE,
|
||||||
|
N_PROPS
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_FINAL_TYPE (SysprofDBusUtility, sysprof_dbus_utility, GTK_TYPE_WIDGET)
|
||||||
|
|
||||||
|
static GParamSpec *properties [N_PROPS];
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_dbus_utility_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
SysprofDBusUtility *self = (SysprofDBusUtility *)object;
|
||||||
|
|
||||||
|
g_clear_object (&self->message);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (sysprof_dbus_utility_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_dbus_utility_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
SysprofDBusUtility *self = SYSPROF_DBUS_UTILITY (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_MESSAGE:
|
||||||
|
g_value_set_object (value, sysprof_dbus_utility_get_message (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_dbus_utility_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
SysprofDBusUtility *self = SYSPROF_DBUS_UTILITY (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_MESSAGE:
|
||||||
|
sysprof_dbus_utility_set_message (self, g_value_get_object (value));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_dbus_utility_class_init (SysprofDBusUtilityClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->finalize = sysprof_dbus_utility_finalize;
|
||||||
|
object_class->get_property = sysprof_dbus_utility_get_property;
|
||||||
|
object_class->set_property = sysprof_dbus_utility_set_property;
|
||||||
|
|
||||||
|
properties[PROP_MESSAGE] =
|
||||||
|
g_param_spec_object ("message", NULL, NULL,
|
||||||
|
SYSPROF_TYPE_DOCUMENT_DBUS_MESSAGE,
|
||||||
|
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
|
||||||
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-dbus-utility.ui");
|
||||||
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_dbus_utility_init (SysprofDBusUtility *self)
|
||||||
|
{
|
||||||
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
}
|
||||||
|
|
||||||
|
SysprofDocumentDBusMessage *
|
||||||
|
sysprof_dbus_utility_get_message (SysprofDBusUtility *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DBUS_UTILITY (self), NULL);
|
||||||
|
|
||||||
|
return self->message;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sysprof_dbus_utility_set_message (SysprofDBusUtility *self,
|
||||||
|
SysprofDocumentDBusMessage *message)
|
||||||
|
{
|
||||||
|
g_return_if_fail (SYSPROF_IS_DBUS_UTILITY (self));
|
||||||
|
g_return_if_fail (!message || SYSPROF_IS_DOCUMENT_DBUS_MESSAGE (message));
|
||||||
|
|
||||||
|
if (g_set_object (&self->message, message))
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MESSAGE]);
|
||||||
|
}
|
||||||
37
src/sysprof/sysprof-dbus-utility.h
Normal file
37
src/sysprof/sysprof-dbus-utility.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/* sysprof-dbus-utility.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 <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include <sysprof.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define SYSPROF_TYPE_DBUS_UTILITY (sysprof_dbus_utility_get_type())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (SysprofDBusUtility, sysprof_dbus_utility, SYSPROF, DBUS_UTILITY, GtkWidget)
|
||||||
|
|
||||||
|
SysprofDocumentDBusMessage *sysprof_dbus_utility_get_message (SysprofDBusUtility *self);
|
||||||
|
void sysprof_dbus_utility_set_message (SysprofDBusUtility *self,
|
||||||
|
SysprofDocumentDBusMessage *message);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
45
src/sysprof/sysprof-dbus-utility.ui
Normal file
45
src/sysprof/sysprof-dbus-utility.ui
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="SysprofDBusUtility" parent="GtkWidget">
|
||||||
|
<child>
|
||||||
|
<object class="AdwToolbarView">
|
||||||
|
<style>
|
||||||
|
<class name="utility"/>
|
||||||
|
</style>
|
||||||
|
<child type="top">
|
||||||
|
<object class="AdwHeaderBar">
|
||||||
|
<child type="title">
|
||||||
|
<object class="AdwWindowTitle">
|
||||||
|
<property name="title" translatable="yes">Message</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<property name="content">
|
||||||
|
<object class="GtkScrolledWindow">
|
||||||
|
<property name="vexpand">true</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTextView">
|
||||||
|
<property name="editable">false</property>
|
||||||
|
<property name="monospace">true</property>
|
||||||
|
<property name="top-margin">3</property>
|
||||||
|
<property name="left-margin">3</property>
|
||||||
|
<property name="right-margin">3</property>
|
||||||
|
<property name="bottom-margin">3</property>
|
||||||
|
<property name="buffer">
|
||||||
|
<object class="GtkTextBuffer">
|
||||||
|
<binding name="text">
|
||||||
|
<lookup name="string" type="SysprofDocumentDBusMessage">
|
||||||
|
<lookup name="message">SysprofDBusUtility</lookup>
|
||||||
|
</lookup>
|
||||||
|
</binding>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
@ -22,6 +22,7 @@
|
|||||||
<file preprocess="xml-stripblanks">sysprof-cpu-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-cpu-section-counter.ui</file>
|
||||||
<file preprocess="xml-stripblanks">sysprof-dbus-section.ui</file>
|
<file preprocess="xml-stripblanks">sysprof-dbus-section.ui</file>
|
||||||
|
<file preprocess="xml-stripblanks">sysprof-dbus-utility.ui</file>
|
||||||
<file preprocess="xml-stripblanks">sysprof-energy-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-energy-section-counter.ui</file>
|
||||||
<file preprocess="xml-stripblanks">sysprof-files-section.ui</file>
|
<file preprocess="xml-stripblanks">sysprof-files-section.ui</file>
|
||||||
|
|||||||
Reference in New Issue
Block a user