From abdd54619778c1bf5a5c4a5d0f9d9f77d368c0c7 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 12 Jun 2023 12:50:25 -0700 Subject: [PATCH] libsysprof-gtk: add getter for callgraph --- src/libsysprof-gtk/sysprof-callgraph-view.c | 28 +++++++++++++++++++++ src/libsysprof-gtk/sysprof-callgraph-view.h | 16 ++++++------ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/libsysprof-gtk/sysprof-callgraph-view.c b/src/libsysprof-gtk/sysprof-callgraph-view.c index 46b11873..4fb0995a 100644 --- a/src/libsysprof-gtk/sysprof-callgraph-view.c +++ b/src/libsysprof-gtk/sysprof-callgraph-view.c @@ -26,6 +26,7 @@ enum { PROP_0, + PROP_CALLGRAPH, PROP_DOCUMENT, PROP_TRACEABLES, N_PROPS @@ -154,6 +155,10 @@ sysprof_callgraph_view_get_property (GObject *object, switch (prop_id) { + case PROP_CALLGRAPH: + g_value_set_object (value, sysprof_callgraph_view_get_callgraph (self)); + break; + case PROP_DOCUMENT: g_value_set_object (value, sysprof_callgraph_view_get_document (self)); break; @@ -200,6 +205,11 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass) object_class->get_property = sysprof_callgraph_view_get_property; object_class->set_property = sysprof_callgraph_view_set_property; + properties[PROP_CALLGRAPH] = + g_param_spec_object ("callgraph", NULL, NULL, + SYSPROF_TYPE_CALLGRAPH, + (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + properties[PROP_DOCUMENT] = g_param_spec_object ("document", NULL, NULL, SYSPROF_TYPE_DOCUMENT, @@ -338,6 +348,8 @@ sysprof_callgraph_view_reload_cb (GObject *object, if ((descendants_first = gtk_tree_list_model_get_row (descendants_tree, 0))) gtk_tree_list_row_set_expanded (descendants_first, TRUE); + + g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CALLGRAPH]); } static gboolean @@ -460,3 +472,19 @@ buildable_iface_init (GtkBuildableIface *iface) { iface->get_internal_child = sysprof_callgraph_view_get_internal_child; } + +/** + * sysprof_callgraph_view_get_callgraph: + * @self: a #SysprofCallgraphView + * + * Gets the callgraph being displayed. + * + * Returns: (transfer none) (nullable): a #SysprofCallgraph or %NULL + */ +SysprofCallgraph * +sysprof_callgraph_view_get_callgraph (SysprofCallgraphView *self) +{ + g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self), NULL); + + return self->callgraph; +} diff --git a/src/libsysprof-gtk/sysprof-callgraph-view.h b/src/libsysprof-gtk/sysprof-callgraph-view.h index f61de95e..c4523e80 100644 --- a/src/libsysprof-gtk/sysprof-callgraph-view.h +++ b/src/libsysprof-gtk/sysprof-callgraph-view.h @@ -36,17 +36,19 @@ typedef struct _SysprofCallgraphView SysprofCallgraphView; typedef struct _SysprofCallgraphViewClass SysprofCallgraphViewClass; SYSPROF_AVAILABLE_IN_ALL -GType sysprof_callgraph_view_get_type (void) G_GNUC_CONST; +GType sysprof_callgraph_view_get_type (void) G_GNUC_CONST; SYSPROF_AVAILABLE_IN_ALL -SysprofDocument *sysprof_callgraph_view_get_document (SysprofCallgraphView *self); +SysprofCallgraph *sysprof_callgraph_view_get_callgraph (SysprofCallgraphView *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_callgraph_view_set_document (SysprofCallgraphView *self, - SysprofDocument *document); +SysprofDocument *sysprof_callgraph_view_get_document (SysprofCallgraphView *self); SYSPROF_AVAILABLE_IN_ALL -GListModel *sysprof_callgraph_view_get_traceables (SysprofCallgraphView *self); +void sysprof_callgraph_view_set_document (SysprofCallgraphView *self, + SysprofDocument *document); SYSPROF_AVAILABLE_IN_ALL -void sysprof_callgraph_view_set_traceables (SysprofCallgraphView *self, - GListModel *model); +GListModel *sysprof_callgraph_view_get_traceables (SysprofCallgraphView *self); +SYSPROF_AVAILABLE_IN_ALL +void sysprof_callgraph_view_set_traceables (SysprofCallgraphView *self, + GListModel *model); G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCallgraphView, g_object_unref)