From 210de8268ed90f292b86a6bc6929075ac3f23091 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Sat, 18 May 2019 18:54:55 -0700 Subject: [PATCH] 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 ++++++++++++++ .../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 3c1cfed2..92dc69a8 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 a6222fae..a84328df 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); +void sysprof_aid_set_display_name (SysprofAid *self, + const gchar *display_name); SYSPROF_AVAILABLE_IN_ALL -GIcon *sysprof_aid_get_icon (SysprofAid *self); +GIcon *sysprof_aid_get_icon (SysprofAid *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_aid_set_icon (SysprofAid *self, - GIcon *icon); +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); +void sysprof_aid_set_icon_name (SysprofAid *self, + const gchar *icon_name); +SYSPROF_AVAILABLE_IN_ALL +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 e5f1e152..2639bcdb 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 9286e55b..06bfef41 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); }