[anjuta] pm: Allow selecting several items in the project view



commit 0346ba04fe4b390ea15c9bb78dde39ccfb348e4f
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sat Jan 16 12:53:31 2010 +0100

    pm: Allow selecting several items in the project view

 plugins/project-manager/gbf-project-model.c |   68 ++++++---
 plugins/project-manager/gbf-project-util.c  |    8 +-
 plugins/project-manager/gbf-project-view.c  |   99 ++++++++----
 plugins/project-manager/gbf-project-view.h  |    3 +-
 plugins/project-manager/gbf-tree-data.c     |    2 +-
 plugins/project-manager/plugin.c            |  240 ++++++++++++++++++---------
 6 files changed, 285 insertions(+), 135 deletions(-)
---
diff --git a/plugins/project-manager/gbf-project-model.c b/plugins/project-manager/gbf-project-model.c
index 70018ea..23ccdd6 100644
--- a/plugins/project-manager/gbf-project-model.c
+++ b/plugins/project-manager/gbf-project-model.c
@@ -466,12 +466,22 @@ move_target_shortcut (GbfProjectModel *model,
 		return;
 
 	root_path = gtk_tree_row_reference_get_path (model->priv->root_row);
+	
 	/* check before_path */
 	if (!before_path ||
-	    gtk_tree_path_get_depth (before_path) > 1 ||
-	    gtk_tree_path_compare (before_path, root_path) > 0) {
+	    gtk_tree_path_get_depth (before_path) > 1)
+	{
+		/* Missing destination path, use root path */
 		before_path = root_path;
 	}
+	else if (gtk_tree_path_compare (before_path, root_path) > 0)
+	{
+		/* Destination path outside shortcut are, remove shortcut */
+		gbf_project_model_remove (model, iter);
+		gtk_tree_path_free (root_path);
+		
+		return;
+	}
 		
 	/* get the tree iter for the row before which to insert the shortcut */
 	if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &sibling, before_path)) {
@@ -752,21 +762,15 @@ gbf_project_model_find_tree_data (GbfProjectModel 	*model,
 			          GtkTreeIter     	*iter,
 			          GbfTreeData  		*data)
 {
-	GtkTreePath *root;
 	GtkTreeIter tmp_iter;
 	gboolean retval = FALSE;
 	
-	root = gbf_project_model_get_project_root (model);
-	if (!root)
-		return FALSE;
-
-	if (gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &tmp_iter, root)) {
+	if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &tmp_iter)) {
 		if (recursive_find_tree_data (GTK_TREE_MODEL (model), &tmp_iter, data)) {
 			retval = TRUE;
 			*iter = tmp_iter;
 		}
 	}
-	gtk_tree_path_free (root);
 	
 	return retval;
 }
@@ -1067,10 +1071,11 @@ row_drop_possible (GtkTreeDragDest  *drag_dest,
 		   GtkTreePath      *dest_path,
 		   GtkSelectionData *selection_data)
 {
-	GtkTreePath *root_path;
+	GtkTreeModel *src_model;
+	GtkTreePath *src_path;
 	GbfProjectModel *model;
+	GtkTreeIter iter;
 	gboolean retval = FALSE;
-	GtkTreeModel *src_model = NULL;
   
 	g_return_val_if_fail (GBF_IS_PROJECT_MODEL (drag_dest), FALSE);
 
@@ -1078,19 +1083,40 @@ row_drop_possible (GtkTreeDragDest  *drag_dest,
 
 	if (!gtk_tree_get_row_drag_data (selection_data,
 					 &src_model,
-					 NULL))
+					 &src_path))
 		return FALSE;
