libsysprof-gtk: rename descendants view for legibility

This commit is contained in:
Christian Hergert
2023-06-12 11:23:35 -07:00
parent 451e79a84c
commit fa35089e93
5 changed files with 52 additions and 47 deletions

View File

@ -33,7 +33,7 @@ struct _SysprofCallgraphView
SysprofDocument *document;
GListModel *traceables;
GtkColumnView *column_view;
GtkColumnView *descendants_column_view;
GtkColumnView *functions_column_view;
GtkScrolledWindow *scrolled_window;
GtkWidget *paned;

View File

@ -152,7 +152,7 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/libsysprof-gtk/sysprof-callgraph-view.ui");
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, column_view);
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, descendants_column_view);
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, functions_column_view);
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, paned);
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, scrolled_window);
@ -187,17 +187,19 @@ sysprof_callgraph_view_reload_cb (GObject *object,
SysprofDocument *document = (SysprofDocument *)object;
g_autoptr(SysprofCallgraphView) self = user_data;
g_autoptr(SysprofCallgraph) callgraph = NULL;
g_autoptr(GtkTreeListRowSorter) sorter = NULL;
g_autoptr(GtkMultiSelection) model = NULL;
g_autoptr(GtkSingleSelection) functions_selection = NULL;
g_autoptr(GtkSortListModel) sort_model = NULL;
g_autoptr(GtkSortListModel) functions_sort_model = NULL;
g_autoptr(GListModel) functions_model = NULL;
g_autoptr(GtkTreeListModel) tree = NULL;
g_autoptr(GtkTreeListRow) first = NULL;
g_autoptr(GError) error = NULL;
GtkSorter *column_sorter;
g_autoptr(GtkTreeListRowSorter) descendants_sorter = NULL;
g_autoptr(GtkMultiSelection) descendants_selection = NULL;
g_autoptr(GtkSortListModel) descendants_sort_model = NULL;
g_autoptr(GtkTreeListModel) descendants_tree = NULL;
g_autoptr(GtkTreeListRow) descendants_first = NULL;
g_autoptr(GtkSingleSelection) functions_selection = NULL;
g_autoptr(GtkSortListModel) functions_sort_model = NULL;
g_autoptr(GListModel) functions_model = NULL;
g_assert (SYSPROF_IS_DOCUMENT (document));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
@ -208,18 +210,16 @@ sysprof_callgraph_view_reload_cb (GObject *object,
return;
}
tree = gtk_tree_list_model_new (g_object_ref (G_LIST_MODEL (callgraph)),
FALSE,
FALSE,
sysprof_callgraph_view_create_model_func,
NULL,
NULL);
column_sorter = gtk_column_view_get_sorter (self->column_view);
sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
sort_model = gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (tree)),
g_object_ref (GTK_SORTER (sorter)));
model = gtk_multi_selection_new (g_object_ref (G_LIST_MODEL (sort_model)));
gtk_column_view_set_model (self->column_view, GTK_SELECTION_MODEL (model));
column_sorter = gtk_column_view_get_sorter (self->descendants_column_view);
descendants_tree = gtk_tree_list_model_new (g_object_ref (G_LIST_MODEL (callgraph)),
FALSE, FALSE,
sysprof_callgraph_view_create_model_func,
NULL, NULL);
descendants_sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
descendants_sort_model = gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (descendants_tree)),
g_object_ref (GTK_SORTER (descendants_sorter)));
descendants_selection = gtk_multi_selection_new (g_object_ref (G_LIST_MODEL (descendants_sort_model)));
gtk_column_view_set_model (self->descendants_column_view, GTK_SELECTION_MODEL (descendants_selection));
column_sorter = gtk_column_view_get_sorter (self->functions_column_view);
functions_model = sysprof_callgraph_list_symbols (callgraph);
@ -232,8 +232,8 @@ sysprof_callgraph_view_reload_cb (GObject *object,
if (SYSPROF_CALLGRAPH_VIEW_GET_CLASS (self)->load)
SYSPROF_CALLGRAPH_VIEW_GET_CLASS (self)->load (self, callgraph);
if ((first = gtk_tree_list_model_get_row (tree, 0)))
gtk_tree_list_row_set_expanded (first, TRUE);
if ((descendants_first = gtk_tree_list_model_get_row (descendants_tree, 0)))
gtk_tree_list_row_set_expanded (descendants_first, TRUE);
}
static gboolean
@ -261,7 +261,8 @@ sysprof_callgraph_view_queue_reload (SysprofCallgraphView *self)
{
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
gtk_column_view_set_model (self->column_view, NULL);
gtk_column_view_set_model (self->descendants_column_view, NULL);
gtk_column_view_set_model (self->functions_column_view, NULL);
g_clear_handle_id (&self->reload_source, g_source_remove);
g_cancellable_cancel (self->cancellable);
@ -340,8 +341,8 @@ sysprof_callgraph_view_get_internal_child (GtkBuildable *buildable,
GtkBuilder *builder,
const char *name)
{
if (g_strcmp0 (name, "column_view") == 0)
return G_OBJECT (SYSPROF_CALLGRAPH_VIEW (buildable)->column_view);
if (g_strcmp0 (name, "descendants_column_view") == 0)
return G_OBJECT (SYSPROF_CALLGRAPH_VIEW (buildable)->descendants_column_view);
else if (g_strcmp0 (name, "functions_column_view") == 0)
return G_OBJECT (SYSPROF_CALLGRAPH_VIEW (buildable)->functions_column_view);

View File

@ -52,7 +52,7 @@
<property name="end-child">
<object class="GtkScrolledWindow" id="scrolled_window">
<child>
<object class="GtkColumnView" id="column_view">
<object class="GtkColumnView" id="descendants_column_view">
<style>
<class name="data-table"/>
</style>

View File

@ -28,10 +28,10 @@ struct _SysprofWeightedCallgraphView
{
SysprofCallgraphView parent_instance;
GtkColumnViewColumn *self_column;
GtkColumnViewColumn *total_column;
GtkCustomSorter *self_sorter;
GtkCustomSorter *total_sorter;
GtkColumnViewColumn *descendants_self_column;
GtkColumnViewColumn *descendants_total_column;
GtkCustomSorter *descendants_self_sorter;
GtkCustomSorter *descendants_total_sorter;
GtkColumnViewColumn *functions_self_column;
GtkColumnViewColumn *functions_total_column;
@ -262,14 +262,18 @@ sysprof_weighted_callgraph_view_load (SysprofCallgraphView *view,
root = sysprof_callgraph_get_augment (callgraph, NULL);
gtk_custom_sorter_set_sort_func (self->self_sorter, descendants_sort_by_self, root, NULL);
gtk_custom_sorter_set_sort_func (self->total_sorter, descendants_sort_by_total, root, NULL);
gtk_custom_sorter_set_sort_func (self->descendants_self_sorter,
descendants_sort_by_self, root, NULL);
gtk_custom_sorter_set_sort_func (self->descendants_total_sorter,
descendants_sort_by_total, root, NULL);
gtk_custom_sorter_set_sort_func (self->functions_self_sorter, functions_sort_by_self, root, NULL);
gtk_custom_sorter_set_sort_func (self->functions_total_sorter, functions_sort_by_total, root, NULL);
gtk_custom_sorter_set_sort_func (self->functions_self_sorter,
functions_sort_by_self, root, NULL);
gtk_custom_sorter_set_sort_func (self->functions_total_sorter,
functions_sort_by_total, root, NULL);
gtk_column_view_sort_by_column (SYSPROF_CALLGRAPH_VIEW (self)->column_view,
self->total_column,
gtk_column_view_sort_by_column (SYSPROF_CALLGRAPH_VIEW (self)->descendants_column_view,
self->descendants_total_column,
GTK_SORT_DESCENDING);
gtk_column_view_sort_by_column (SYSPROF_CALLGRAPH_VIEW (self)->functions_column_view,
self->functions_total_column,
@ -288,10 +292,10 @@ sysprof_weighted_callgraph_view_class_init (SysprofWeightedCallgraphViewClass *k
gtk_widget_class_set_template_from_resource (widget_class, "/libsysprof-gtk/sysprof-weighted-callgraph-view.ui");
gtk_widget_class_bind_template_child (widget_class, SysprofWeightedCallgraphView, self_column);
gtk_widget_class_bind_template_child (widget_class, SysprofWeightedCallgraphView, total_column);
gtk_widget_class_bind_template_child (widget_class, SysprofWeightedCallgraphView, self_sorter);
gtk_widget_class_bind_template_child (widget_class, SysprofWeightedCallgraphView, total_sorter);
gtk_widget_class_bind_template_child (widget_class, SysprofWeightedCallgraphView, descendants_self_column);
gtk_widget_class_bind_template_child (widget_class, SysprofWeightedCallgraphView, descendants_total_column);
gtk_widget_class_bind_template_child (widget_class, SysprofWeightedCallgraphView, descendants_self_sorter);
gtk_widget_class_bind_template_child (widget_class, SysprofWeightedCallgraphView, descendants_total_sorter);
gtk_widget_class_bind_template_child (widget_class, SysprofWeightedCallgraphView, functions_self_column);
gtk_widget_class_bind_template_child (widget_class, SysprofWeightedCallgraphView, functions_total_column);

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="SysprofWeightedCallgraphView" parent="SysprofCallgraphView">
<child internal-child="column_view">
<child internal-child="descendants_column_view">
<object class="GtkColumnView">
<child>
<object class="GtkColumnViewColumn" id="self_column">
<object class="GtkColumnViewColumn" id="descendants_self_column">
<property name="title" translatable="yes">Self</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
@ -28,13 +28,13 @@
</object>
</property>
<property name="sorter">
<object class="GtkCustomSorter" id="self_sorter">
<object class="GtkCustomSorter" id="descendants_self_sorter">
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="total_column">
<object class="GtkColumnViewColumn" id="descendants_total_column">
<property name="title" translatable="yes">Total</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
@ -58,7 +58,7 @@
</object>
</property>
<property name="sorter">
<object class="GtkCustomSorter" id="total_sorter">
<object class="GtkCustomSorter" id="descendants_total_sorter">
</object>
</property>
</object>