libsysprof-ui: hide callgraph when no data is present

This commit is contained in:
Christian Hergert
2019-05-15 16:53:11 -07:00
parent 0c62fd13d4
commit 89293254c5
2 changed files with 140 additions and 113 deletions

View File

@ -54,6 +54,7 @@ typedef struct
GtkTreeView *functions_view; GtkTreeView *functions_view;
GtkTreeView *descendants_view; GtkTreeView *descendants_view;
GtkTreeViewColumn *descendants_name_column; GtkTreeViewColumn *descendants_name_column;
GtkStack *stack;
GQueue *history; GQueue *history;
@ -173,9 +174,10 @@ sysprof_callgraph_view_load (SysprofCallgraphView *self,
* insensitive and give some indication of loading progress. * insensitive and give some indication of loading progress.
*/ */
g_set_object (&priv->profile, profile); if (!g_set_object (&priv->profile, profile))
return;
if (NULL == (stash = sysprof_callgraph_profile_get_stash (profile))) if (!(stash = sysprof_callgraph_profile_get_stash (profile)))
return; return;
for (n = stack_stash_get_root (stash); n; n = n->siblings) for (n = stack_stash_get_root (stash); n; n = n->siblings)
@ -202,6 +204,8 @@ sysprof_callgraph_view_load (SysprofCallgraphView *self,
gtk_tree_selection_select_iter (selection, &iter); gtk_tree_selection_select_iter (selection, &iter);
} }
gtk_stack_set_visible_child_name (priv->stack, "callgraph");
g_clear_object (&functions); g_clear_object (&functions);
} }
@ -220,6 +224,8 @@ sysprof_callgraph_view_unload (SysprofCallgraphView *self)
gtk_tree_view_set_model (priv->callers_view, NULL); gtk_tree_view_set_model (priv->callers_view, NULL);
gtk_tree_view_set_model (priv->functions_view, NULL); gtk_tree_view_set_model (priv->functions_view, NULL);
gtk_tree_view_set_model (priv->descendants_view, NULL); gtk_tree_view_set_model (priv->descendants_view, NULL);
gtk_stack_set_visible_child_name (priv->stack, "empty-state");
} }
/** /**
@ -758,6 +764,7 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, functions_view); gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, functions_view);
gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, descendants_view); gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, descendants_view);
gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, descendants_name_column); gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, descendants_name_column);
gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, stack);
bindings = gtk_binding_set_by_class (klass); bindings = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (bindings, GDK_KEY_Left, GDK_MOD1_MASK, "go-previous", 0); gtk_binding_entry_add_signal (bindings, GDK_KEY_Left, GDK_MOD1_MASK, "go-previous", 0);
@ -776,6 +783,8 @@ sysprof_callgraph_view_init (SysprofCallgraphView *self)
gtk_widget_init_template (GTK_WIDGET (self)); gtk_widget_init_template (GTK_WIDGET (self));
gtk_stack_set_visible_child_name (priv->stack, "empty-state");
selection = gtk_tree_view_get_selection (priv->functions_view); selection = gtk_tree_view_get_selection (priv->functions_view);
g_signal_connect_object (selection, g_signal_connect_object (selection,

View File

@ -1,5 +1,8 @@
<interface> <interface>
<template class="SysprofCallgraphView" parent="GtkBin"> <template class="SysprofCallgraphView" parent="GtkBin">
<child>
<object class="GtkStack" id="stack">
<property name="visible">true</property>
<child> <child>
<object class="GtkPaned"> <object class="GtkPaned">
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
@ -185,6 +188,21 @@
</object> </object>
</child> </child>
</object> </object>
<packing>
<property name="name">callgraph</property>
</packing>
</child>
<child>
<object class="SysprofEmptyStateView">
<property name="title" translatable="yes">Not Enough Samples</property>
<property name="subtitle" translatable="yes">More samples are necessary to display a callgraph.</property>
<property name="visible">true</property>
</object>
<packing>
<property name="name">empty-state</property>
</packing>
</child>
</object>
</child> </child>
</template> </template>
</interface> </interface>