[gnome-builder] project-tree: Unselect project file after expansion
- From: Matthew Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] project-tree: Unselect project file after expansion
- Date: Thu, 24 Nov 2016 05:26:16 +0000 (UTC)
commit f72cfa5b4566f0e7c2e3bee5b6ae0eb134c4648e
Author: Matthew Leeds <mleeds redhat com>
Date: Wed Nov 23 22:46:24 2016 -0600
project-tree: Unselect project file after expansion
In gb_project_tree_actions_refresh, we call gb_project_tree_reveal on
the project file to expand the tree, but the project file ends up
selected as well. This commit fixes that by adding an ide_tree_unselect_all
function and makes use of it. (In most cases when you do a reveal it makes
sense to have the node selected, just not this one).
libide/tree/ide-tree.c | 17 +++++++++++++++++
libide/tree/ide-tree.h | 1 +
plugins/project-tree/gb-project-tree-actions.c | 5 ++++-
3 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/libide/tree/ide-tree.c b/libide/tree/ide-tree.c
index a227e85..265e985 100644
--- a/libide/tree/ide-tree.c
+++ b/libide/tree/ide-tree.c
@@ -1098,6 +1098,23 @@ ide_tree_get_selected (IdeTree *self)
return ret;
}
+/**
+ * ide_tree_unselect_all:
+ * @self: (in): A #IdeTree.
+ *
+ * Unselects the currently selected node in the tree.
+ */
+void
+ide_tree_unselect_all (IdeTree *self)
+{
+ GtkTreeSelection *selection;
+
+ g_return_if_fail (IDE_IS_TREE (self));
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self));
+ gtk_tree_selection_unselect_all (selection);
+}
+
void
ide_tree_scroll_to_node (IdeTree *self,
IdeTreeNode *node)
diff --git a/libide/tree/ide-tree.h b/libide/tree/ide-tree.h
index 2cfc01e..64dfd8d 100644
--- a/libide/tree/ide-tree.h
+++ b/libide/tree/ide-tree.h
@@ -73,6 +73,7 @@ IdeTreeNode *ide_tree_find_custom (IdeTree *self,
GEqualFunc equal_func,
gpointer key);
IdeTreeNode *ide_tree_get_selected (IdeTree *self);
+void ide_tree_unselect_all (IdeTree *self);
void ide_tree_rebuild (IdeTree *self);
void ide_tree_set_root (IdeTree *self,
IdeTreeNode *node);
diff --git a/plugins/project-tree/gb-project-tree-actions.c b/plugins/project-tree/gb-project-tree-actions.c
index 7b55e49..e21ff91 100644
--- a/plugins/project-tree/gb-project-tree-actions.c
+++ b/plugins/project-tree/gb-project-tree-actions.c
@@ -99,7 +99,10 @@ gb_project_tree_actions_refresh (GSimpleAction *action,
GFile *project_file;
project_file = ide_context_get_project_file (context);
if (project_file != NULL)
- gb_project_tree_reveal (self, project_file, FALSE, FALSE);
+ {
+ gb_project_tree_reveal (self, project_file, FALSE, FALSE);
+ ide_tree_unselect_all (IDE_TREE (self));
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]