[anjuta] project-manager: Allow to select a new node in the properties dialog



commit b28f33816207ddad9038ba9fbe3234b35a01a61e
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Mon Jan 10 21:56:02 2011 +0100

    project-manager: Allow to select a new node in the properties dialog

 plugins/project-manager/dialogs.c      |  325 +++++++++++++++++++++++---------
 plugins/project-manager/dialogs.h      |    2 +-
 plugins/project-manager/plugin.c       |   27 ++--
 plugins/project-manager/pm_dialogs.ui  |  152 ++++++++++++---
 plugins/project-manager/project-view.c |   27 +++-
 plugins/project-manager/project-view.h |    2 +-
 plugins/project-manager/project.c      |   46 -----
 plugins/project-manager/project.h      |    2 -
 8 files changed, 399 insertions(+), 184 deletions(-)
---
diff --git a/plugins/project-manager/dialogs.c b/plugins/project-manager/dialogs.c
index eae4da9..eae7810 100644
--- a/plugins/project-manager/dialogs.c
+++ b/plugins/project-manager/dialogs.c
@@ -45,7 +45,13 @@
 typedef struct _PropertiesTable
 {
 	AnjutaPmProject *project;
+	GtkWidget *dialog;
 	GtkWidget *table;
+	GtkWidget *head;
+	GtkWidget *main;
+	GtkWidget *expand;
+	GtkWidget *extra;
+	GbfTreeData *data;
 	AnjutaProjectNode *node;
 	GList *properties;
 } PropertiesTable;
@@ -511,60 +517,100 @@ add_label (const gchar *display_name, const gchar *value, GtkWidget *table, gint
 	*position = *position + 1;
 }
 
