mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-ui: stub out proxy source
The goal for this (which is unfinished) is to setup a dbus proxy to the peer. That can be reused for both gtk and mutter, if configured correctly. We'll likely need to allow some specific config tweaks in the UI.
This commit is contained in:
@ -17,6 +17,7 @@ libsysprof_ui_public_sources = [
|
||||
'sysprof-model-filter.c',
|
||||
'sysprof-notebook.c',
|
||||
'sysprof-process-model-row.c',
|
||||
'sysprof-proxy-aid.c',
|
||||
'sysprof-profiler-assistant.c',
|
||||
'sysprof-profiler-menu-button.c',
|
||||
'sysprof-recording-state-view.c',
|
||||
@ -64,6 +65,7 @@ libsysprof_ui_public_headers = [
|
||||
'sysprof-model-filter.h',
|
||||
'sysprof-notebook.h',
|
||||
'sysprof-process-model-row.h',
|
||||
'sysprof-proxy-aid.h',
|
||||
'sysprof-profiler-assistant.h',
|
||||
'sysprof-profiler-menu-button.h',
|
||||
'sysprof-recording-state-view.h',
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "sysprof-cpu-aid.h"
|
||||
#include "sysprof-environ-editor.h"
|
||||
#include "sysprof-profiler-assistant.h"
|
||||
#include "sysprof-proxy-aid.h"
|
||||
#include "sysprof-process-model-row.h"
|
||||
|
||||
struct _SysprofProfilerAssistant
|
||||
@ -267,6 +268,7 @@ sysprof_profiler_assistant_class_init (SysprofProfilerAssistantClass *klass)
|
||||
|
||||
g_type_ensure (SYSPROF_TYPE_AID_ICON);
|
||||
g_type_ensure (SYSPROF_TYPE_CPU_AID);
|
||||
g_type_ensure (SYSPROF_TYPE_PROXY_AID);
|
||||
g_type_ensure (SYSPROF_TYPE_ENVIRON_EDITOR);
|
||||
}
|
||||
|
||||
|
||||
209
src/libsysprof-ui/sysprof-proxy-aid.c
Normal file
209
src/libsysprof-ui/sysprof-proxy-aid.c
Normal file
@ -0,0 +1,209 @@
|
||||
/* sysprof-proxy-aid.c
|
||||
*
|
||||
* Copyright 2019 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
|
||||
*/
|
||||
|
||||
#define G_LOG_DOMAIN "sysprof-proxy-aid"
|
||||
|
||||
#include "sysprof-proxy-aid.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GBusType bus_type;
|
||||
gchar *bus_name;
|
||||
gchar *object_path;
|
||||
} SysprofProxyAidPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_BUS_TYPE,
|
||||
PROP_BUS_NAME,
|
||||
PROP_OBJECT_PATH,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (SysprofProxyAid, sysprof_proxy_aid, SYSPROF_TYPE_AID)
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
sysprof_proxy_aid_prepare (SysprofAid *aid,
|
||||
SysprofProfiler *profiler)
|
||||
{
|
||||
SysprofProxyAid *self = (SysprofProxyAid *)aid;
|
||||
SysprofProxyAidPrivate *priv = sysprof_proxy_aid_get_instance_private (self);
|
||||
g_autoptr(SysprofSource) source = NULL;
|
||||
|
||||
g_assert (SYSPROF_IS_PROXY_AID (self));
|
||||
g_assert (SYSPROF_IS_PROFILER (profiler));
|
||||
|
||||
source = sysprof_proxy_source_new (priv->bus_type, priv->bus_name, priv->object_path);
|
||||
sysprof_profiler_add_source (profiler, source);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_proxy_aid_finalize (GObject *object)
|
||||
{
|
||||
SysprofProxyAid *self = (SysprofProxyAid *)object;
|
||||
SysprofProxyAidPrivate *priv = sysprof_proxy_aid_get_instance_private (self);
|
||||
|
||||
g_clear_pointer (&priv->bus_name, g_free);
|
||||
g_clear_pointer (&priv->object_path, g_free);
|
||||
|
||||
G_OBJECT_CLASS (sysprof_proxy_aid_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_proxy_aid_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofProxyAid *self = SYSPROF_PROXY_AID (object);
|
||||
SysprofProxyAidPrivate *priv = sysprof_proxy_aid_get_instance_private (self);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_BUS_NAME:
|
||||
g_value_set_string (value, priv->bus_name);
|
||||
break;
|
||||
|
||||
case PROP_OBJECT_PATH:
|
||||
g_value_set_string (value, priv->object_path);
|
||||
break;
|
||||
|
||||
case PROP_BUS_TYPE:
|
||||
g_value_set_enum (value, priv->bus_type);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_proxy_aid_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofProxyAid *self = SYSPROF_PROXY_AID (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_BUS_NAME:
|
||||
sysprof_proxy_aid_set_bus_name (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_BUS_TYPE:
|
||||
sysprof_proxy_aid_set_bus_type (self, g_value_get_enum (value));
|
||||
break;
|
||||
|
||||
case PROP_OBJECT_PATH:
|
||||
sysprof_proxy_aid_set_object_path (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_proxy_aid_class_init (SysprofProxyAidClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
SysprofAidClass *aid_class = SYSPROF_AID_CLASS (klass);
|
||||
|
||||
object_class->finalize = sysprof_proxy_aid_finalize;
|
||||
object_class->get_property = sysprof_proxy_aid_get_property;
|
||||
object_class->set_property = sysprof_proxy_aid_set_property;
|
||||
|
||||
aid_class->prepare = sysprof_proxy_aid_prepare;
|
||||
|
||||
properties [PROP_OBJECT_PATH] =
|
||||
g_param_spec_string ("object-path", NULL, NULL,
|
||||
NULL,
|
||||
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties [PROP_BUS_NAME] =
|
||||
g_param_spec_string ("bus-name", NULL, NULL,
|
||||
NULL,
|
||||
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties [PROP_BUS_TYPE] =
|
||||
g_param_spec_enum ("bus-type", NULL, NULL,
|
||||
G_TYPE_BUS_TYPE,
|
||||
G_BUS_TYPE_SESSION,
|
||||
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_proxy_aid_init (SysprofProxyAid *self)
|
||||
{
|
||||
SysprofProxyAidPrivate *priv = sysprof_proxy_aid_get_instance_private (self);
|
||||
|
||||
priv->bus_type = G_BUS_TYPE_SESSION;
|
||||
priv->object_path = g_strdup ("/org/gnome/Sysprof3/Profiler");
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_proxy_aid_set_bus_type (SysprofProxyAid *self,
|
||||
GBusType bus_type)
|
||||
{
|
||||
SysprofProxyAidPrivate *priv = sysprof_proxy_aid_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (SYSPROF_IS_PROXY_AID (self));
|
||||
g_return_if_fail (bus_type == G_BUS_TYPE_SESSION || bus_type == G_BUS_TYPE_SYSTEM);
|
||||
|
||||
priv->bus_type = bus_type;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_BUS_TYPE]);
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_proxy_aid_set_bus_name (SysprofProxyAid *self,
|
||||
const gchar *bus_name)
|
||||
{
|
||||
SysprofProxyAidPrivate *priv = sysprof_proxy_aid_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (SYSPROF_IS_PROXY_AID (self));
|
||||
|
||||
if (g_strcmp0 (bus_name, priv->bus_name) != 0)
|
||||
{
|
||||
g_free (priv->bus_name);
|
||||
priv->bus_name = g_strdup (bus_name);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_BUS_NAME]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_proxy_aid_set_object_path (SysprofProxyAid *self,
|
||||
const gchar *object_path)
|
||||
{
|
||||
SysprofProxyAidPrivate *priv = sysprof_proxy_aid_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (SYSPROF_IS_PROXY_AID (self));
|
||||
|
||||
if (g_strcmp0 (object_path, priv->object_path) != 0)
|
||||
{
|
||||
g_free (priv->object_path);
|
||||
priv->object_path = g_strdup (object_path);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_OBJECT_PATH]);
|
||||
}
|
||||
}
|
||||
49
src/libsysprof-ui/sysprof-proxy-aid.h
Normal file
49
src/libsysprof-ui/sysprof-proxy-aid.h
Normal file
@ -0,0 +1,49 @@
|
||||
/* sysprof-proxy-aid.h
|
||||
*
|
||||
* Copyright 2019 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-aid.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_PROXY_AID (sysprof_proxy_aid_get_type())
|
||||
|
||||
G_DECLARE_DERIVABLE_TYPE (SysprofProxyAid, sysprof_proxy_aid, SYSPROF, PROXY_AID, SysprofAid)
|
||||
|
||||
struct _SysprofProxyAidClass
|
||||
{
|
||||
SysprofAidClass parent_class;
|
||||
|
||||
/*< private >*/
|
||||
gpointer _reserved[8];
|
||||
};
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_proxy_aid_set_bus_type (SysprofProxyAid *self,
|
||||
GBusType bus_type);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_proxy_aid_set_bus_name (SysprofProxyAid *self,
|
||||
const gchar *bus_name);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_proxy_aid_set_object_path (SysprofProxyAid *self,
|
||||
const gchar *obj_path);
|
||||
|
||||
G_END_DECLS
|
||||
@ -47,6 +47,7 @@ G_BEGIN_DECLS
|
||||
# include "sysprof-process-model-row.h"
|
||||
# include "sysprof-profiler-assistant.h"
|
||||
# include "sysprof-profiler-menu-button.h"
|
||||
# include "sysprof-proxy-aid.h"
|
||||
# include "sysprof-recording-state-view.h"
|
||||
# include "sysprof-visualizer-row.h"
|
||||
# include "sysprof-visualizer-view.h"
|
||||
|
||||
@ -4,6 +4,13 @@
|
||||
<object class="SysprofCpuAid" id="cpu_aid"/>
|
||||
<object class="SysprofMemoryAid" id="memory_aid"/>
|
||||
<object class="SysprofCallgraphAid" id="callgraph_aid"/>
|
||||
<object class="SysprofProxyAid" id="mutter_aid">
|
||||
<property name="object-path">/org/gnome/Sysprof3/Profiler</property>
|
||||
<property name="bus-type">session</property>
|
||||
<property name="bus-name">org.gnome.Mutter</property>
|
||||
<property name="display-name">Display Compositor</property>
|
||||
<property name="icon-name">org.gnome.Sysprof-symbolic</property>
|
||||
</object>
|
||||
<template class="SysprofProfilerAssistant" parent="GtkBin">
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
@ -66,6 +73,12 @@
|
||||
<property name="visible">true</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="SysprofAidIcon">
|
||||
<property name="aid">mutter_aid</property>
|
||||
<property name="visible">true</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="column">center</property>
|
||||
|
||||
@ -15,6 +15,7 @@ libsysprof_public_sources = [
|
||||
'sysprof-process-model-item.c',
|
||||
'sysprof-profile.c',
|
||||
'sysprof-profiler.c',
|
||||
'sysprof-proxy-source.c',
|
||||
'sysprof-selection.c',
|
||||
'sysprof-source.c',
|
||||
'sysprof-symbol-dirs.c',
|
||||
@ -36,6 +37,7 @@ libsysprof_public_headers = [
|
||||
'sysprof-process-model-item.h',
|
||||
'sysprof-profile.h',
|
||||
'sysprof-profiler.h',
|
||||
'sysprof-proxy-source.h',
|
||||
'sysprof-selection.h',
|
||||
'sysprof-source.h',
|
||||
'sysprof-symbol-dirs.h',
|
||||
|
||||
116
src/libsysprof/sysprof-proxy-source.c
Normal file
116
src/libsysprof/sysprof-proxy-source.c
Normal file
@ -0,0 +1,116 @@
|
||||
/* sysprof-proxy-source.c
|
||||
*
|
||||
* Copyright 2019 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
|
||||
*/
|
||||
|
||||
#define G_LOG_DOMAIN "sysprof-proxy-source"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sysprof-proxy-source.h"
|
||||
|
||||
struct _SysprofProxySource
|
||||
{
|
||||
GObject parent_instance;
|
||||
gchar *bus_name;
|
||||
gchar *object_path;
|
||||
GBusType bus_type;
|
||||
};
|
||||
|
||||
static void
|
||||
sysprof_proxy_source_prepare (SysprofSource *source)
|
||||
{
|
||||
SysprofProxySource *self = (SysprofProxySource *)source;
|
||||
|
||||
g_assert (SYSPROF_IS_PROXY_SOURCE (self));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sysprof_proxy_source_get_is_ready (SysprofSource *source)
|
||||
{
|
||||
SysprofProxySource *self = (SysprofProxySource *)source;
|
||||
|
||||
g_assert (SYSPROF_IS_PROXY_SOURCE (self));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_proxy_source_set_writer (SysprofSource *source,
|
||||
SysprofCaptureWriter *writer)
|
||||
{
|
||||
SysprofProxySource *self = (SysprofProxySource *)source;
|
||||
|
||||
g_assert (SYSPROF_IS_PROXY_SOURCE (self));
|
||||
g_assert (writer != NULL);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
source_iface_init (SysprofSourceInterface *iface)
|
||||
{
|
||||
iface->prepare = sysprof_proxy_source_prepare;
|
||||
iface->set_writer = sysprof_proxy_source_set_writer;
|
||||
iface->get_is_ready = sysprof_proxy_source_get_is_ready;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (SysprofProxySource, sysprof_proxy_source, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_SOURCE, source_iface_init))
|
||||
|
||||
static void
|
||||
sysprof_proxy_source_finalize (GObject *object)
|
||||
{
|
||||
SysprofProxySource *self = (SysprofProxySource *)object;
|
||||
|
||||
g_clear_pointer (&self->bus_name, g_free);
|
||||
g_clear_pointer (&self->object_path, g_free);
|
||||
|
||||
G_OBJECT_CLASS (sysprof_proxy_source_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_proxy_source_class_init (SysprofProxySourceClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = sysprof_proxy_source_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_proxy_source_init (SysprofProxySource *self)
|
||||
{
|
||||
}
|
||||
|
||||
SysprofSource *
|
||||
sysprof_proxy_source_new (GBusType bus_type,
|
||||
const gchar *bus_name,
|
||||
const gchar *object_path)
|
||||
{
|
||||
SysprofProxySource *self;
|
||||
|
||||
g_return_val_if_fail (bus_type == G_BUS_TYPE_SESSION || bus_type == G_BUS_TYPE_SYSTEM, NULL);
|
||||
g_return_val_if_fail (bus_name != NULL, NULL);
|
||||
g_return_val_if_fail (object_path != NULL, NULL);
|
||||
|
||||
self = g_object_new (SYSPROF_TYPE_PROXY_SOURCE, NULL);
|
||||
self->bus_type = bus_type;
|
||||
self->bus_name = g_strdup (bus_name);
|
||||
self->object_path = g_strdup (object_path);
|
||||
|
||||
return SYSPROF_SOURCE (g_steal_pointer (&self));
|
||||
}
|
||||
39
src/libsysprof/sysprof-proxy-source.h
Normal file
39
src/libsysprof/sysprof-proxy-source.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* sysprof-proxy-source.h
|
||||
*
|
||||
* Copyright 2019 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 <gio/gio.h>
|
||||
|
||||
#include "sysprof-source.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_PROXY_SOURCE (sysprof_proxy_source_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SysprofProxySource, sysprof_proxy_source, SYSPROF, PROXY_SOURCE, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofSource *sysprof_proxy_source_new (GBusType bus_type,
|
||||
const gchar *bus_name,
|
||||
const gchar *object_path);
|
||||
|
||||
G_END_DECLS
|
||||
@ -38,6 +38,7 @@ G_BEGIN_DECLS
|
||||
# include "sysprof-jitmap-symbol-resolver.h"
|
||||
# include "sysprof-kernel-symbol-resolver.h"
|
||||
# include "sysprof-kernel-symbol.h"
|
||||
# include "sysprof-proxy-source.h"
|
||||
# include "sysprof-symbol-dirs.h"
|
||||
# include "sysprof-symbol-resolver.h"
|
||||
# include "sysprof-map-lookaside.h"
|
||||
|
||||
Reference in New Issue
Block a user