From 1e3345ae42046ced6975dd0c4ec1303d79c1c647 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 16 Jun 2023 17:28:44 -0700 Subject: [PATCH] libsysprof-gtk: select time range when activating mark w/ duration --- src/libsysprof-gtk/sysprof-mark-table.c | 26 ++++++++++++++++++++++++ src/libsysprof-gtk/sysprof-mark-table.ui | 1 + 2 files changed, 27 insertions(+) diff --git a/src/libsysprof-gtk/sysprof-mark-table.c b/src/libsysprof-gtk/sysprof-mark-table.c index 055b980e..97f77954 100644 --- a/src/libsysprof-gtk/sysprof-mark-table.c +++ b/src/libsysprof-gtk/sysprof-mark-table.c @@ -84,6 +84,31 @@ sysprof_mark_table_connect (SysprofMarkTable *self) GTK_SORT_ASCENDING); } +static void +sysprof_mark_table_activate_cb (SysprofMarkTable *self, + guint position, + GtkColumnView *column_view) +{ + g_autoptr(SysprofDocumentMark) mark = NULL; + SysprofTimeSpan time_span; + GListModel *model; + + g_assert (SYSPROF_IS_MARK_TABLE (self)); + g_assert (GTK_IS_COLUMN_VIEW (column_view)); + + if (self->session == NULL) + return; + + model = G_LIST_MODEL (gtk_column_view_get_model (column_view)); + mark = g_list_model_get_item (model, position); + + time_span.begin_nsec = sysprof_document_frame_get_time (SYSPROF_DOCUMENT_FRAME (mark)); + time_span.end_nsec = time_span.begin_nsec + sysprof_document_mark_get_duration (mark); + + if (time_span.end_nsec != time_span.begin_nsec) + sysprof_session_select_time (self->session, &time_span); +} + static void sysprof_mark_table_dispose (GObject *object) { @@ -161,6 +186,7 @@ sysprof_mark_table_class_init (SysprofMarkTableClass *klass) gtk_widget_class_bind_template_child (widget_class, SysprofMarkTable, box); gtk_widget_class_bind_template_child (widget_class, SysprofMarkTable, column_view); gtk_widget_class_bind_template_child (widget_class, SysprofMarkTable, start_column); + gtk_widget_class_bind_template_callback (widget_class, sysprof_mark_table_activate_cb); g_resources_register (libsysprof_gtk_get_resource ()); diff --git a/src/libsysprof-gtk/sysprof-mark-table.ui b/src/libsysprof-gtk/sysprof-mark-table.ui index 71c22e21..fd6e32e6 100644 --- a/src/libsysprof-gtk/sysprof-mark-table.ui +++ b/src/libsysprof-gtk/sysprof-mark-table.ui @@ -12,6 +12,7 @@ + true