-static PropertiesTable*
-create_properties_table (IAnjutaProject *project, AnjutaProjectNode *node)
+static gboolean
+is_project_node_but_shortcut (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
 {
-	GtkBuilder *bxml;
-	PropertiesTable *table;
-	GtkWidget *properties;
-	GtkWidget *main_table;
-	GtkWidget *extra_table;
-	GtkWidget *extra_expand;
-	GFile *file;
+	GbfTreeData *data;
 
+	gtk_tree_model_get (GTK_TREE_MODEL (model), iter,
+		    GBF_PROJECT_MODEL_COLUMN_DATA, &data,
+		    -1);
+
+	return (data != NULL) && (data->shortcut == NULL) && (gbf_tree_data_get_node (data) != NULL);
+}
+
+static void
+update_properties (PropertiesTable *table)
+{
+	GFile *file;
+	const gchar *title;
+	gint head_pos;
 	gint main_pos;
 	gint extra_pos;
-	gchar *path;
 	const GList *item;
 	AnjutaProjectNodeType type;
 	AnjutaProjectNodeInfo* node_info;
 	gboolean single;
+	GList *children;
+	GList *last;
 
-	bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
-	if (!bxml) return NULL;
-
-	table = g_new0 (PropertiesTable, 1);
-	table->node = node;
-	anjuta_util_builder_get_objects (bxml,
-									"properties", &properties,
-									"main_table", &main_table,
-									"extra_table", &extra_table,
-									"extra_expand", &extra_expand,
-									NULL);
-	table->table = properties;
-	g_object_ref (properties);
-
+	head_pos = 0;
 	main_pos = 0;
 	extra_pos = 0;
 
-	/* Always display node name */
-	file = anjuta_project_node_get_file (node);
+	/* Update dialog type */
+	switch (anjuta_project_node_get_node_type (table->node))
+	{
+	case ANJUTA_PROJECT_ROOT:
+		title = _("Project properties");
+		break;
+	case ANJUTA_PROJECT_GROUP:
+		title = _("Directory properties");
+		break;
+	case ANJUTA_PROJECT_TARGET:
+		title = _("Target properties");
+		break;
+	case ANJUTA_PROJECT_SOURCE:
+		title = _("Source properties");
+		break;
+	case ANJUTA_PROJECT_MODULE:
+		title = _("Module properties");
+		break;
+	case ANJUTA_PROJECT_PACKAGE:
+		title = _("Package properties");
+		break;
+	default:
+		title = _("Unknown properties");
+		break;
+	}
+	gtk_window_set_title (GTK_WINDOW (table->dialog), title);
+
+	/* Clear table */
+	children = gtk_container_get_children (GTK_CONTAINER (table->head));
+	/* Clear only the first 4 widgets */
+	while ((last = g_list_nth (children, 4)) != NULL) children = g_list_delete_link (children, last);
+	g_list_foreach (children, (GFunc)gtk_widget_destroy, NULL);
+	g_list_free (children);
+	children = gtk_container_get_children (GTK_CONTAINER (table->main));
+	g_list_foreach (children, (GFunc)gtk_widget_destroy, NULL);
+	g_list_free (children);
+	children = gtk_container_get_children (GTK_CONTAINER (table->extra));
+	g_list_foreach (children, (GFunc)gtk_widget_destroy, NULL);
+	g_list_free (children);
+	g_list_foreach (table->properties, (GFunc)pm_property_entry_free, NULL);
+	g_list_free (table->properties);
+	table->properties = NULL;
+	
+	/* Update node name */
+	file = anjuta_project_node_get_file (table->node);
 	if (file != NULL)
 	{
+		gchar *path;
+		
 		path = g_file_get_path (file);
-		add_label (_("Path:"), path, main_table, &main_pos);
+		add_label (_("Path:"), path, table->head, &head_pos);
 		g_free (path);
 	}
 	else
 	{
-		add_label (_("Name:"), anjuta_project_node_get_name (node), main_table, &main_pos);
+		add_label (_("Name:"), anjuta_project_node_get_name (table->node), table->head, &head_pos);
 	}
-
+	
 	/* Display node type only if several types are possible */
 	node_info = NULL;
 	single = TRUE;
-	type = anjuta_project_node_get_full_type (node);
-	for (item = ianjuta_project_get_node_info (project, NULL); item != NULL; item = g_list_next (item))
+	type = anjuta_project_node_get_full_type (table->node);
+	for (item = ianjuta_project_get_node_info (table->project->project, NULL); item != NULL; item = g_list_next (item))
 	{
 		AnjutaProjectNodeInfo* info = (AnjutaProjectNodeInfo *)item->data;
 
@@ -579,28 +625,28 @@ create_properties_table (IAnjutaProject *project, AnjutaProjectNode *node)
 	}
 	if (!single && (node_info != NULL))
 	{
-		add_label (_("Type:"), anjuta_project_node_info_name (node_info), main_table, &main_pos);
+		add_label (_("Type:"), anjuta_project_node_info_name (node_info), table->main, &main_pos);
 	}
 
 	/* Display other node properties */
 	single = FALSE;
 
-	for (item = anjuta_project_node_get_native_properties (node); item != NULL; item = g_list_next (item))
+	for (item = anjuta_project_node_get_native_properties (table->node); item != NULL; item = g_list_next (item))
 	{
 		AnjutaProjectProperty *valid_prop = (AnjutaProjectProperty *)item->data; 
 		AnjutaProjectProperty *prop; 
 		GtkWidget *entry;
 
-		prop = anjuta_project_node_get_property (node, valid_prop);
-		if (prop != NULL)
+		prop = anjuta_project_node_get_property (table->node, valid_prop);
+		if (prop->native != NULL)
 		{
 			/* This property has been set, display it in the main part */
-			entry = add_entry (project, node, prop, main_table, &main_pos);
+			entry = add_entry (table->project->project, table->node, prop, table->main, &main_pos);
 		}
 		else
 		{
 			/* This property has not been set, hide it by default */
-			entry = add_entry (project, node, valid_prop, extra_table, &extra_pos);
+			entry = add_entry (table->project->project, table->node, valid_prop, table->extra, &extra_pos);
 			single = TRUE;
 		}
 
@@ -611,14 +657,13 @@ create_properties_table (IAnjutaProject *project, AnjutaProjectNode *node)
 		}
 	}
 	table->properties = g_list_reverse (table->properties);
-	gtk_widget_show_all (properties);
+	gtk_widget_show_all (table->table);
 	
 	/* Hide expander if it is empty */
-	if (!single) gtk_widget_hide (extra_expand);
-	
-	g_object_unref (bxml);
-	
-	return table;
+	if (single)
+		gtk_widget_show (table->expand);
+	else
+		gtk_widget_hide (table->expand);
 }
 
 static void
@@ -686,68 +731,166 @@ on_properties_dialog_response (GtkWidget *dialog,
 	gtk_widget_destroy (dialog);
 }
 
