[sysprof/wip/chergert/sysprof-3] libsysprof: add memory aid
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/chergert/sysprof-3] libsysprof: add memory aid
- Date: Sun, 19 May 2019 01:58:26 +0000 (UTC)
commit 73ba445b63cdb324792d96a02fd27c8ef6b5b9b8
Author: Christian Hergert <chergert redhat com>
Date: Sat May 18 18:58:16 2019 -0700
libsysprof: add memory aid
src/libsysprof-ui/meson.build | 3 +
src/libsysprof-ui/sysprof-memory-aid.c | 77 ++++++++++++++++++++++
src/libsysprof-ui/sysprof-memory-aid.h | 35 ++++++++++
src/libsysprof-ui/sysprof-ui.h | 1 +
src/libsysprof-ui/ui/sysprof-profiler-assistant.ui | 7 ++
5 files changed, 123 insertions(+)
---
diff --git a/src/libsysprof-ui/meson.build b/src/libsysprof-ui/meson.build
index 160ae4b..d63ee3b 100644
--- a/src/libsysprof-ui/meson.build
+++ b/src/libsysprof-ui/meson.build
@@ -12,6 +12,7 @@ libsysprof_ui_public_sources = [
'sysprof-marks-model.c',
'sysprof-marks-view.c',
'sysprof-mark-visualizer-row.c',
+ 'sysprof-memory-aid.c',
'sysprof-model-filter.c',
'sysprof-notebook.c',
'sysprof-process-model-row.c',
@@ -56,6 +57,8 @@ libsysprof_ui_public_headers = [
'sysprof-marks-model.h',
'sysprof-marks-view.h',
'sysprof-mark-visualizer-row.h',
+ 'sysprof-memory-aid.h',
+ 'sysprof-model-filter.c',
'sysprof-model-filter.h',
'sysprof-notebook.h',
'sysprof-process-model-row.h',
diff --git a/src/libsysprof-ui/sysprof-memory-aid.c b/src/libsysprof-ui/sysprof-memory-aid.c
new file mode 100644
index 0000000..9c97ae0
--- /dev/null
+++ b/src/libsysprof-ui/sysprof-memory-aid.c
@@ -0,0 +1,77 @@
+/* sysprof-memory-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-memory-aid"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include "sysprof-memory-aid.h"
+
+struct _SysprofMemoryAid
+{
+ SysprofAid parent_instance;
+};
+
+G_DEFINE_TYPE (SysprofMemoryAid, sysprof_memory_aid, SYSPROF_TYPE_AID)
+
+/**
+ * sysprof_memory_aid_new:
+ *
+ * Create a new #SysprofMemoryAid.
+ *
+ * Returns: (transfer full): a newly created #SysprofMemoryAid
+ *
+ * Since: 3.34
+ */
+SysprofAid *
+sysprof_memory_aid_new (void)
+{
+ return g_object_new (SYSPROF_TYPE_MEMORY_AID, NULL);
+}
+
+static void
+sysprof_memory_aid_prepare (SysprofAid *self,
+ SysprofProfiler *profiler)
+{
+ g_autoptr(SysprofSource) source = NULL;
+
+ g_assert (SYSPROF_IS_MEMORY_AID (self));
+ g_assert (SYSPROF_IS_PROFILER (profiler));
+
+ source = sysprof_memory_source_new ();
+ sysprof_profiler_add_source (profiler, source);
+}
+
+static void
+sysprof_memory_aid_class_init (SysprofMemoryAidClass *klass)
+{
+ SysprofAidClass *aid_class = SYSPROF_AID_CLASS (klass);
+
+ aid_class->prepare = sysprof_memory_aid_prepare;
+}
+
+static void
+sysprof_memory_aid_init (SysprofMemoryAid *self)
+{
+ sysprof_aid_set_display_name (SYSPROF_AID (self), _("Memory Usage"));
+ sysprof_aid_set_icon_name (SYSPROF_AID (self), "org.gnome.Sysprof-symbolic");
+}
diff --git a/src/libsysprof-ui/sysprof-memory-aid.h b/src/libsysprof-ui/sysprof-memory-aid.h
new file mode 100644
index 0000000..424bd65
--- /dev/null
+++ b/src/libsysprof-ui/sysprof-memory-aid.h
@@ -0,0 +1,35 @@
+/* sysprof-memory-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_MEMORY_AID (sysprof_memory_aid_get_type())
+
+SYSPROF_AVAILABLE_IN_ALL
+G_DECLARE_FINAL_TYPE (SysprofMemoryAid, sysprof_memory_aid, SYSPROF, MEMORY_AID, SysprofAid)
+
+SYSPROF_AVAILABLE_IN_ALL
+SysprofAid *sysprof_memory_aid_new (void);
+
+G_END_DECLS
diff --git a/src/libsysprof-ui/sysprof-ui.h b/src/libsysprof-ui/sysprof-ui.h
index 2744cf9..91fb5be 100644
--- a/src/libsysprof-ui/sysprof-ui.h
+++ b/src/libsysprof-ui/sysprof-ui.h
@@ -40,6 +40,7 @@ G_BEGIN_DECLS
# include "sysprof-marks-model.h"
# include "sysprof-marks-view.h"
# include "sysprof-mark-visualizer-row.h"
+# include "sysprof-memory-aid.h"
# include "sysprof-model-filter.h"
# include "sysprof-notebook.h"
# include "sysprof-process-model-row.h"
diff --git a/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui
b/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui
index 1c73bee..dc43db8 100644
--- a/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui
+++ b/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui
@@ -2,6 +2,7 @@
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="SysprofCpuAid" id="cpu_aid"/>
+ <object class="SysprofMemoryAid" id="memory_aid"/>
<template class="SysprofProfilerAssistant" parent="GtkBin">
<child>
<object class="GtkScrolledWindow">
@@ -52,6 +53,12 @@
<property name="visible">true</property>
</object>
</child>
+ <child>
+ <object class="SysprofAidIcon">
+ <property name="aid">memory_aid</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
</object>
<packing>
<property name="column">center</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]