From a234cc219748f4788d806917b6d1ffdd7350fbc8 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 12 Jul 2023 14:49:32 -0700 Subject: [PATCH] libsysprof-gtk: add SysprofCallgraphView:utillity-traceables This property is meant to hold accessory traceables that match the current selection in the callgraph view. Eventually we want this bridged with the callgraph sections to show something useful. --- .../sysprof-callgraph-view-private.h | 1 + src/libsysprof-gtk/sysprof-callgraph-view.c | 26 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/libsysprof-gtk/sysprof-callgraph-view-private.h b/src/libsysprof-gtk/sysprof-callgraph-view-private.h index 721f0aed..43df9c99 100644 --- a/src/libsysprof-gtk/sysprof-callgraph-view-private.h +++ b/src/libsysprof-gtk/sysprof-callgraph-view-private.h @@ -35,6 +35,7 @@ struct _SysprofCallgraphView SysprofDocument *document; SysprofCallgraph *callgraph; GListModel *traceables; + GListModel *utility_traceables; GtkColumnView *callers_column_view; GtkColumnView *descendants_column_view; diff --git a/src/libsysprof-gtk/sysprof-callgraph-view.c b/src/libsysprof-gtk/sysprof-callgraph-view.c index bca4ee3e..839d9d0b 100644 --- a/src/libsysprof-gtk/sysprof-callgraph-view.c +++ b/src/libsysprof-gtk/sysprof-callgraph-view.c @@ -34,6 +34,7 @@ enum { PROP_HIDE_SYSTEM_LIBRARIES, PROP_INCLUDE_THREADS, PROP_TRACEABLES, + PROP_UTILITY_TRACEABLES, N_PROPS }; @@ -50,6 +51,17 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (SysprofCallgraphView, sysprof_callgraph_view, static GParamSpec *properties [N_PROPS]; +static void +sysprof_callgraph_view_set_utility_traceables (SysprofCallgraphView *self, + GListModel *model) +{ + g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); + g_assert (!model || G_IS_LIST_MODEL (model)); + + if (g_set_object (&self->utility_traceables, model)) + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_UTILITY_TRACEABLES]); +} + static void sysprof_callgraph_view_set_descendants (SysprofCallgraphView *self, GListModel *model) @@ -181,6 +193,8 @@ sysprof_callgraph_view_list_traceables_cb (GObject *object, traceables_selection_changed_cb (self, 0, 0, single); } + sysprof_callgraph_view_set_utility_traceables (self, model); + gtk_widget_set_visible (gtk_widget_get_parent (GTK_WIDGET (self->right_paned)), model && g_list_model_get_n_items (model)); } @@ -197,7 +211,7 @@ descendants_selection_changed_cb (SysprofCallgraphView *self, g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self)); g_assert (GTK_IS_SINGLE_SELECTION (single)); - gtk_column_view_set_model (self->traceables_column_view, NULL); + sysprof_callgraph_view_set_utility_traceables (self, NULL); if ((object = gtk_single_selection_get_selected_item (single)) && GTK_IS_TREE_LIST_ROW (object) && @@ -364,6 +378,7 @@ sysprof_callgraph_view_dispose (GObject *object) g_clear_object (&self->callgraph); g_clear_object (&self->document); g_clear_object (&self->traceables); + g_clear_object (&self->utility_traceables); G_OBJECT_CLASS (sysprof_callgraph_view_parent_class)->dispose (object); } @@ -398,6 +413,10 @@ sysprof_callgraph_view_get_property (GObject *object, g_value_set_object (value, sysprof_callgraph_view_get_traceables (self)); break; + case PROP_UTILITY_TRACEABLES: + g_value_set_object (value, self->utility_traceables); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -469,6 +488,11 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass) G_TYPE_LIST_MODEL, (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + properties[PROP_UTILITY_TRACEABLES] = + g_param_spec_object ("utility-traceables", NULL, NULL, + G_TYPE_LIST_MODEL, + (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_properties (object_class, N_PROPS, properties); gtk_widget_class_set_template_from_resource (widget_class, "/libsysprof-gtk/sysprof-callgraph-view.ui");