-/* Properties dialog
- *---------------------------------------------------------------------------*/
+static void
+on_node_changed (GtkTreeView       *view,
+                 gpointer           user_data)     
+{
+	PropertiesTable *table = (PropertiesTable *)user_data;
+	GtkTreeIter iter;
+	GtkTreePath *path;
+	GtkTreeModel *model;
+
+	model = gtk_tree_view_get_model (view);
+	gtk_tree_view_get_cursor (view, &path, NULL);
+	
+	if (gtk_tree_model_get_iter (model, &iter, path))
+	{
+		GbfTreeData *data;
+		
+		gtk_tree_model_get (model, &iter, GBF_PROJECT_MODEL_COLUMN_DATA, &data, -1);
+
+		if (table->data->properties_dialog != NULL)
+		{
+			g_object_remove_weak_pointer (G_OBJECT (table->dialog), (gpointer *)&table->data->properties_dialog);
+			table->data->properties_dialog = NULL;
+		}
+		if (data->properties_dialog != NULL)
+		{
+			g_object_unref (data->properties_dialog);
+		}
+		table->data = data;
+		data->properties_dialog = table->dialog;
+		g_object_add_weak_pointer (G_OBJECT (table->dialog), (gpointer *)&table->data->properties_dialog);
 
-GtkWidget *
-pm_project_create_properties_dialog (AnjutaPmProject *project, GtkWindow *parent, AnjutaProjectNode *node)
+		table->node = gbf_tree_data_get_node (data);
+		update_properties (table);
+	}
+
+	if (path != NULL) gtk_tree_path_free (path);
+}
+
+static GtkWidget *
+pm_project_create_properties_dialog (AnjutaPmProject *project, GtkWindow *parent, GbfProjectView *view, GbfTreeData *data, GtkTreeIter *selected)
 {
-	const char *title;
 	PropertiesTable *table;
 	GtkWidget *dialog = NULL;
+	GtkBuilder *bxml;
+	GtkWidget *node_view;
+	
+	g_return_val_if_fail (data != NULL, NULL);
+	
+	bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
+	if (!bxml) return NULL;
 
-	g_return_val_if_fail (node != NULL, NULL);
+	table = g_new0 (PropertiesTable, 1);
+	table->data = data;
+	table->node = gbf_tree_data_get_node (data);
+	table->project = project;
+	anjuta_util_builder_get_objects (bxml,
+									"properties", &table->table,
+									"head_table", &table->head,
+	                                "nodes_view", &node_view,
+									"main_table", &table->main,
+									"extra_table", &table->extra,
+									"extra_expand", &table->expand,
+									NULL);
+	g_object_ref (table->table);
+	g_object_unref (bxml);
+
+	/* Add tree view */
+	setup_nodes_treeview (gbf_project_view_get_model (view),
+							node_view,
+							is_project_node_but_shortcut,
+							NULL,
+							selected);
+	gtk_widget_show (node_view);
+
+	dialog = gtk_dialog_new_with_buttons (NULL,
+						   parent,
+						   GTK_DIALOG_DESTROY_WITH_PARENT,
+						   GTK_STOCK_CANCEL,
+						   GTK_RESPONSE_CANCEL,
+						   GTK_STOCK_APPLY,
+						   GTK_RESPONSE_APPLY, NULL);
+	table->dialog = dialog;
+
+	update_properties (table);
+	
+	g_signal_connect (node_view, "cursor-changed",
+					G_CALLBACK (on_node_changed),
+					table);
 	
-	switch (anjuta_project_node_get_node_type (node))
+	g_signal_connect (dialog, "response",
+					G_CALLBACK (on_properties_dialog_response),
+					table);
+
+	gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG(dialog))),
+					table->table);
+	gtk_window_set_default_size (GTK_WINDOW (dialog), 450, -1);
+	gtk_widget_show (dialog);
+	
+	return dialog;
+}
+
+
+/* Properties dialog
+ *---------------------------------------------------------------------------*/
+
+/* Display properties dialog. These dialogs are not modal, so a pointer on each
+ * dialog is kept with in node data to be able to destroy them if the node is
+ * removed. It is useful to put the dialog at the top if the same target is
+ * selected while the corresponding dialog already exist instead of creating
+ * two times the same dialog.
+ * The project properties dialog is display if the node iterator is NULL. */
+
+gboolean
+anjuta_pm_project_show_properties_dialog (ProjectManagerPlugin *plugin, GtkTreeIter *selected)
+{
+	GtkWidget **dialog_ptr;
+	GtkTreeIter iter;
+	
+	if (selected == NULL)
 	{
-	case ANJUTA_PROJECT_ROOT:
-		title = _("Project properties");
-		break;
-	case ANJUTA_PROJECT_GROUP:
-		title = _("Directory properties");
-		break;
-	case ANJUTA_PROJECT_TARGET:
-		title = _("Target properties");
-		break;
-	case ANJUTA_PROJECT_SOURCE:
-		title = _("Source properties");
-		break;
-	case ANJUTA_PROJECT_MODULE:
-		title = _("Module properties");
-		break;
-	case ANJUTA_PROJECT_PACKAGE:
-		title = _("Package properties");
-		break;
-	default:
-		return NULL;
+		/* Display root properties by default */
+		if (gbf_project_view_get_project_root (plugin->view, &iter))
+		{
+			selected = &iter;
+		}
 	}
 
-	table = create_properties_table (project->project, node);
-
-	if (table != NULL)
+	if (selected)
 	{
-		table->project = project;
-		dialog = gtk_dialog_new_with_buttons (title,
-							   parent,
-							   GTK_DIALOG_DESTROY_WITH_PARENT,
-							   GTK_STOCK_CANCEL,
-							   GTK_RESPONSE_CANCEL,
-							   GTK_STOCK_APPLY,
-							   GTK_RESPONSE_APPLY, NULL);
-
-		g_signal_connect (dialog, "response",
-						G_CALLBACK (on_properties_dialog_response),
-						table);
-
-		gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG(dialog))),
-				table->table);
-		gtk_window_set_default_size (GTK_WINDOW (dialog), 450, -1);
-		gtk_widget_show (dialog);
+		GbfTreeData *data;
+		
+		gtk_tree_model_get (GTK_TREE_MODEL (gbf_project_view_get_model (plugin->view)), selected, GBF_PROJECT_MODEL_COLUMN_DATA, &data, -1);
+
+		dialog_ptr = &data->properties_dialog;
+	
+		if (*dialog_ptr != NULL)
+		{
+			/* Show already existing dialog */
+			gtk_window_present (GTK_WINDOW (*dialog_ptr));
+		}
+		else
+		{
+			*dialog_ptr = pm_project_create_properties_dialog (
+				plugin->project,
+				GTK_WINDOW (plugin->project->plugin->shell),
+			    plugin->view,
+			    data,                                               
+				selected);
+			if (*dialog_ptr != NULL)
+			{
+				g_object_add_weak_pointer (G_OBJECT (*dialog_ptr), (gpointer *)dialog_ptr);
+			}
+		}
 	}
 
