libsysprof-gtk: add getter for callgraph

This commit is contained in:
Christian Hergert
2023-06-12 12:50:25 -07:00
parent 68424bb4a5
commit abdd546197
2 changed files with 37 additions and 7 deletions

View File

@ -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;
}