mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-ui: start on aids
This commit is contained in:
@ -3,6 +3,7 @@ libsysprof_ui_public_sources = [
|
||||
'sysprof-capture-view.c',
|
||||
'sysprof-callgraph-view.c',
|
||||
'sysprof-color-cycle.c',
|
||||
'sysprof-cpu-aid.c',
|
||||
'sysprof-cpu-visualizer-row.c',
|
||||
'sysprof-display.c',
|
||||
'sysprof-empty-state-view.c',
|
||||
@ -46,6 +47,7 @@ libsysprof_ui_public_headers = [
|
||||
'sysprof-capture-view.h',
|
||||
'sysprof-callgraph-view.h',
|
||||
'sysprof-cell-renderer-percent.h',
|
||||
'sysprof-cpu-aid.h',
|
||||
'sysprof-cpu-visualizer-row.h',
|
||||
'sysprof-display.h',
|
||||
'sysprof-empty-state-view.h',
|
||||
|
||||
@ -36,6 +36,7 @@ enum {
|
||||
PROP_0,
|
||||
PROP_DISPLAY_NAME,
|
||||
PROP_ICON,
|
||||
PROP_ICON_NAME,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
@ -83,16 +84,19 @@ sysprof_aid_set_property (GObject *object,
|
||||
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);
|
||||
sysprof_aid_set_display_name (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_ICON:
|
||||
priv->icon = g_value_dup_object (value);
|
||||
sysprof_aid_set_icon (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_ICON_NAME:
|
||||
sysprof_aid_set_icon_name (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -114,14 +118,21 @@ sysprof_aid_class_init (SysprofAidClass *klass)
|
||||
"Display Name",
|
||||
"Display Name",
|
||||
NULL,
|
||||
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties [PROP_ICON_NAME] =
|
||||
g_param_spec_string ("icon-name",
|
||||
"Icon Name",
|
||||
"Icon Name",
|
||||
NULL,
|
||||
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | 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_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
@ -169,3 +180,45 @@ sysprof_aid_get_icon (SysprofAid *self)
|
||||
|
||||
return priv->icon;
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_aid_set_icon (SysprofAid *self,
|
||||
GIcon *icon)
|
||||
{
|
||||
SysprofAidPrivate *priv = sysprof_aid_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (SYSPROF_IS_AID (self));
|
||||
|
||||
if (g_set_object (&priv->icon, icon))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ICON]);
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_aid_set_icon_name (SysprofAid *self,
|
||||
const gchar *icon_name)
|
||||
{
|
||||
g_autoptr(GIcon) icon = NULL;
|
||||
|
||||
g_return_if_fail (SYSPROF_IS_AID (self));
|
||||
|
||||
if (icon_name != NULL)
|
||||
icon = g_themed_icon_new (icon_name);
|
||||
|
||||
sysprof_aid_set_icon (self, icon);
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_aid_set_display_name (SysprofAid *self,
|
||||
const gchar *display_name)
|
||||
{
|
||||
SysprofAidPrivate *priv = sysprof_aid_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (SYSPROF_IS_AID (self));
|
||||
|
||||
if (g_strcmp0 (display_name, priv->display_name) != 0)
|
||||
{
|
||||
g_free (priv->display_name);
|
||||
priv->display_name = g_strdup (display_name);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DISPLAY_NAME]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,8 +43,17 @@ struct _SysprofAidClass
|
||||
};
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar *sysprof_aid_get_display_name (SysprofAid *self);
|
||||
const gchar *sysprof_aid_get_display_name (SysprofAid *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GIcon *sysprof_aid_get_icon (SysprofAid *self);
|
||||
void sysprof_aid_set_display_name (SysprofAid *self,
|
||||
const gchar *display_name);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GIcon *sysprof_aid_get_icon (SysprofAid *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_aid_set_icon (SysprofAid *self,
|
||||
GIcon *icon);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_aid_set_icon_name (SysprofAid *self,
|
||||
const gchar *icon_name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
61
src/libsysprof-ui/sysprof-cpu-aid.c
Normal file
61
src/libsysprof-ui/sysprof-cpu-aid.c
Normal file
@ -0,0 +1,61 @@
|
||||
/* sysprof-cpu-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-cpu-aid"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "sysprof-cpu-aid.h"
|
||||
|
||||
struct _SysprofCpuAid
|
||||
{
|
||||
SysprofAid parent_instance;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (SysprofCpuAid, sysprof_cpu_aid, SYSPROF_TYPE_AID)
|
||||
|
||||
/**
|
||||
* sysprof_cpu_aid_new:
|
||||
*
|
||||
* Create a new #SysprofCpuAid.
|
||||
*
|
||||
* Returns: (transfer full): a newly created #SysprofCpuAid
|
||||
*
|
||||
* Since: 3.34
|
||||
*/
|
||||
SysprofAid *
|
||||
sysprof_cpu_aid_new (void)
|
||||
{
|
||||
return g_object_new (SYSPROF_TYPE_CPU_AID, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_cpu_aid_class_init (SysprofCpuAidClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_cpu_aid_init (SysprofCpuAid *self)
|
||||
{
|
||||
sysprof_aid_set_display_name (SYSPROF_AID (self), _("CPU Usage"));
|
||||
sysprof_aid_set_icon_name (SYSPROF_AID (self), "org.gnome.Sysprof-symbolic");
|
||||
}
|
||||
35
src/libsysprof-ui/sysprof-cpu-aid.h
Normal file
35
src/libsysprof-ui/sysprof-cpu-aid.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* sysprof-cpu-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_CPU_AID (sysprof_cpu_aid_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SysprofCpuAid, sysprof_cpu_aid, SYSPROF, CPU_AID, SysprofAid)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofAid *sysprof_cpu_aid_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
@ -25,6 +25,7 @@
|
||||
#include <sysprof.h>
|
||||
|
||||
#include "sysprof-aid-icon.h"
|
||||
#include "sysprof-cpu-aid.h"
|
||||
#include "sysprof-environ-editor.h"
|
||||
#include "sysprof-profiler-assistant.h"
|
||||
#include "sysprof-process-model-row.h"
|
||||
@ -149,6 +150,7 @@ sysprof_profiler_assistant_class_init (SysprofProfilerAssistantClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, process_revealer);
|
||||
|
||||
g_type_ensure (SYSPROF_TYPE_AID_ICON);
|
||||
g_type_ensure (SYSPROF_TYPE_CPU_AID);
|
||||
g_type_ensure (SYSPROF_TYPE_ENVIRON_EDITOR);
|
||||
}
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ G_BEGIN_DECLS
|
||||
# include "sysprof-callgraph-view.h"
|
||||
# include "sysprof-capture-view.h"
|
||||
# include "sysprof-cell-renderer-percent.h"
|
||||
# include "sysprof-cpu-aid.h"
|
||||
# include "sysprof-cpu-visualizer-row.h"
|
||||
# include "sysprof-display.h"
|
||||
# include "sysprof-empty-state-view.h"
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.22"/>
|
||||
<object class="SysprofCpuAid" id="cpu_aid"/>
|
||||
<template class="SysprofProfilerAssistant" parent="GtkBin">
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
@ -41,26 +42,13 @@
|
||||
<property name="max-children-per-line">4</property>
|
||||
<property name="min-children-per-line">4</property>
|
||||
<property name="halign">fill</property>
|
||||
<property name="homogeneous">true</property>
|
||||
<property name="selection-mode">single</property>
|
||||
<property name="margin-bottom">24</property>
|
||||
<property name="visible">true</property>
|
||||
<child>
|
||||
<object class="SysprofAidIcon">
|
||||
<property name="visible">true</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="SysprofAidIcon">
|
||||
<property name="visible">true</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="SysprofAidIcon">
|
||||
<property name="visible">true</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="SysprofAidIcon">
|
||||
<property name="aid">cpu_aid</property>
|
||||
<property name="visible">true</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
Reference in New Issue
Block a user