[anjuta] project-manager: Allow to add groups to the root of directory project



commit 15c5450914dd120f1b976f64649e515741b9d8ad
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Wed Mar 14 22:32:33 2012 +0100

    project-manager: Allow to add groups to the root of directory project

 plugins/project-manager/dialogs.c      |    4 ++--
 plugins/project-manager/project-view.c |   26 ++++++++++++++++++++++++++
 plugins/project-manager/project-view.h |    2 ++
 3 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/plugins/project-manager/dialogs.c b/plugins/project-manager/dialogs.c
index 69eb5e2..eff82e5 100644
--- a/plugins/project-manager/dialogs.c
+++ b/plugins/project-manager/dialogs.c
@@ -994,8 +994,8 @@ anjuta_pm_project_new_group (ProjectManagerPlugin *plugin, GtkWindow *parent, Gt
 				name = gtk_editable_get_chars (
 						GTK_EDITABLE (group_name_entry), 0, -1);
 
-				group = gbf_project_view_find_selected (GBF_PROJECT_VIEW (groups_view),
-														ANJUTA_PROJECT_GROUP);
+				group = gbf_project_view_find_selected_state (GBF_PROJECT_VIEW (groups_view),
+				                                              ANJUTA_PROJECT_CAN_ADD_GROUP);
 				if (group)
 				{
 					new_group = anjuta_pm_project_add_group (plugin->project, group, NULL, name, &err);
diff --git a/plugins/project-manager/project-view.c b/plugins/project-manager/project-view.c
index f4008f0..0905b4e 100644
--- a/plugins/project-manager/project-view.c
+++ b/plugins/project-manager/project-view.c
@@ -686,6 +686,32 @@ gbf_project_view_find_selected (GbfProjectView *view, AnjutaProjectNodeType type
 	return node;
 }
 
+AnjutaProjectNode *
+gbf_project_view_find_selected_state (GtkTreeView *view,
+                                      AnjutaProjectNodeState state)
+{
+	AnjutaProjectNode *node = NULL;
+	GbfTreeData *data;
+
+	g_return_val_if_fail (view != NULL, NULL);
+	g_return_val_if_fail (GBF_IS_PROJECT_VIEW (view), NULL);
+
+	data = gbf_project_view_get_first_selected (view, NULL);
+	if (data != NULL)
+	{
+
+		node = gbf_tree_data_get_node (data);
+
+		/* walk up the hierarchy searching for a node of the given type */
+		while ((node != NULL) && (state != 0) && !(anjuta_project_node_get_state (node) & state))
+		{
+			node = anjuta_project_node_parent (node);
+		}
+	}
+
+	return node;
+}
+
 GbfTreeData *
 gbf_project_view_get_first_selected (GbfProjectView *view, GtkTreeIter* selected)
 {
diff --git a/plugins/project-manager/project-view.h b/plugins/project-manager/project-view.h
index c6ae745..0b9982f 100644
--- a/plugins/project-manager/project-view.h
+++ b/plugins/project-manager/project-view.h
@@ -71,6 +71,8 @@ void			    gbf_project_view_set_visible_func (GbfProjectView *view,
 
 AnjutaProjectNode          *gbf_project_filter_view_find_selected     (GtkTreeView *view,
 									AnjutaProjectNodeType type);
+AnjutaProjectNode          *gbf_project_view_find_selected_state (GtkTreeView *view,
+                                                                  AnjutaProjectNodeState state);
 GList                      *gbf_project_filter_view_get_all_selected  (GtkTreeView *view);
 
 void			    gbf_project_view_set_cursor_to_iter (GbfProjectView *view,



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