From ecacbc8c7736a2d57f1a5c1d9b115642156c7856 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 26 Jul 2023 12:07:09 -0700 Subject: [PATCH] sysprof: start on an energy section via RAPL/Battery Charge counters --- .../scalable/actions/energy-symbolic.svg | 2 + src/sysprof/meson.build | 1 + src/sysprof/sysprof-energy-section-counter.ui | 50 ++ src/sysprof/sysprof-energy-section.c | 84 +++ src/sysprof/sysprof-energy-section.h | 32 + src/sysprof/sysprof-energy-section.ui | 554 ++++++++++++++++++ src/sysprof/sysprof-window.c | 2 + src/sysprof/sysprof-window.ui | 10 + src/sysprof/sysprof.gresource.xml | 3 + 9 files changed, 738 insertions(+) create mode 100644 src/sysprof/icons/scalable/actions/energy-symbolic.svg create mode 100644 src/sysprof/sysprof-energy-section-counter.ui create mode 100644 src/sysprof/sysprof-energy-section.c create mode 100644 src/sysprof/sysprof-energy-section.h create mode 100644 src/sysprof/sysprof-energy-section.ui diff --git a/src/sysprof/icons/scalable/actions/energy-symbolic.svg b/src/sysprof/icons/scalable/actions/energy-symbolic.svg new file mode 100644 index 00000000..a0d807f1 --- /dev/null +++ b/src/sysprof/icons/scalable/actions/energy-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/src/sysprof/meson.build b/src/sysprof/meson.build index f11c28cc..d082314e 100644 --- a/src/sysprof/meson.build +++ b/src/sysprof/meson.build @@ -15,6 +15,7 @@ sysprof_sources = [ 'sysprof-cpu-section.c', 'sysprof-css.c', 'sysprof-duplex-layer.c', + 'sysprof-energy-section.c', 'sysprof-files-section.c', 'sysprof-frame-utility.c', 'sysprof-greeter.c', diff --git a/src/sysprof/sysprof-energy-section-counter.ui b/src/sysprof/sysprof-energy-section-counter.ui new file mode 100644 index 00000000..99cae904 --- /dev/null +++ b/src/sysprof/sysprof-energy-section-counter.ui @@ -0,0 +1,50 @@ + + + + diff --git a/src/sysprof/sysprof-energy-section.c b/src/sysprof/sysprof-energy-section.c new file mode 100644 index 00000000..8de3431b --- /dev/null +++ b/src/sysprof/sysprof-energy-section.c @@ -0,0 +1,84 @@ +/* sysprof-energy-section.c + * + * Copyright 2023 Christian Hergert + * + * 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include "config.h" + +#include "sysprof-chart.h" +#include "sysprof-energy-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 _SysprofEnergySection +{ + SysprofSection parent_instance; + + SysprofTimeScrubber *scrubber; + GtkColumnView *column_view; + GtkColumnViewColumn *time_column; +}; + +G_DEFINE_FINAL_TYPE (SysprofEnergySection, sysprof_energy_section, SYSPROF_TYPE_SECTION) + +static void +sysprof_energy_section_dispose (GObject *object) +{ + SysprofEnergySection *self = (SysprofEnergySection *)object; + + gtk_widget_dispose_template (GTK_WIDGET (self), SYSPROF_TYPE_ENERGY_SECTION); + + G_OBJECT_CLASS (sysprof_energy_section_parent_class)->dispose (object); +} + +static void +sysprof_energy_section_class_init (SysprofEnergySectionClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->dispose = sysprof_energy_section_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-energy-section.ui"); + gtk_widget_class_bind_template_child (widget_class, SysprofEnergySection, column_view); + gtk_widget_class_bind_template_child (widget_class, SysprofEnergySection, scrubber); + gtk_widget_class_bind_template_child (widget_class, SysprofEnergySection, time_column); + + g_type_ensure (SYSPROF_TYPE_CHART); + g_type_ensure (SYSPROF_TYPE_DOCUMENT_MARK); + g_type_ensure (SYSPROF_TYPE_DOCUMENT_COUNTER); + g_type_ensure (SYSPROF_TYPE_DOCUMENT_COUNTER_VALUE); + g_type_ensure (SYSPROF_TYPE_LINE_LAYER); + g_type_ensure (SYSPROF_TYPE_TIME_SERIES); + g_type_ensure (SYSPROF_TYPE_TIME_SPAN_LAYER); + g_type_ensure (SYSPROF_TYPE_XY_SERIES); +} + +static void +sysprof_energy_section_init (SysprofEnergySection *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); + + gtk_column_view_sort_by_column (self->column_view, self->time_column, GTK_SORT_ASCENDING); +} + diff --git a/src/sysprof/sysprof-energy-section.h b/src/sysprof/sysprof-energy-section.h new file mode 100644 index 00000000..5399998a --- /dev/null +++ b/src/sysprof/sysprof-energy-section.h @@ -0,0 +1,32 @@ +/* sysprof-energy-section.h + * + * Copyright 2023 Christian Hergert + * + * 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "sysprof-section.h" + +G_BEGIN_DECLS + +#define SYSPROF_TYPE_ENERGY_SECTION (sysprof_energy_section_get_type()) + +G_DECLARE_FINAL_TYPE (SysprofEnergySection, sysprof_energy_section, SYSPROF, ENERG_SECTION, SysprofSection) + +G_END_DECLS + diff --git a/src/sysprof/sysprof-energy-section.ui b/src/sysprof/sysprof-energy-section.ui new file mode 100644 index 00000000..67068a66 --- /dev/null +++ b/src/sysprof/sysprof-energy-section.ui @@ -0,0 +1,554 @@ + + + + + + + + diff --git a/src/sysprof/sysprof-window.c b/src/sysprof/sysprof-window.c index 59479887..c1808baf 100644 --- a/src/sysprof/sysprof-window.c +++ b/src/sysprof/sysprof-window.c @@ -24,6 +24,7 @@ #include "sysprof-counters-section.h" #include "sysprof-cpu-section.h" +#include "sysprof-energy-section.h" #include "sysprof-files-section.h" #include "sysprof-greeter.h" #include "sysprof-logs-section.h" @@ -413,6 +414,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_DOCUMENT); + g_type_ensure (SYSPROF_TYPE_ENERGY_SECTION); g_type_ensure (SYSPROF_TYPE_FILES_SECTION); g_type_ensure (SYSPROF_TYPE_LOGS_SECTION); g_type_ensure (SYSPROF_TYPE_MARKS_SECTION); diff --git a/src/sysprof/sysprof-window.ui b/src/sysprof/sysprof-window.ui index 85085bb5..04611279 100644 --- a/src/sysprof/sysprof-window.ui +++ b/src/sysprof/sysprof-window.ui @@ -216,6 +216,16 @@ + + + Energy + counters + energy-symbolic + + SysprofWindow + + + Network diff --git a/src/sysprof/sysprof.gresource.xml b/src/sysprof/sysprof.gresource.xml index 40b84d1f..a2caf973 100644 --- a/src/sysprof/sysprof.gresource.xml +++ b/src/sysprof/sysprof.gresource.xml @@ -5,6 +5,7 @@ gtk/menus.ui icons/scalable/actions/address-layout-symbolic.svg icons/scalable/actions/empty-symbolic.svg + icons/scalable/actions/energy-symbolic.svg icons/scalable/actions/mark-chart-symbolic.svg icons/scalable/actions/mark-table-symbolic.svg icons/scalable/actions/mark-waterfall-symbolic.svg @@ -18,6 +19,8 @@ sysprof-counters-section.ui sysprof-cpu-section.ui sysprof-cpu-section-counter.ui + sysprof-energy-section.ui + sysprof-energy-section-counter.ui sysprof-files-section.ui sysprof-frame-utility.ui sysprof-greeter.ui