From 90dcf98248907349c1b867cb8aebf0d278531f12 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 25 Jul 2023 18:00:18 -0700 Subject: [PATCH] sysprof: allow filtering functions --- src/sysprof/sysprof-callgraph-view-private.h | 1 + src/sysprof/sysprof-callgraph-view.c | 8 ++- src/sysprof/sysprof-callgraph-view.ui | 65 +++++++++++++++----- 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/sysprof/sysprof-callgraph-view-private.h b/src/sysprof/sysprof-callgraph-view-private.h index 55443808..597a672a 100644 --- a/src/sysprof/sysprof-callgraph-view-private.h +++ b/src/sysprof/sysprof-callgraph-view-private.h @@ -46,6 +46,7 @@ struct _SysprofCallgraphView GtkCustomSorter *functions_name_sorter; GtkScrolledWindow *scrolled_window; GtkWidget *paned; + GtkStringFilter *function_filter; GCancellable *cancellable; diff --git a/src/sysprof/sysprof-callgraph-view.c b/src/sysprof/sysprof-callgraph-view.c index 1f6f1d0d..701bc740 100644 --- a/src/sysprof/sysprof-callgraph-view.c +++ b/src/sysprof/sysprof-callgraph-view.c @@ -514,6 +514,7 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass) gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, descendants_name_sorter); 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, function_filter); gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, paned); gtk_widget_class_install_action (widget_class, "callgraph.make-descendant-root", NULL, make_descendant_root_action); @@ -523,6 +524,7 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass) g_resources_register (sysprof_get_resource ()); g_type_ensure (PANEL_TYPE_PANED); + g_type_ensure (SYSPROF_TYPE_CALLGRAPH_SYMBOL); g_type_ensure (SYSPROF_TYPE_CATEGORY_ICON); g_type_ensure (SYSPROF_TYPE_SYMBOL_LABEL); g_type_ensure (SYSPROF_TYPE_TREE_EXPANDER); @@ -589,6 +591,7 @@ sysprof_callgraph_view_reload_cb (GObject *object, { SysprofDocument *document = (SysprofDocument *)object; g_autoptr(SysprofCallgraphView) self = user_data; + g_autoptr(GtkFilterListModel) filter_model = NULL; g_autoptr(SysprofCallgraph) callgraph = NULL; g_autoptr(GError) error = NULL; GtkSorter *column_sorter; @@ -613,7 +616,10 @@ sysprof_callgraph_view_reload_cb (GObject *object, column_sorter = gtk_column_view_get_sorter (self->functions_column_view); functions_model = sysprof_callgraph_list_symbols (callgraph); - functions_sort_model = gtk_sort_list_model_new (g_object_ref (functions_model), + filter_model = gtk_filter_list_model_new (g_object_ref (G_LIST_MODEL (functions_model)), + g_object_ref (GTK_FILTER (self->function_filter))); + gtk_filter_list_model_set_incremental (filter_model, TRUE); + functions_sort_model = gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (filter_model)), g_object_ref (column_sorter)); functions_selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (functions_sort_model))); gtk_single_selection_set_autoselect (functions_selection, FALSE); diff --git a/src/sysprof/sysprof-callgraph-view.ui b/src/sysprof/sysprof-callgraph-view.ui index c86058b8..534bf3bb 100644 --- a/src/sysprof/sysprof-callgraph-view.ui +++ b/src/sysprof/sysprof-callgraph-view.ui @@ -7,23 +7,26 @@ vertical - - true - true - never + + vertical - + + true + true + never - - Functions - true - - - - - - - + + + Functions + true + + + + + + + - ]]> + ]]> + + + - + + + + + + + + + + Filter Functions + 3 + 3 + 3 + 3 + true @@ -265,4 +285,15 @@ + + substring + + + + + + + filter_search_entry + +