[sysprof/wip/chergert/sysprof-3] libsysprof-ui: add hostinfo source when cpu is selected



commit 1466abcd99973212c182a2ef9ec3000f3b92aeeb
Author: Christian Hergert <chergert redhat com>
Date:   Sat May 18 18:54:55 2019 -0700

    libsysprof-ui: add hostinfo source when cpu is selected

 src/libsysprof-ui/sysprof-aid.c                | 11 +++++++++++
 src/libsysprof-ui/sysprof-aid.h                | 22 ++++++++++++++--------
 src/libsysprof-ui/sysprof-cpu-aid.c            | 16 ++++++++++++++++
 src/libsysprof-ui/sysprof-profiler-assistant.c |  9 +++++++++
 4 files changed, 50 insertions(+), 8 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-aid.c b/src/libsysprof-ui/sysprof-aid.c
index 3c1cfed..92dc69a 100644
--- a/src/libsysprof-ui/sysprof-aid.c
+++ b/src/libsysprof-ui/sysprof-aid.c
@@ -222,3 +222,14 @@ sysprof_aid_set_display_name (SysprofAid  *self,
       g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DISPLAY_NAME]);
     }
 }
+
+void
+sysprof_aid_prepare (SysprofAid      *self,
+                     SysprofProfiler *profiler)
+{
+  g_return_if_fail (SYSPROF_IS_AID (self));
+  g_return_if_fail (SYSPROF_IS_PROFILER (profiler));
+
+  if (SYSPROF_AID_GET_CLASS (self)->prepare)
+    SYSPROF_AID_GET_CLASS (self)->prepare (self, profiler);
+}
diff --git a/src/libsysprof-ui/sysprof-aid.h b/src/libsysprof-ui/sysprof-aid.h
index a6222fa..a84328d 100644
--- a/src/libsysprof-ui/sysprof-aid.h
+++ b/src/libsysprof-ui/sysprof-aid.h
@@ -38,22 +38,28 @@ struct _SysprofAidClass
 {
   GObjectClass parent_class;
 
+  void (*prepare) (SysprofAid      *self,
+                   SysprofProfiler *profiler);
+
   /*< gpointer >*/
   gpointer _reserved[16];
 };
 
 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
+void         sysprof_aid_set_display_name (SysprofAid      *self,
+                                           const gchar     *display_name);
 SYSPROF_AVAILABLE_IN_ALL
-void         sysprof_aid_set_display_name (SysprofAid  *self,
-                                           const gchar *display_name);
+GIcon       *sysprof_aid_get_icon         (SysprofAid      *self);
 SYSPROF_AVAILABLE_IN_ALL
-GIcon       *sysprof_aid_get_icon         (SysprofAid  *self);
+void         sysprof_aid_set_icon         (SysprofAid      *self,
+                                           GIcon           *icon);
 SYSPROF_AVAILABLE_IN_ALL
-void         sysprof_aid_set_icon         (SysprofAid  *self,
-                                           GIcon       *icon);
+void         sysprof_aid_set_icon_name    (SysprofAid      *self,
+                                           const gchar     *icon_name);
 SYSPROF_AVAILABLE_IN_ALL
-void         sysprof_aid_set_icon_name    (SysprofAid  *self,
-                                           const gchar *icon_name);
+void         sysprof_aid_prepare          (SysprofAid      *self,
+                                           SysprofProfiler *profiler);
 
 G_END_DECLS
diff --git a/src/libsysprof-ui/sysprof-cpu-aid.c b/src/libsysprof-ui/sysprof-cpu-aid.c
index e5f1e15..2639bcd 100644
--- a/src/libsysprof-ui/sysprof-cpu-aid.c
+++ b/src/libsysprof-ui/sysprof-cpu-aid.c
@@ -48,9 +48,25 @@ sysprof_cpu_aid_new (void)
   return g_object_new (SYSPROF_TYPE_CPU_AID, NULL);
 }
 
+static void
+sysprof_cpu_aid_prepare (SysprofAid      *self,
+                         SysprofProfiler *profiler)
+{
+  g_autoptr(SysprofSource) source = NULL;
+
+  g_assert (SYSPROF_IS_CPU_AID (self));
+  g_assert (SYSPROF_IS_PROFILER (profiler));
+
+  source = sysprof_hostinfo_source_new ();
+  sysprof_profiler_add_source (profiler, source);
+}
+
 static void
 sysprof_cpu_aid_class_init (SysprofCpuAidClass *klass)
 {
+  SysprofAidClass *aid_class = SYSPROF_AID_CLASS (klass);
+
+  aid_class->prepare = sysprof_cpu_aid_prepare;
 }
 
 static void
diff --git a/src/libsysprof-ui/sysprof-profiler-assistant.c b/src/libsysprof-ui/sysprof-profiler-assistant.c
index 9286e55..06bfef4 100644
--- a/src/libsysprof-ui/sysprof-profiler-assistant.c
+++ b/src/libsysprof-ui/sysprof-profiler-assistant.c
@@ -166,6 +166,12 @@ sysprof_profiler_assistant_foreach_cb (GtkWidget       *widget,
 
       sysprof_profiler_add_pid (profiler, pid);
     }
+  else if (SYSPROF_IS_AID_ICON (widget))
+    {
+      SysprofAid *aid = sysprof_aid_icon_get_aid (SYSPROF_AID_ICON (widget));
+
+      sysprof_aid_prepare (aid, profiler);
+    }
 }
 
 static void
@@ -221,6 +227,9 @@ sysprof_profiler_assistant_record_clicked_cb (SysprofProfilerAssistant *self,
 #endif
 
   /* Now allow the aids to add their sources */
+  gtk_container_foreach (GTK_CONTAINER (self->aid_flow_box),
+                         (GtkCallback) sysprof_profiler_assistant_foreach_cb,
+                         profiler);
 
   g_signal_emit (self, signals [START_RECORDING], 0, profiler);
 }


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