-    
-	/* can only drag to ourselves and only new toplevel nodes will
-	 * be created */
-	if (src_model == GTK_TREE_MODEL (drag_dest) &&
-	    gtk_tree_path_get_depth (dest_path) == 1) {
-		root_path = gtk_tree_row_reference_get_path (model->priv->root_row);
-		if (gtk_tree_path_compare (dest_path, root_path) <= 0) {
-			retval = TRUE;
+	
+		
+	if (gtk_tree_model_get_iter (src_model, &iter, src_path))
+	{
+		GbfTreeData *data = NULL;
+		
+		gtk_tree_model_get (src_model, &iter,
+		    GBF_PROJECT_MODEL_COLUMN_DATA, &data, -1);
+
+		if (data != NULL)
+		{
+			/* can only drag to ourselves and only new toplevel nodes will
+			 * be created */
+			if (src_model == GTK_TREE_MODEL (drag_dest) &&
+	    			gtk_tree_path_get_depth (dest_path) == 1)
+			{
+				if (data->type == GBF_TREE_NODE_SHORTCUT)
+				{
+					retval = TRUE;
+				}
+				else
+				{
+					GtkTreePath *root_path;
+					
+					root_path = gtk_tree_row_reference_get_path (model->priv->root_row);
+					retval = gtk_tree_path_compare (dest_path, root_path) <= 0;
+					gtk_tree_path_free (root_path);
+				}
+			}
 		}
-		gtk_tree_path_free (root_path);
 	}
+	gtk_tree_path_free (src_path);
 
 	return retval;
 }
diff --git a/plugins/project-manager/gbf-project-util.c b/plugins/project-manager/gbf-project-util.c
index 4c7ac62..84ee0db 100644
--- a/plugins/project-manager/gbf-project-util.c
+++ b/plugins/project-manager/gbf-project-util.c
@@ -467,9 +467,11 @@ setup_targets_treeview (GbfProjectModel     *model,
 
     /* select default target */
     if (select_target) {
-        gtk_tree_model_filter_convert_child_iter_to_iter (
-                GTK_TREE_MODEL_FILTER (filter), &iter_filter, select_target);
-        path = gtk_tree_model_get_path (filter, &iter_filter);
+        if (gtk_tree_model_filter_convert_child_iter_to_iter (
+                GTK_TREE_MODEL_FILTER (filter), &iter_filter, select_target))
+        {
+            path = gtk_tree_model_get_path (filter, &iter_filter);
+        }
     }
     if (path)
     {
diff --git a/plugins/project-manager/gbf-project-view.c b/plugins/project-manager/gbf-project-view.c
index cffb67d..9a712ce 100644
--- a/plugins/project-manager/gbf-project-view.c
+++ b/plugins/project-manager/gbf-project-view.c
@@ -372,71 +372,106 @@ gbf_project_view_new (void)
 AnjutaProjectNode *
 gbf_project_view_find_selected (GbfProjectView *view, AnjutaProjectNodeType type)
 {
-	GtkTreeSelection *selection;
-	GtkTreeModel *model;
 	GtkTreeIter iter;
 	AnjutaProjectNode *node = NULL;
 
 	g_return_val_if_fail (view != NULL, NULL);
 	g_return_val_if_fail (GBF_IS_PROJECT_VIEW (view), NULL);
-	
-	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
-	if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
-		if (GBF_IS_PROJECT_MODEL (model))
-		{
-			node = gbf_project_model_get_node (GBF_PROJECT_MODEL (model), &iter);
-		}
-		else if (GTK_IS_TREE_MODEL_FILTER (model))
+
+	if (gbf_project_view_get_first_selected (view, &iter) != NULL)
+	{
+		GtkTreeModel *model;
+		
+		model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+		if (GTK_IS_TREE_MODEL_FILTER (model))
 		{
-			GtkTreeIter child_iter;
-			
-			gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &child_iter, &iter);
+			GtkTreeIter filter_iter = iter;
+			gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &iter, &filter_iter);
 			model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
-			node = gbf_project_model_get_node (GBF_PROJECT_MODEL (model), &child_iter);
-		}
-
+		}			
+		node = gbf_project_model_get_node (GBF_PROJECT_MODEL (model), &iter);
+		
 		/* walk up the hierarchy searching for a node of the given type */
 		while ((node != NULL) && (anjuta_project_node_get_type (node) != type))
 		{
 			node = anjuta_project_node_parent (node);
 		}
 	}
-
+	
 	return node;
 }
 
 GbfTreeData *
