mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-ui: stub out SysprofAid
This will be used as a high-level object that knows how to deal with both the SysprofSource (data collector) and various views for the user.
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
libsysprof_ui_public_sources = [
|
libsysprof_ui_public_sources = [
|
||||||
|
'sysprof-aid.c',
|
||||||
'sysprof-capture-view.c',
|
'sysprof-capture-view.c',
|
||||||
'sysprof-callgraph-view.c',
|
'sysprof-callgraph-view.c',
|
||||||
'sysprof-color-cycle.c',
|
'sysprof-color-cycle.c',
|
||||||
@ -40,6 +41,7 @@ libsysprof_ui_private_sources = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
libsysprof_ui_public_headers = [
|
libsysprof_ui_public_headers = [
|
||||||
|
'sysprof-aid.h',
|
||||||
'sysprof-capture-view.h',
|
'sysprof-capture-view.h',
|
||||||
'sysprof-callgraph-view.h',
|
'sysprof-callgraph-view.h',
|
||||||
'sysprof-cell-renderer-percent.h',
|
'sysprof-cell-renderer-percent.h',
|
||||||
|
|||||||
171
src/libsysprof-ui/sysprof-aid.c
Normal file
171
src/libsysprof-ui/sysprof-aid.c
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/* sysprof-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-aid"
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "sysprof-aid.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gchar *display_name;
|
||||||
|
GIcon *icon;
|
||||||
|
} SysprofAidPrivate;
|
||||||
|
|
||||||
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SysprofAid, sysprof_aid, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_DISPLAY_NAME,
|
||||||
|
PROP_ICON,
|
||||||
|
N_PROPS
|
||||||
|
};
|
||||||
|
|
||||||
|
static GParamSpec *properties [N_PROPS];
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_aid_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
SysprofAid *self = (SysprofAid *)object;
|
||||||
|
SysprofAidPrivate *priv = sysprof_aid_get_instance_private (self);
|
||||||
|
|
||||||
|
g_clear_pointer (&priv->display_name, g_free);
|
||||||
|
g_clear_object (&priv->icon);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (sysprof_aid_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_aid_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
SysprofAid *self = SYSPROF_AID (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_DISPLAY_NAME:
|
||||||
|
g_value_set_string (value, sysprof_aid_get_display_name (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_ICON:
|
||||||
|
g_value_set_object (value, sysprof_aid_get_icon (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_aid_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
SysprofAid *self = SYSPROF_AID (object);
|
||||||
|
SysprofAidPrivate *priv = sysprof_aid_get_instance_private (self);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_DISPLAY_NAME:
|
||||||
|
priv->display_name = g_value_dup_string (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_ICON:
|
||||||
|
priv->icon = g_value_dup_object (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_aid_class_init (SysprofAidClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->finalize = sysprof_aid_finalize;
|
||||||
|
object_class->get_property = sysprof_aid_get_property;
|
||||||
|
object_class->set_property = sysprof_aid_set_property;
|
||||||
|
|
||||||
|
properties [PROP_DISPLAY_NAME] =
|
||||||
|
g_param_spec_string ("display-name",
|
||||||
|
"Display Name",
|
||||||
|
"Display Name",
|
||||||
|
NULL,
|
||||||
|
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties [PROP_ICON] =
|
||||||
|
g_param_spec_object ("icon",
|
||||||
|
"Icon",
|
||||||
|
"The icon to display",
|
||||||
|
G_TYPE_ICON,
|
||||||
|
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_aid_init (SysprofAid *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_aid_get_display_name:
|
||||||
|
* @self: a #SysprofAid
|
||||||
|
*
|
||||||
|
* Gets the display name as it should be shown to the user.
|
||||||
|
*
|
||||||
|
* Returns: a string containing the display name
|
||||||
|
*
|
||||||
|
* Since: 3.34
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
sysprof_aid_get_display_name (SysprofAid *self)
|
||||||
|
{
|
||||||
|
SysprofAidPrivate *priv = sysprof_aid_get_instance_private (self);
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_AID (self), NULL);
|
||||||
|
|
||||||
|
return priv->display_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_aid_get_icon:
|
||||||
|
*
|
||||||
|
* Gets the icon for the aid.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none) (nullable): a #GIcon or %NULL
|
||||||
|
*
|
||||||
|
* Since: 3.34
|
||||||
|
*/
|
||||||
|
GIcon *
|
||||||
|
sysprof_aid_get_icon (SysprofAid *self)
|
||||||
|
{
|
||||||
|
SysprofAidPrivate *priv = sysprof_aid_get_instance_private (self);
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_AID (self), NULL);
|
||||||
|
|
||||||
|
return priv->icon;
|
||||||
|
}
|
||||||
50
src/libsysprof-ui/sysprof-aid.h
Normal file
50
src/libsysprof-ui/sysprof-aid.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/* sysprof-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
|
||||||
|
|
||||||
|
#if !defined (SYSPROF_UI_INSIDE) && !defined (SYSPROF_UI_COMPILATION)
|
||||||
|
# error "Only <sysprof-ui.h> can be included directly."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gio/gio.h>
|
||||||
|
#include <sysprof.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define SYSPROF_TYPE_AID (sysprof_aid_get_type())
|
||||||
|
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
G_DECLARE_DERIVABLE_TYPE (SysprofAid, sysprof_aid, SYSPROF, AID, GObject)
|
||||||
|
|
||||||
|
struct _SysprofAidClass
|
||||||
|
{
|
||||||
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
/*< gpointer >*/
|
||||||
|
gpointer _reserved[16];
|
||||||
|
};
|
||||||
|
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
const gchar *sysprof_aid_get_display_name (SysprofAid *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
GIcon *sysprof_aid_get_icon (SysprofAid *self);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
@ -27,6 +27,7 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
#define SYSPROF_UI_INSIDE
|
#define SYSPROF_UI_INSIDE
|
||||||
|
|
||||||
|
# include "sysprof-aid.h"
|
||||||
# include "sysprof-callgraph-view.h"
|
# include "sysprof-callgraph-view.h"
|
||||||
# include "sysprof-capture-view.h"
|
# include "sysprof-capture-view.h"
|
||||||
# include "sysprof-cell-renderer-percent.h"
|
# include "sysprof-cell-renderer-percent.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user