[sysprof] libsysprof-ui: add callgraph aid



commit 89bcbad02d8e6bb8dd42b4e683fb906b204e6b74
Author: Christian Hergert <chergert redhat com>
Date:   Sat May 18 19:49:32 2019 -0700

    libsysprof-ui: add callgraph aid

 src/libsysprof-ui/meson.build                      |  2 +
 src/libsysprof-ui/sysprof-callgraph-aid.c          | 98 ++++++++++++++++++++++
 src/libsysprof-ui/sysprof-callgraph-aid.h          | 35 ++++++++
 src/libsysprof-ui/sysprof-ui.h                     |  1 +
 src/libsysprof-ui/ui/sysprof-aid-icon.ui           |  2 +-
 src/libsysprof-ui/ui/sysprof-profiler-assistant.ui |  7 ++
 6 files changed, 144 insertions(+), 1 deletion(-)
---
diff --git a/src/libsysprof-ui/meson.build b/src/libsysprof-ui/meson.build
index d63ee3b..f5087a7 100644
--- a/src/libsysprof-ui/meson.build
+++ b/src/libsysprof-ui/meson.build
@@ -1,6 +1,7 @@
 libsysprof_ui_public_sources = [
   'sysprof-aid.c',
   'sysprof-capture-view.c',
+  'sysprof-callgraph-aid.c',
   'sysprof-callgraph-view.c',
   'sysprof-color-cycle.c',
   'sysprof-cpu-aid.c',
@@ -46,6 +47,7 @@ libsysprof_ui_private_sources = [
 libsysprof_ui_public_headers = [
   'sysprof-aid.h',
   'sysprof-capture-view.h',
+  'sysprof-callgraph-aid.h',
   'sysprof-callgraph-view.h',
   'sysprof-cell-renderer-percent.h',
   'sysprof-cpu-aid.h',
diff --git a/src/libsysprof-ui/sysprof-callgraph-aid.c b/src/libsysprof-ui/sysprof-callgraph-aid.c
new file mode 100644
index 0000000..9e3c45a
--- /dev/null
+++ b/src/libsysprof-ui/sysprof-callgraph-aid.c
@@ -0,0 +1,98 @@
+/* sysprof-callgraph-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-callgraph-aid"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include "sysprof-callgraph-aid.h"
+
+struct _SysprofCallgraphAid
+{
+  SysprofAid parent_instance;
+};
+
+G_DEFINE_TYPE (SysprofCallgraphAid, sysprof_callgraph_aid, SYSPROF_TYPE_AID)
+
+/**
+ * sysprof_callgraph_aid_new:
+ *
+ * Create a new #SysprofCallgraphAid.
+ *
+ * Returns: (transfer full): a newly created #SysprofCallgraphAid
+ *
+ * Since: 3.34
+ */
+SysprofAid *
+sysprof_callgraph_aid_new (void)
+{
+  return g_object_new (SYSPROF_TYPE_CALLGRAPH_AID, NULL);
+}
+
+static void
+sysprof_callgraph_aid_prepare (SysprofAid      *self,
+                               SysprofProfiler *profiler)
+{
+  g_assert (SYSPROF_IS_CALLGRAPH_AID (self));
+  g_assert (SYSPROF_IS_PROFILER (profiler));
+
+#ifdef __linux__
+  {
+    const GPid *pids;
+    guint n_pids;
+
+    if ((pids = sysprof_profiler_get_pids (profiler, &n_pids)))
+      {
+        for (guint i = 0; i < n_pids; i++)
+          {
+            g_autoptr(SysprofSource) source = NULL;
+
+            source = sysprof_perf_source_new ();
+            sysprof_perf_source_set_target_pid (SYSPROF_PERF_SOURCE (source), pids[i]);
+            sysprof_profiler_add_source (profiler, source);
+          }
+      }
+    else
+      {
+        g_autoptr(SysprofSource) source = NULL;
+
+        source = sysprof_perf_source_new ();
+        sysprof_profiler_add_source (profiler, source);
+      }
+  }
+#endif
+}
+
+static void
+sysprof_callgraph_aid_class_init (SysprofCallgraphAidClass *klass)
+{
+  SysprofAidClass *aid_class = SYSPROF_AID_CLASS (klass);
+
+  aid_class->prepare = sysprof_callgraph_aid_prepare;
+}
+
+static void
+sysprof_callgraph_aid_init (SysprofCallgraphAid *self)
+{
+  sysprof_aid_set_display_name (SYSPROF_AID (self), _("Callgraph"));
+  sysprof_aid_set_icon_name (SYSPROF_AID (self), "org.gnome.Sysprof-symbolic");
+}
diff --git a/src/libsysprof-ui/sysprof-callgraph-aid.h b/src/libsysprof-ui/sysprof-callgraph-aid.h
new file mode 100644
index 0000000..ecfe053
--- /dev/null
+++ b/src/libsysprof-ui/sysprof-callgraph-aid.h
@@ -0,0 +1,35 @@
+/* sysprof-callgraph-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_CALLGRAPH_AID (sysprof_callgraph_aid_get_type())
+
+SYSPROF_AVAILABLE_IN_ALL
+G_DECLARE_FINAL_TYPE (SysprofCallgraphAid, sysprof_callgraph_aid, SYSPROF, CALLGRAPH_AID, SysprofAid)
+
+SYSPROF_AVAILABLE_IN_ALL
+SysprofAid *sysprof_callgraph_aid_new (void);
+
+G_END_DECLS
diff --git a/src/libsysprof-ui/sysprof-ui.h b/src/libsysprof-ui/sysprof-ui.h
index 91fb5be..5517f41 100644
--- a/src/libsysprof-ui/sysprof-ui.h
+++ b/src/libsysprof-ui/sysprof-ui.h
@@ -30,6 +30,7 @@ G_BEGIN_DECLS
 # include "sysprof-aid.h"
 # include "sysprof-callgraph-view.h"
 # include "sysprof-capture-view.h"
+# include "sysprof-callgraph-aid.h"
 # include "sysprof-cell-renderer-percent.h"
 # include "sysprof-cpu-aid.h"
 # include "sysprof-cpu-visualizer-row.h"
diff --git a/src/libsysprof-ui/ui/sysprof-aid-icon.ui b/src/libsysprof-ui/ui/sysprof-aid-icon.ui
index 2866b53..0cbf334 100644
--- a/src/libsysprof-ui/ui/sysprof-aid-icon.ui
+++ b/src/libsysprof-ui/ui/sysprof-aid-icon.ui
@@ -43,8 +43,8 @@
           <object class="GtkLabel" id="label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Aid Description</property>
             <property name="use_underline">True</property>
+            <property name="justify">center</property>
             <property name="wrap">True</property>
             <property name="mnemonic_widget">SysprofAidIcon</property>
             <property name="max_width_chars">12</property>
diff --git a/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui 
b/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui
index dc43db8..daec81f 100644
--- a/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui
+++ b/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui
@@ -3,6 +3,7 @@
   <requires lib="gtk+" version="3.22"/>
   <object class="SysprofCpuAid" id="cpu_aid"/>
   <object class="SysprofMemoryAid" id="memory_aid"/>
+  <object class="SysprofCallgraphAid" id="callgraph_aid"/>
   <template class="SysprofProfilerAssistant" parent="GtkBin">
     <child>
       <object class="GtkScrolledWindow">
@@ -47,6 +48,12 @@
                     <property name="selection-mode">single</property>
                     <property name="margin-bottom">24</property>
                     <property name="visible">true</property>
+                    <child>
+                      <object class="SysprofAidIcon">
+                        <property name="aid">callgraph_aid</property>
+                        <property name="visible">true</property>
+                      </object>
+                    </child>
                     <child>
                       <object class="SysprofAidIcon">
                         <property name="aid">cpu_aid</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]