-gbf_project_view_get_selected (GbfProjectView *view, GtkTreeIter* selected)
+gbf_project_view_get_first_selected (GbfProjectView *view, GtkTreeIter* selected)
 {
 	GtkTreeSelection *selection;
+	GbfTreeData *data = NULL;
 	GtkTreeModel *model;
-	GtkTreeIter iter;
-	GbfTreeData *data;
+	GList *list;
 
 	g_return_val_if_fail (view != NULL, FALSE);
 	g_return_val_if_fail (GBF_IS_PROJECT_VIEW (view), FALSE);
 	
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
-	if (gtk_tree_selection_get_selected (selection, &model, &iter))
+	list = gtk_tree_selection_get_selected_rows(selection, &model);
+	if (list != NULL)
 	{
-		if (GTK_IS_TREE_MODEL_FILTER (model))
+		GtkTreeIter iter;
+		
+		if (gtk_tree_model_get_iter (model, &iter, list->data))
 		{
-			GtkTreeIter child_iter;
-			
-			gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &child_iter, &iter);
-			iter = child_iter;
+			if (selected) *selected = iter;
+
+			gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
+				    GBF_PROJECT_MODEL_COLUMN_DATA, &data,
+			    	-1);
 		}
-		if (selected) *selected = iter;
-		
-	
-		gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
-			    GBF_PROJECT_MODEL_COLUMN_DATA, &data,
-			    -1);
+		g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
+		g_list_free (list);
 	}
 
 	return data;
 }
 
+static void
+on_each_selected_node (GtkTreeModel *model,
+			GtkTreePath *path,
+                        GtkTreeIter *iter,
+                        gpointer user_data)
+{
+	GList **selected = (GList **)user_data;
+	GbfTreeData *data;
+
+	/*if (GTK_IS_TREE_MODEL_FILTER (model))
+	{
+		GtkTreeIter child_iter;
+			
+		gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &child_iter, iter);
+		*iter = child_iter;
+	}*/
+	
+	gtk_tree_model_get (GTK_TREE_MODEL (model), iter,
+		    GBF_PROJECT_MODEL_COLUMN_DATA, &data,
+		    -1);
+
+	*selected = g_list_prepend (*selected, data);
+}
+
+GList *
+gbf_project_view_get_all_selected (GbfProjectView *view)
+{
+	GtkTreeSelection *selection;
+	GList *selected = NULL;
+
+	g_return_val_if_fail (view != NULL, FALSE);
+	g_return_val_if_fail (GBF_IS_PROJECT_VIEW (view), FALSE);
+	
+	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+	gtk_tree_selection_selected_foreach (selection, on_each_selected_node, &selected);
+
+	return g_list_reverse (selected);
+}
+
 /* Shorcuts functions
  *---------------------------------------------------------------------------*/
 
diff --git a/plugins/project-manager/gbf-project-view.h b/plugins/project-manager/gbf-project-view.h
index e107b72..855a860 100644
--- a/plugins/project-manager/gbf-project-view.h
+++ b/plugins/project-manager/gbf-project-view.h
@@ -63,8 +63,9 @@ GtkWidget                  *gbf_project_view_new               (void);
 
 AnjutaProjectNode          *gbf_project_view_find_selected     (GbfProjectView *view,
 							        AnjutaProjectNodeType type);
