From 364f35a7fb5d85d4e23b5939e440ca8cd54d501b Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Sun, 12 May 2019 18:35:22 -0700 Subject: [PATCH] wire up marks reader --- src/libsysprof-ui/meson.build | 3 ++- src/libsysprof-ui/sysprof-marks-model.c | 8 ++++++-- src/libsysprof-ui/sysprof-marks-view.c | 25 +++++++++++++++++++++++++ src/libsysprof-ui/sysprof-ui.h | 1 + src/sysprof/sysprof-window.c | 3 +++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/libsysprof-ui/meson.build b/src/libsysprof-ui/meson.build index 7066ec44..63247f75 100644 --- a/src/libsysprof-ui/meson.build +++ b/src/libsysprof-ui/meson.build @@ -5,6 +5,7 @@ libsysprof_ui_public_sources = [ 'sysprof-empty-state-view.c', 'sysprof-failed-state-view.c', 'sysprof-line-visualizer-row.c', + 'sysprof-marks-model.c', 'sysprof-marks-view.c', 'sysprof-mark-visualizer-row.c', 'sysprof-model-filter.c', @@ -23,7 +24,6 @@ libsysprof_ui_private_sources = [ 'pointcache.c', 'rectangles.c', 'sysprof-cell-renderer-percent.c', - 'sysprof-marks-model.c', 'sysprof-theme-manager.c', '../stackstash.c', ] @@ -35,6 +35,7 @@ libsysprof_ui_public_headers = [ 'sysprof-empty-state-view.h', 'sysprof-failed-state-view.h', 'sysprof-line-visualizer-row.h', + 'sysprof-marks-model.h', 'sysprof-marks-view.h', 'sysprof-mark-visualizer-row.h', 'sysprof-model-filter.h', diff --git a/src/libsysprof-ui/sysprof-marks-model.c b/src/libsysprof-ui/sysprof-marks-model.c index 85323eb4..b5af990b 100644 --- a/src/libsysprof-ui/sysprof-marks-model.c +++ b/src/libsysprof-ui/sysprof-marks-model.c @@ -33,8 +33,10 @@ struct _SysprofMarksModel typedef struct { - gint64 begin_time; - gint64 end_time; + gint64 begin_time; + gint64 end_time; + const gchar *group; + const gchar *name; } Item; static void @@ -84,6 +86,8 @@ cursor_foreach_cb (const SysprofCaptureFrame *frame, item.begin_time = frame->time; item.end_time = item.begin_time + mark->duration; + item.group = g_string_chunk_insert_const (self->chunks, mark->group); + item.name = g_string_chunk_insert_const (self->chunks, mark->name); g_array_append_val (self->items, item); diff --git a/src/libsysprof-ui/sysprof-marks-view.c b/src/libsysprof-ui/sysprof-marks-view.c index 5a2afa1a..93b005ad 100644 --- a/src/libsysprof-ui/sysprof-marks-view.c +++ b/src/libsysprof-ui/sysprof-marks-view.c @@ -22,6 +22,7 @@ #include "config.h" +#include "sysprof-marks-model.h" #include "sysprof-marks-view.h" typedef struct @@ -52,9 +53,33 @@ sysprof_marks_view_new (void) return g_object_new (SYSPROF_TYPE_MARKS_VIEW, NULL); } +static void +new_marks_model_cb (GObject *object, + GAsyncResult *result, + gpointer user_data) +{ + g_autoptr(SysprofMarksView) self = user_data; + SysprofMarksViewPrivate *priv = sysprof_marks_view_get_instance_private (self); + g_autoptr(SysprofMarksModel) model = NULL; + g_autoptr(GError) error = NULL; + + g_assert (SYSPROF_IS_MARKS_VIEW (self)); + g_assert (G_IS_ASYNC_RESULT (result)); + + if (!(model = sysprof_marks_model_new_finish (result, &error))) + g_warning ("Failed to load marks model: %s", error->message); + else + gtk_tree_view_set_model (priv->tree_view, GTK_TREE_MODEL (model)); +} + void sysprof_marks_view_set_reader (SysprofMarksView *self, SysprofCaptureReader *reader) { g_return_if_fail (SYSPROF_IS_MARKS_VIEW (self)); + + sysprof_marks_model_new_async (reader, + NULL, + new_marks_model_cb, + g_object_ref (self)); } diff --git a/src/libsysprof-ui/sysprof-ui.h b/src/libsysprof-ui/sysprof-ui.h index bd5cbdca..a45d8fc1 100644 --- a/src/libsysprof-ui/sysprof-ui.h +++ b/src/libsysprof-ui/sysprof-ui.h @@ -32,6 +32,7 @@ G_BEGIN_DECLS # include "sysprof-empty-state-view.h" # include "sysprof-failed-state-view.h" # include "sysprof-line-visualizer-row.h" +# include "sysprof-marks-model.h" # include "sysprof-marks-view.h" # include "sysprof-mark-visualizer-row.h" # include "sysprof-model-filter.h" diff --git a/src/sysprof/sysprof-window.c b/src/sysprof/sysprof-window.c index 2955c6e8..32ce1546 100644 --- a/src/sysprof/sysprof-window.c +++ b/src/sysprof/sysprof-window.c @@ -269,6 +269,8 @@ sysprof_window_build_profile (SysprofWindow *self) self->refilter_cancellable, sysprof_window_build_profile_cb, g_object_ref (self)); + + sysprof_marks_view_set_reader (self->marks_view, self->reader); } static void @@ -835,6 +837,7 @@ sysprof_window_class_init (SysprofWindowClass *klass) gtk_widget_class_bind_template_child (widget_class, SysprofWindow, info_bar); gtk_widget_class_bind_template_child (widget_class, SysprofWindow, info_bar_label); gtk_widget_class_bind_template_child (widget_class, SysprofWindow, info_bar_revealer); + gtk_widget_class_bind_template_child (widget_class, SysprofWindow, marks_view); gtk_widget_class_bind_template_child (widget_class, SysprofWindow, paned); gtk_widget_class_bind_template_child (widget_class, SysprofWindow, profiler_menu_button); gtk_widget_class_bind_template_child (widget_class, SysprofWindow, record_button);