-	return dialog;
+	return selected != NULL;
 }
 
+
+
 /* Group dialog
  *---------------------------------------------------------------------------*/
 
diff --git a/plugins/project-manager/dialogs.h b/plugins/project-manager/dialogs.h
index 13161a6..c65cd3e 100644
--- a/plugins/project-manager/dialogs.h
+++ b/plugins/project-manager/dialogs.h
@@ -35,8 +35,8 @@ GList* anjuta_pm_project_new_multiple_source (ProjectManagerPlugin *plugin, GtkW
 GList* anjuta_pm_project_new_module (ProjectManagerPlugin *plugin, GtkWindow *parent, GtkTreeIter *default_target, const gchar *default_module);
 GList* anjuta_pm_project_new_package (ProjectManagerPlugin *plugin, GtkWindow *parent, GtkTreeIter *default_module, GList *packages_to_add);
 
+gboolean anjuta_pm_project_show_properties_dialog (ProjectManagerPlugin *plugin, GtkTreeIter *selected);
 
-GtkWidget *pm_project_create_properties_dialog (AnjutaPmProject *project, GtkWindow *parent, AnjutaProjectNode *node);
 
 G_END_DECLS
 
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index 20a94b5..24b836c 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -424,7 +424,12 @@ on_refresh (GtkAction *action, ProjectManagerPlugin *plugin)
 static void
 on_properties (GtkAction *action, ProjectManagerPlugin *plugin)
 {
-	anjuta_pm_project_show_properties_dialog (plugin->project, NULL);
+	GtkTreeIter selected;
+	gboolean found;
+
+	found = gbf_project_view_get_first_selected (plugin->view, &selected);
+
+	anjuta_pm_project_show_properties_dialog (plugin, found ? &selected : NULL);
 }
 
 static void
@@ -528,22 +533,14 @@ on_add_source (GtkAction *action, ProjectManagerPlugin *plugin)
 static void
 on_popup_properties (GtkAction *action, ProjectManagerPlugin *plugin)
 {
-	GList *selected;
-	
-	selected = gbf_project_view_get_all_selected (plugin->view);
+	GtkTreeIter selected;
+	gboolean found;
 
-	if (selected != NULL)
-	{
-		GList *item;
-		
-		for (item = g_list_first (selected); item != NULL; item = g_list_next (item))
-		{
-			GbfTreeData *data = (GbfTreeData *)(item->data);
+	/* FIXME: Perhaps it would be better to open a dialog for each
+	 * selected node ? */
+	found = gbf_project_view_get_first_selected (plugin->view, &selected);
 
-			anjuta_pm_project_show_properties_dialog (plugin->project, data);
-		}
-		g_list_free (selected);
-	}
+	anjuta_pm_project_show_properties_dialog (plugin, found ? &selected : NULL);
 }
 
 static void
diff --git a/plugins/project-manager/pm_dialogs.ui b/plugins/project-manager/pm_dialogs.ui
index 8cc9d0f..182439a 100644
--- a/plugins/project-manager/pm_dialogs.ui
+++ b/plugins/project-manager/pm_dialogs.ui
@@ -842,13 +842,15 @@
   <object class="GtkVBox" id="properties">
     <property name="visible">True</property>
     <property name="orientation">vertical</property>
+    <property name="border_width">6</property>
+    <property name="spacing">12</property>
     <child>
-      <object class="GtkTable" id="main_table">
+      <object class="GtkTable" id="head_table">
         <property name="visible">True</property>
         <property name="n_rows">3</property>
         <property name="n_columns">2</property>
         <property name="column_spacing">12</property>
-        <property name="row_spacing">6</property>
+        <property name="row_spacing">0</property>
         <child>
           <placeholder/>
         </child>
@@ -875,42 +877,32 @@
       </packing>
     </child>
     <child>
-      <object class="GtkExpander" id="extra_expand">
+      <object class="GtkExpander" id="expand2">
         <property name="visible">True</property>
         <property name="can_focus">True</property>
         <property name="spacing">6</property>
         <child>
-          <object class="GtkTable" id="extra_table">
+          <object class="GtkScrolledWindow" id="scrolledwindow4">
             <property name="visible">True</property>
-            <property name="n_rows">3</property>
-            <property name="n_columns">2</property>
-            <property name="column_spacing">12</property>
-            <property name="row_spacing">6</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">automatic</property>
+            <property name="vscrollbar_policy">automatic</property>
+            <property name="shadow_type">in</property>
             <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
+              <object class="GbfProjectView" id="nodes_view">
+                <property name="visible">True</property>
+              </object>
             </child>
           </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
         </child>
         <child type="label">
-          <object class="GtkLabel" id="label13">
+          <object class="GtkLabel" id="label14">
             <property name="visible">True</property>
             <property name="yalign">1</property>
-            <property name="label" translatable="yes">More options:</property>
+            <property name="label" translatable="yes">Browse other nodes</property>
           </object>
         </child>
       </object>
@@ -921,7 +913,113 @@
       </packing>
     </child>
     <child>
-      <placeholder/>
+      <object class="GtkScrolledWindow" id="scrolledwindow3">
+        <property name="width_request">600</property>
+        <property name="height_request">144</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="hscrollbar_policy">automatic</property>
+        <property name="vscrollbar_policy">automatic</property>
+        <child>
+          <object class="GtkViewport" id="viewport1">
+            <property name="visible">True</property>
+            <property name="resize_mode">queue</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkVBox" id="vbox">
+                <property name="visible">True</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkTable" id="main_table">
+                    <property name="visible">True</property>
+                    <property name="n_rows">3</property>
+                    <property name="n_columns">2</property>
+                    <property name="column_spacing">12</property>
+                    <property name="row_spacing">0</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkExpander" id="extra_expand">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkTable" id="extra_table">
+                        <property name="visible">True</property>
+                        <property name="n_rows">3</property>
+                        <property name="n_columns">2</property>
+                        <property name="column_spacing">12</property>
+                        <property name="row_spacing">6</property>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label13">
+                        <property name="visible">True</property>
+                        <property name="yalign">1</property>
+                        <property name="label" translatable="yes">More options:</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">True</property>
+        <property name="fill">True</property>
+        <property name="position">2</property>
+      </packing>
     </child>
   </object>
 </interface>
diff --git a/plugins/project-manager/project-view.c b/plugins/project-manager/project-view.c
index 4673a78..267879d 100644
--- a/plugins/project-manager/project-view.c
+++ b/plugins/project-manager/project-view.c
@@ -496,7 +496,7 @@ set_text (GtkTreeViewColumn *tree_column,
 	  gpointer           user_data)
 {
 	GbfTreeData *data;
-  
+
 	gtk_tree_model_get (model, iter, GBF_PROJECT_MODEL_COLUMN_DATA, &data, -1);
 	/* data can be NULL just after gtk_tree_store_insert before
 	calling gtk_tree_store_set */ 
@@ -1427,3 +1427,28 @@ gbf_project_view_get_model (GbfProjectView *view)
 {
 	return view->model;
 }
+
+gboolean
+gbf_project_view_get_project_root (GbfProjectView *view, GtkTreeIter *iter)
+{
+	GtkTreeModel *model;
+	GtkTreeModel *view_model;
+	GtkTreePath *path;
+	gboolean ok = FALSE;
+
+	model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+	view_model = model;
+	if (GTK_IS_TREE_MODEL_FILTER (model))
+	{
+		model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (view_model));
+	}
+		
+	path = gbf_project_model_get_project_root (GBF_PROJECT_MODEL (model));
+	if (path)
+	{
+		ok = gtk_tree_model_get_iter (model, iter, path);
+		gtk_tree_path_free (path);
+	}
+
+	return ok;
+}
diff --git a/plugins/project-manager/project-view.h b/plugins/project-manager/project-view.h
index b17af22..39c8a61 100644
--- a/plugins/project-manager/project-view.h
+++ b/plugins/project-manager/project-view.h
@@ -104,7 +104,7 @@ gboolean gbf_project_view_find_file (GbfProjectView *view, GtkTreeIter* iter, GF
 
 GbfProjectModel *gbf_project_view_get_model (GbfProjectView *view);
 
-
+gboolean gbf_project_view_get_project_root (GbfProjectView *view, GtkTreeIter *iter);
 
 G_END_DECLS
 
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index be83877..ca0296a 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -424,52 +424,6 @@ anjuta_pm_project_get_module (AnjutaPmProject *project, const gchar *name)
 	return module;
 }
 
-/* Display properties dialog. These dialogs are not modal, so a pointer on each
- * dialog is kept with in node data to be able to destroy them if the node is
- * removed. It is useful to put the dialog at the top if the same target is
- * selected while the corresponding dialog already exist instead of creating
- * two times the same dialog.
- * The project properties dialog is display if the node iterator is NULL. */
-
-gboolean
-anjuta_pm_project_show_properties_dialog (AnjutaPmProject *project, GbfTreeData *data)
-{
-	GtkWidget **dialog_ptr;
-	AnjutaProjectNode *node;
-	
-	if (data == NULL)
-	{
-		/* Show project properties dialog */
-		dialog_ptr = &project->properties_dialog;
-		node = project->root;
-	}
-	else
-	{
-		/* Show node properties dialog */
-		dialog_ptr = &data->properties_dialog;
-		node = gbf_tree_data_get_node (data);
-	}
-	
-	if (*dialog_ptr != NULL)
-	{
-		/* Show already existing dialog */
-		gtk_window_present (GTK_WINDOW (*dialog_ptr));
-	}
-	else
-	{
-		*dialog_ptr = pm_project_create_properties_dialog (
-			project,
-			GTK_WINDOW (project->plugin->shell),
-			node);
-		if (*dialog_ptr != NULL)
-		{
-			g_object_add_weak_pointer (G_OBJECT (*dialog_ptr), (gpointer *)dialog_ptr);
-		}
-	}
-
-	return TRUE;
-}
-
 /* Implement GObject
  *---------------------------------------------------------------------------*/
 
diff --git a/plugins/project-manager/project.h b/plugins/project-manager/project.h
index 61c7eea..4238c63 100644
--- a/plugins/project-manager/project.h
+++ b/plugins/project-manager/project.h
@@ -99,8 +99,6 @@ AnjutaProjectNode *anjuta_pm_project_get_node_from_file (AnjutaPmProject *projec
 AnjutaProjectNode *anjuta_pm_project_get_node_from_iter (AnjutaPmProject *project, GtkTreeIter *iter);
 AnjutaProjectNode *anjuta_pm_project_get_module (AnjutaPmProject *project, const gchar *name);
 
-gboolean anjuta_pm_project_show_properties_dialog (AnjutaPmProject *project, GbfTreeData *data);
-
 G_END_DECLS
 
 #endif /* _PROJECT_H_ */



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