treeexpander: Scroll to expanded item
authorCorey Berla <corey@berla.me>
Wed, 30 Nov 2022 04:00:48 +0000 (20:00 -0800)
committerCorey Berla <corey@berla.me>
Wed, 30 Nov 2022 17:43:20 +0000 (09:43 -0800)
If the anchor is below the expanded item, the expanded item will
go out of view if there are sufficient children items.  This is not
ideal, so make sure to scroll to the item to ensure it remains in
view.

gtk/gtktreeexpander.c

index d2cce546a36fac5f7c574fa7113c4cd654f086ec..a89a51eb0be4e9a653652cd8f2b4f2f969b21fd9 100644 (file)
@@ -503,11 +503,17 @@ gtk_tree_expander_toggle_expand (GtkWidget  *widget,
                                  GVariant   *parameter)
 {
   GtkTreeExpander *self = GTK_TREE_EXPANDER (widget);
+  gboolean expand;
 
   if (self->list_row == NULL)
     return;
 
-  gtk_tree_list_row_set_expanded (self->list_row, !gtk_tree_list_row_get_expanded (self->list_row));
+  expand = !gtk_tree_list_row_get_expanded (self->list_row);
+
+  if (expand)
+    gtk_widget_activate_action (widget, "listitem.scroll-to", NULL);
+
+  gtk_tree_list_row_set_expanded (self->list_row, expand);
 }
 
 static gboolean