[gnome-builder] project-tree: Reveal left dock when using "Reveal in Project Tree"



commit f2f377ab9cdf4f94bc41853be75a0cb1a0ee398a
Author: vanadiae <vanadiae35 gmail com>
Date:   Tue Jun 1 20:17:38 2021 +0200

    project-tree: Reveal left dock when using "Reveal in Project Tree"
    
    Currently if the left dock (where the project tree lives) is hidden,
    then using the Reveal in Project Tree feature won't make it reveal from
    the side, which is annoying because if you want to reveal a file in the
    project tree then you'll surely want to actually see it, which isn't the
    case here as the dock isn't revealed. It means you need to press F9
    to manually reveal it instead of having it done automatically.
    
    So this commit removes this annoyance by revealing the left dock when
    revealing a file in the project tree.

 src/plugins/project-tree/gbp-project-tree.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/src/plugins/project-tree/gbp-project-tree.c b/src/plugins/project-tree/gbp-project-tree.c
index ffa55aa2d..c11984a1a 100644
--- a/src/plugins/project-tree/gbp-project-tree.c
+++ b/src/plugins/project-tree/gbp-project-tree.c
@@ -316,6 +316,22 @@ reveal_next (Reveal *r)
       ide_tree_select_node (IDE_TREE (r->tree), r->node);
       gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (r->tree),
                                     path, NULL, FALSE, 0, 0);
+
+      /* Due to the way tree views work, we need to use this function to
+       * grab keyboard focus on a particular row in the treeview. This allows
+       * pressing the menu key and navigate with the arrow keys in the tree
+       * view without leaving the keyboard :)
+       */
+      gtk_tree_view_set_cursor (GTK_TREE_VIEW (r->tree),
+                                path,
+                                NULL,
+                                FALSE);
+      /* We still need to grab the focus on the tree view widget as suggested
+       * by the documentation. ide_widget_reveal_and_grab() also makes the left
+       * dock show up automatically which is very nice because it avoids having
+       * to press F9 when it could have been revealed automatically.
+       */
+      ide_widget_reveal_and_grab (GTK_WIDGET (r->tree));
     }
 
 failure:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]