libsysprof-gtk: allow sorting by function name

This commit is contained in:
Christian Hergert
2023-06-12 12:31:25 -07:00
parent ac09c98b70
commit 98b84def81
3 changed files with 21 additions and 0 deletions

View File

@ -37,6 +37,7 @@ struct _SysprofCallgraphView
GtkColumnView *callers_column_view;
GtkColumnView *descendants_column_view;
GtkColumnView *functions_column_view;
GtkCustomSorter *functions_name_sorter;
GtkScrolledWindow *scrolled_window;
GtkWidget *paned;

View File

@ -215,6 +215,7 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass)
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, callers_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, functions_name_sorter);
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, paned);
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, scrolled_window);
gtk_widget_class_bind_template_callback (widget_class, sysprof_callgraph_view_key_pressed_cb);
@ -230,6 +231,18 @@ sysprof_callgraph_view_init (SysprofCallgraphView *self)
gtk_widget_init_template (GTK_WIDGET (self));
}
static int
functions_name_compare (gconstpointer a,
gconstpointer b,
gpointer user_data)
{
SysprofCallgraphSymbol *sym_a = (SysprofCallgraphSymbol *)a;
SysprofCallgraphSymbol *sym_b = (SysprofCallgraphSymbol *)b;
return g_strcmp0 (sysprof_symbol_get_name (sysprof_callgraph_symbol_get_symbol (sym_a)),
sysprof_symbol_get_name (sysprof_callgraph_symbol_get_symbol (sym_b)));
}
static GListModel *
sysprof_callgraph_view_create_model_func (gpointer item,
gpointer user_data)
@ -297,6 +310,9 @@ sysprof_callgraph_view_reload_cb (GObject *object,
gtk_column_view_set_model (self->functions_column_view,
GTK_SELECTION_MODEL (functions_selection));
gtk_custom_sorter_set_sort_func (self->functions_name_sorter,
functions_name_compare, NULL, NULL);
if (SYSPROF_CALLGRAPH_VIEW_GET_CLASS (self)->load)
SYSPROF_CALLGRAPH_VIEW_GET_CLASS (self)->load (self, callgraph);

View File

@ -17,6 +17,10 @@
<object class="GtkColumnViewColumn" id="functions_name_column">
<property name="title" translatable="yes">Functions</property>
<property name="expand">true</property>
<property name="sorter">
<object class="GtkCustomSorter" id="functions_name_sorter">
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[