-GbfTreeData                *gbf_project_view_get_selected      (GbfProjectView *view,
+GbfTreeData                *gbf_project_view_get_first_selected(GbfProjectView *view,
                                                                 GtkTreeIter    *selected);
+GList                      *gbf_project_view_get_all_selected  (GbfProjectView *view);
 
 GList                      *gbf_project_view_get_shortcut_list (GbfProjectView *view);
 void                        gbf_project_view_set_shortcut_list (GbfProjectView *view,
diff --git a/plugins/project-manager/gbf-tree-data.c b/plugins/project-manager/gbf-tree-data.c
index 494d418..df2fb4c 100644
--- a/plugins/project-manager/gbf-tree-data.c
+++ b/plugins/project-manager/gbf-tree-data.c
@@ -133,7 +133,7 @@ gbf_tree_data_equal (GbfTreeData *data_a, GbfTreeData *data_b)
 	gboolean equal;
 
 	equal = data_a == data_b;
-	if ((data_a != NULL) && (data_b != NULL))
+	if (!equal && (data_a != NULL) && (data_b != NULL))
 	{
 		equal = data_a->type == data_b->type;
 		if (equal)
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index 9e35a57..3e1e26f 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -595,12 +595,21 @@ on_add_source (GtkAction *action, ProjectManagerPlugin *plugin)
 static void
 on_popup_properties (GtkAction *action, ProjectManagerPlugin *plugin)
 {
-	GbfTreeData *data;
+	GList *selected;
+	
+	selected = gbf_project_view_get_all_selected (GBF_PROJECT_VIEW (plugin->view));
 
-	data = gbf_project_view_get_selected (GBF_PROJECT_VIEW (plugin->view), NULL);
-	if (data)
+	if (selected != NULL)
 	{
-		project_manager_show_node_properties_dialog (plugin, data);
+		GList *item;
+		
+		for (item = g_list_first (selected); item != NULL; item = g_list_next (item))
+		{
+			GbfTreeData *data = (GbfTreeData *)(item->data);
+
+			project_manager_show_node_properties_dialog (plugin, data);
+		}
+		g_list_free (selected);
 	}
 }
 
@@ -611,7 +620,7 @@ on_popup_add_group (GtkAction *action, ProjectManagerPlugin *plugin)
 	AnjutaProjectGroup *new_group;
 	
 	update_operation_begin (plugin);
-	gbf_project_view_get_selected (GBF_PROJECT_VIEW (plugin->view), &selected_group);
+	gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_group);
 	
 	new_group = gbf_project_util_new_group (plugin->model,
 										   get_plugin_parent_window (plugin),
@@ -626,7 +635,7 @@ on_popup_add_target (GtkAction *action, ProjectManagerPlugin *plugin)
 	AnjutaProjectTarget *new_target;
 
 	update_operation_begin (plugin);
-	gbf_project_view_get_selected (GBF_PROJECT_VIEW (plugin->view), &selected_group);
+	gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_group);
 
 	new_target = gbf_project_util_new_target (plugin->model,
 											 get_plugin_parent_window (plugin),
@@ -642,7 +651,7 @@ on_popup_add_source (GtkAction *action, ProjectManagerPlugin *plugin)
 	AnjutaProjectSource *new_source;
 	
 	update_operation_begin (plugin);
-	gbf_project_view_get_selected (GBF_PROJECT_VIEW (plugin->view), &selected_target);
+	gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_target);
 
 	new_source = gbf_project_util_add_source (plugin->model,
 											 get_plugin_parent_window (plugin),
@@ -652,78 +661,149 @@ on_popup_add_source (GtkAction *action, ProjectManagerPlugin *plugin)
 }
 
 static gboolean
-confirm_removal (ProjectManagerPlugin *plugin, AnjutaProjectNode *node)
+confirm_removal (ProjectManagerPlugin *plugin, GList *selected)
 {
 	gboolean answer;
-	gchar *mesg;
-	gchar* question;
-	gchar* full_mesg;
-	gchar* name;
+	GString* mesg;
+	GList *item;
+	GbfTreeNodeType type;
+	gboolean group = FALSE;
+	gboolean source = FALSE;
 
+	g_return_val_if_fail (selected != NULL, FALSE);
 
-	name = anjuta_project_node_get_name (node);
-	switch (anjuta_project_node_get_type (node))
+	type = ((GbfTreeData *)selected->data)->type;
+	for (item = g_list_first (selected); item != NULL; item = g_list_next (item))
 	{
-		case ANJUTA_PROJECT_GROUP:
-			question = _("Are you sure you want to remove the following group from the project?\n\n");
-			mesg = _("Group: %s\n\nThe group will not be deleted from the file system.");
+		GbfTreeData *data = (GbfTreeData *)item->data;
+
+		if (data->type == GBF_TREE_NODE_GROUP) group = TRUE;
+		if (data->type == GBF_TREE_NODE_SOURCE) source = TRUE;
+		if (type != data->type) type = GBF_TREE_NODE_UNKNOWN;
+	}
+
+	switch (type)
+	{
+	case GBF_TREE_NODE_GROUP:
+		mesg = g_string_new (_("Are you sure you want to remove the following group from the project?\n\n"));
+		break;
+	case GBF_TREE_NODE_TARGET:
+		mesg = g_string_new (_("Are you sure you want to remove the following target from the project?\n\n"));
+		break;
+	case GBF_TREE_NODE_SOURCE:
+		mesg = g_string_new (_("Are you sure you want to remove the following source file from the project?\n\n"));
+		break;
+	case GBF_TREE_NODE_UNKNOWN:
+		mesg = g_string_new (_("Are you sure you want to remove the following elements from the project?\n\n"));
+		break;
+	case GBF_TREE_NODE_SHORTCUT:
+		/* Remove shortcut without confirmation */
+		return TRUE;
+	default:
+		g_warn_if_reached ();
+		return FALSE;
+	}
+
+	for (item = g_list_first (selected); item != NULL; item = g_list_next (item))
+	{
+		GbfTreeData *data = (GbfTreeData *)item->data;
+
+		switch (data->type)
+		{
+		case GBF_TREE_NODE_GROUP:
+			g_string_append_printf (mesg, _("Group: %s\n"), data->name);
 			break;
-		case ANJUTA_PROJECT_TARGET:
-			question = _("Are you sure you want to remove the following target from the project?\n\n");
-			mesg = _("Target: %s");
+		case GBF_TREE_NODE_TARGET:
+			g_string_append_printf (mesg, _("Target: %s\n"), data->name);
 			break;
-		case ANJUTA_PROJECT_SOURCE:
-			question = _("Are you sure you want to remove the following source file from the project?\n\n");
-			mesg = _("Source: %s\n\nThe source file will not be deleted from the file system.");
+		case GBF_TREE_NODE_SOURCE:
+			g_string_append_printf (mesg, _("Source: %s\n"), data->name);
 			break;
+		case GBF_TREE_NODE_SHORTCUT:
+			g_string_append_printf (mesg, _("Shortcut: %s\n"), data->name);
+			return TRUE;
 		default:
-			g_warning ("Unknown node");
+			g_warn_if_reached ();
 			return FALSE;
+		}
 	}
-	full_mesg = g_strconcat (question, mesg, NULL);
+
+	if (group || source)
+	{
+		g_string_append (mesg, _("\n"));
+		if (group)
+			g_string_append (mesg, _("The group will not be deleted from the file system."));
+		if (source)
+			g_string_append (mesg, _("The source file will not be deleted from the file system."));
+	}			    
+	
 	answer =
 		anjuta_util_dialog_boolean_question (get_plugin_parent_window (plugin),
-											 full_mesg, name);
-	g_free (name);
-	g_free (full_mesg);
+											 mesg->str, _("Confirm remove"));
+	g_string_free (mesg, TRUE);
+	
 	return answer;
 }
 
 static void
 on_popup_remove (GtkAction *action, ProjectManagerPlugin *plugin)
 {
-	AnjutaProjectNode *node;
+	GList *selected;
 	
-	node = gbf_project_view_find_selected (GBF_PROJECT_VIEW (plugin->view),
-										   ANJUTA_PROJECT_SOURCE);
-	if (node == NULL)
-	{
-		node = gbf_project_view_find_selected (GBF_PROJECT_VIEW (plugin->view),
-											   ANJUTA_PROJECT_TARGET);
-	}
-	if (node == NULL)
-	{
-		node = gbf_project_view_find_selected (GBF_PROJECT_VIEW (plugin->view),
-											   ANJUTA_PROJECT_GROUP);
-	}
-	if (node)
+	selected = gbf_project_view_get_all_selected (GBF_PROJECT_VIEW (plugin->view));
+
+	if (selected != NULL)
 	{
-		if (confirm_removal (plugin, node))
+		if (confirm_removal (plugin, selected))
 		{
 			GError *err = NULL;
-			update_operation_begin (plugin);
-			ianjuta_project_remove_node (plugin->project, node, &err);
-			update_operation_end (plugin, TRUE);
-			if (err)
+			GList *item;
+			gboolean update = FALSE;
+
+			for (item = g_list_first (selected); item != NULL; item = g_list_next (item))
 			{
-				gchar *name = anjuta_project_node_get_name (node);
-				anjuta_util_dialog_error (get_plugin_parent_window (plugin),
+				GbfTreeData *data = (GbfTreeData *)(item->data);
+				AnjutaProjectNode *node;
+				GtkTreeIter iter;
+
+				switch (data->type)
+				{
+				case GBF_TREE_NODE_GROUP:
+				case GBF_TREE_NODE_TARGET:
+				case GBF_TREE_NODE_SOURCE:
+					node = gbf_tree_data_get_node(data, plugin->project);
+					if (node != NULL)
+					{
+						if (!update) update_operation_begin (plugin);
+						ianjuta_project_remove_node (plugin->project, node, &err);
+						if (err)
+						{
+							gchar *name;
+							
+							update_operation_end (plugin, TRUE);
+							update = FALSE;
+							name = anjuta_project_node_get_name (node);
+							anjuta_util_dialog_error (get_plugin_parent_window (plugin),
 										  _("Failed to remove '%s':\n%s"),
 										  name, err->message);
-				g_free (name);
-				g_error_free (err);
+							g_free (name);
+							g_error_free (err);
+						}
+					}
+					break;
+				case GBF_TREE_NODE_SHORTCUT:
+					if (gbf_project_model_find_tree_data (plugin->model, &iter, data))
+					{
+						gbf_project_model_remove (plugin->model, &iter);
+					}
+					break;
+				default:
+					break;
+				}
 			}
+			if (update) update_operation_end (plugin, TRUE);
 		}
+		g_list_free (selected);
 	}
 }
 
@@ -1064,35 +1144,40 @@ on_treeview_button_press_event (GtkWidget             *widget,
 				 GdkEventButton        *event,
 				 ProjectManagerPlugin *plugin)
 {
-	static gboolean in_press = FALSE;
-	gboolean handled;
-	AnjutaUI *ui;
-	GtkWidget *popup;
-
-	if (in_press)
-		return FALSE;
-
-	if (event->button != 3)
-		return FALSE;
-
-	/* Re-emit the event to select the item at mouse position */
-	in_press = TRUE;
-	handled = gtk_widget_event (plugin->view, (GdkEvent *) event);
-	in_press = FALSE;
+	if (event->button == 3)
+	{
+		GtkTreePath *path;
+		GtkTreeSelection *selection;
+		AnjutaUI *ui;
+		GtkWidget *popup;
 
- 	if (!handled)
-    	return FALSE;
+        if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
+                        event->x,event->y, &path, NULL, NULL, NULL))
+			return FALSE;
 
-	ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
-	popup = gtk_ui_manager_get_widget (GTK_UI_MANAGER (ui), "/PopupProjectManager");
-	g_return_val_if_fail (GTK_IS_WIDGET (popup), FALSE);
+		selection = gtk_tree_view_get_selection(GTK_TREE_VIEW (widget));
+        if (!gtk_tree_selection_path_is_selected(selection, path))
+        {
+            gtk_tree_selection_unselect_all(selection);
+            gtk_tree_selection_select_path(selection, path);
+            gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget),
+                                path, NULL, FALSE);
+        }
+        gtk_tree_path_free (path);
+
+		ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
+		popup = gtk_ui_manager_get_widget (GTK_UI_MANAGER (ui), "/PopupProjectManager");
+		g_return_val_if_fail (GTK_IS_WIDGET (popup), FALSE);
+	
+		gtk_menu_popup (GTK_MENU (popup),
+						NULL, NULL, NULL, NULL,
+						((GdkEventButton *) event)->button,
+						((GdkEventButton *) event)->time);
+		
+        return TRUE;
+    }
 	
-	gtk_menu_popup (GTK_MENU (popup),
-					NULL, NULL, NULL, NULL,
-					((GdkEventButton *) event)->button,
-					((GdkEventButton *) event)->time);
-
-	return TRUE;
+	return FALSE;
 }
 
 /* 
@@ -1537,6 +1622,7 @@ project_manager_plugin_activate_plugin (AnjutaPlugin *plugin)
 							 GTK_TREE_MODEL (model));
 	
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+	gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
 	g_signal_connect (view, "uri-activated",
 					  G_CALLBACK (on_uri_activated), plugin);
 	g_signal_connect (view, "target-selected",



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