From 72f84c2c64d0b0fdca8476b2a3a0a06c33eae0d5 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 19 Jul 2023 15:40:42 -0700 Subject: [PATCH] sysprof: add expand/collapse actions This way we can work with columnview and listview. --- src/sysprof/sysprof-tree-expander.c | 32 +++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/sysprof/sysprof-tree-expander.c b/src/sysprof/sysprof-tree-expander.c index e653e5ac..004f9971 100644 --- a/src/sysprof/sysprof-tree-expander.c +++ b/src/sysprof/sysprof-tree-expander.c @@ -212,10 +212,36 @@ sysprof_tree_expander_click_cancel_cb (SysprofTreeExpander *self, gtk_gesture_set_state (GTK_GESTURE (click), GTK_EVENT_SEQUENCE_CLAIMED); } +static void +sysprof_tree_expander_expand (GtkWidget *widget, + const char *action_name, + GVariant *parameter) +{ + SysprofTreeExpander *self = (SysprofTreeExpander *)widget; + + g_assert (SYSPROF_IS_TREE_EXPANDER (self)); + + if (self->list_row != NULL) + gtk_tree_list_row_set_expanded (self->list_row, TRUE); +} + +static void +sysprof_tree_expander_collapse (GtkWidget *widget, + const char *action_name, + GVariant *parameter) +{ + SysprofTreeExpander *self = (SysprofTreeExpander *)widget; + + g_assert (SYSPROF_IS_TREE_EXPANDER (self)); + + if (self->list_row != NULL) + gtk_tree_list_row_set_expanded (self->list_row, FALSE); +} + static void sysprof_tree_expander_toggle_expand (GtkWidget *widget, - const char *action_name, - GVariant *parameter) + const char *action_name, + GVariant *parameter) { SysprofTreeExpander *self = (SysprofTreeExpander *)widget; @@ -424,6 +450,8 @@ sysprof_tree_expander_class_init (SysprofTreeExpanderClass *klass) gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GROUP); gtk_widget_class_install_action (widget_class, "listitem.toggle-expand", NULL, sysprof_tree_expander_toggle_expand); + gtk_widget_class_install_action (widget_class, "listitem.collapse", NULL, sysprof_tree_expander_collapse); + gtk_widget_class_install_action (widget_class, "listitem.expand", NULL, sysprof_tree_expander_expand); } static void