[sysprof/wip/chergert/sysprof-3] libsysprof-ui: reload logs when selection changes
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/chergert/sysprof-3] libsysprof-ui: reload logs when selection changes
- Date: Mon, 27 May 2019 06:44:22 +0000 (UTC)
commit 947d82004e6c5b20b713911f2ff6aed981a6f53b
Author: Christian Hergert <chergert redhat com>
Date: Sun May 26 23:44:13 2019 -0700
libsysprof-ui: reload logs when selection changes
src/libsysprof-ui/sysprof-capture-view.c | 27 +++++++-------
src/libsysprof-ui/sysprof-logs-view.c | 62 +++++++++++++++++++++++++++++---
src/libsysprof-ui/sysprof-logs-view.h | 11 ++++--
3 files changed, 80 insertions(+), 20 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-capture-view.c b/src/libsysprof-ui/sysprof-capture-view.c
index 74ae83d..76a755b 100644
--- a/src/libsysprof-ui/sysprof-capture-view.c
+++ b/src/libsysprof-ui/sysprof-capture-view.c
@@ -580,11 +580,12 @@ sysprof_capture_view_load_logs_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
- g_autoptr(SysprofLogModel) model = NULL;
+ SysprofLogsView *logs_view = (SysprofLogsView *)object;
g_autoptr(GError) error = NULL;
g_autoptr(GTask) task = user_data;
LoadAsync *state;
+ g_assert (SYSPROF_IS_LOGS_VIEW (logs_view));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (G_IS_TASK (task));
@@ -593,13 +594,8 @@ sysprof_capture_view_load_logs_cb (GObject *object,
g_assert (state->reader != NULL);
g_assert (state->n_active > 0);
- if ((model = sysprof_log_model_new_finish (result, &error)))
- {
- SysprofCaptureView *self = g_task_get_source_object (task);
- SysprofCaptureViewPrivate *priv = sysprof_capture_view_get_instance_private (self);
-
- sysprof_logs_view_set_model (priv->logs_view, model);
- }
+ if (!sysprof_logs_view_load_finish (logs_view, result, &error))
+ g_warning ("Failed to load logs: %s", error->message);
state->n_active--;
@@ -646,11 +642,12 @@ sysprof_capture_view_load_scan_cb (GObject *object,
if (priv->features.has_logs)
{
state->n_active++;
- sysprof_log_model_new_async (state->reader,
- state->selection,
- g_task_get_cancellable (task),
- sysprof_capture_view_load_logs_cb,
- g_object_ref (task));
+ sysprof_logs_view_load_async (priv->logs_view,
+ state->reader,
+ state->selection,
+ g_task_get_cancellable (task),
+ sysprof_capture_view_load_logs_cb,
+ g_object_ref (task));
}
sysprof_visualizer_view_set_reader (priv->visualizer_view, state->reader);
@@ -765,6 +762,10 @@ sysprof_capture_view_selection_changed_cb (SysprofCaptureView *self,
priv->reader,
selection,
NULL, NULL, NULL);
+ sysprof_logs_view_load_async (priv->logs_view,
+ priv->reader,
+ selection,
+ NULL, NULL, NULL);
sysprof_marks_view_load_async (priv->marks_view,
priv->reader,
selection,
diff --git a/src/libsysprof-ui/sysprof-logs-view.c b/src/libsysprof-ui/sysprof-logs-view.c
index 23b3d00..a6fed73 100644
--- a/src/libsysprof-ui/sysprof-logs-view.c
+++ b/src/libsysprof-ui/sysprof-logs-view.c
@@ -49,12 +49,64 @@ sysprof_logs_view_init (SysprofLogsView *self)
gtk_widget_init_template (GTK_WIDGET (self));
}
+static void
+sysprof_logs_view_load_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ g_autoptr(SysprofLogModel) model = NULL;
+ g_autoptr(GTask) task = user_data;
+ g_autoptr(GError) error = NULL;
+
+ g_assert (G_IS_ASYNC_RESULT (result));
+ g_assert (G_IS_TASK (task));
+
+ if (!(model = sysprof_log_model_new_finish (result, &error)))
+ {
+ g_task_return_error (task, g_steal_pointer (&error));
+ }
+ else
+ {
+ SysprofLogsView *self;
+
+ self = g_task_get_source_object (task);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (self->tree_view), GTK_TREE_MODEL (model));
+ g_task_return_boolean (task, TRUE);
+ }
+}
+
void
-sysprof_logs_view_set_model (SysprofLogsView *self,
- SysprofLogModel *model)
+sysprof_logs_view_load_async (SysprofLogsView *self,
+ SysprofCaptureReader *reader,
+ SysprofSelection *selection,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
+ g_autoptr(GTask) task = NULL;
+
g_return_if_fail (SYSPROF_IS_LOGS_VIEW (self));
- g_return_if_fail (!model || SYSPROF_IS_LOG_MODEL (model));
+ g_return_if_fail (reader != NULL);
+ g_return_if_fail (!selection || SYSPROF_IS_SELECTION (selection));
+ g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ task = g_task_new (self, cancellable, callback, user_data);
+ g_task_set_source_tag (task, sysprof_logs_view_load_async);
+
+ sysprof_log_model_new_async (reader,
+ selection,
+ cancellable,
+ sysprof_logs_view_load_cb,
+ g_steal_pointer (&task));
+}
- gtk_tree_view_set_model (GTK_TREE_VIEW (self->tree_view), GTK_TREE_MODEL (model));
-}
+gboolean
+sysprof_logs_view_load_finish (SysprofLogsView *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (SYSPROF_IS_LOGS_VIEW (self), FALSE);
+ g_return_val_if_fail (G_IS_TASK (result), FALSE);
+
+ return g_task_propagate_boolean (G_TASK (result), error);
+}
diff --git a/src/libsysprof-ui/sysprof-logs-view.h b/src/libsysprof-ui/sysprof-logs-view.h
index 11dec75..5ff2135 100644
--- a/src/libsysprof-ui/sysprof-logs-view.h
+++ b/src/libsysprof-ui/sysprof-logs-view.h
@@ -30,7 +30,14 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (SysprofLogsView, sysprof_logs_view, SYSPROF, LOGS_VIEW, GtkBin)
-void sysprof_logs_view_set_model (SysprofLogsView *self,
- SysprofLogModel *model);
+void sysprof_logs_view_load_async (SysprofLogsView *self,
+ SysprofCaptureReader *reader,
+ SysprofSelection *selection,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean sysprof_logs_view_load_finish (SysprofLogsView *self,
+ GAsyncResult *result,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]