[anjuta] project-manager: Fix some critical warnings and always keep project properties menu item



commit f7cbd124694048da9e8f235affef119582dc891d
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sat Feb 5 16:51:08 2011 +0100

    project-manager: Fix some critical warnings and always keep project properties menu item

 libanjuta/anjuta-token-stream.c        |    2 +-
 plugins/project-manager/plugin.c       |   28 ++++++++++++----------------
 plugins/project-manager/project-view.c |    2 +-
 plugins/project-manager/project.c      |    9 +++++++--
 4 files changed, 21 insertions(+), 20 deletions(-)
---
diff --git a/libanjuta/anjuta-token-stream.c b/libanjuta/anjuta-token-stream.c
index a1abc9f..63b551c 100644
--- a/libanjuta/anjuta-token-stream.c
+++ b/libanjuta/anjuta-token-stream.c
@@ -315,7 +315,7 @@ anjuta_token_stream_push (AnjutaTokenStream *parent, AnjutaToken *root, AnjutaTo
 	child->root = root == NULL ? anjuta_token_new_static (ANJUTA_TOKEN_FILE, NULL) : root;
 	if (filename == NULL)
 	{
-		child->current_directory = parent == NULL ? NULL : g_object_ref (parent->current_directory);
+		child->current_directory = parent == NULL ? NULL : (parent->current_directory == NULL ? NULL : g_object_ref (parent->current_directory));
 	}
 	else
 	{
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index b24d8d8..6f44a4c 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -427,7 +427,7 @@ on_properties (GtkAction *action, ProjectManagerPlugin *plugin)
 	GtkTreeIter selected;
 	gboolean found;
 
-	found = gbf_project_view_get_first_selected (plugin->view, &selected);
+	found = gbf_project_view_get_first_selected (plugin->view, &selected) != NULL;
 
 	anjuta_pm_project_show_properties_dialog (plugin, found ? &selected : NULL);
 }
@@ -538,7 +538,7 @@ on_popup_properties (GtkAction *action, ProjectManagerPlugin *plugin)
 
 	/* FIXME: Perhaps it would be better to open a dialog for each
 	 * selected node ? */
-	found = gbf_project_view_get_first_selected (plugin->view, &selected);
+	found = gbf_project_view_get_first_selected (plugin->view, &selected) != NULL;
 
 	anjuta_pm_project_show_properties_dialog (plugin, found ? &selected : NULL);
 }
@@ -1015,11 +1015,13 @@ update_ui (ProjectManagerPlugin *plugin)
 			main_caps |= 0x20;
 			popup_caps |= 0x10;
 		}
-		/* Keep properties and refresh if a project is opened */
-		main_caps |= 0x0C0;
-		/* Keep properties and remove if a project is opened */
-		popup_caps |= 0x0C0;
+		/* Keep remove if a project is opened */
+		popup_caps |= 0x080;
 	}
+	/* Keep properties and refresh if a project is opened */
+	main_caps |= 0x0C0;
+	/* Keep properties and remove if a project is opened */
+	popup_caps |= 0x040;
 
 	ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
 
@@ -1346,7 +1348,7 @@ project_manager_load_gbf (ProjectManagerPlugin *pm_plugin)
 	gchar *basename;
 	const gchar *root_uri;
 	GError *error = NULL;
-	
+
 	root_uri = pm_plugin->project_root_uri;
 	
 	dirname = anjuta_util_get_local_path_from_uri (root_uri);
@@ -1361,6 +1363,8 @@ project_manager_load_gbf (ProjectManagerPlugin *pm_plugin)
 	anjuta_status_busy_push (status);
 	pm_plugin->busy = TRUE;
 
+	anjuta_pm_project_unload (pm_plugin->project, NULL);
+	
 	DEBUG_PRINT ("loading project %s\n\n", dirname);
 	anjuta_pm_project_load (pm_plugin->project, dirfile, &error);
 	update_ui (pm_plugin);
@@ -1447,26 +1451,18 @@ static void
 on_profile_scoped (AnjutaProfileManager *profile_manager,
 				   AnjutaProfile *profile, ProjectManagerPlugin *plugin)
 {
-	GValue *value;
 	gchar *session_dir;
 	DEBUG_PRINT ("Profile scoped: %s", anjuta_profile_get_name (profile));
 	if (strcmp (anjuta_profile_get_name (profile), PROJECT_PROFILE_NAME) != 0)
 		return;
 	
 	DEBUG_PRINT ("%s", "Project profile loaded; Restoring project session");
-	
+
 	/* Load gbf project */
 	project_manager_load_gbf (plugin);
 	
-	/* Export project */
-	value = g_new0 (GValue, 1);
-	g_value_init (value, G_TYPE_STRING);
-	g_value_set_string (value, plugin->project_root_uri);
 	
 	update_title (plugin, plugin->project_root_uri);
-	anjuta_shell_add_value (ANJUTA_PLUGIN(plugin)->shell,
-							IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI,
-							value, NULL);
 	
 	/* If profile scoped to "project", restore project session */
 	session_dir = get_session_dir (plugin);
diff --git a/plugins/project-manager/project-view.c b/plugins/project-manager/project-view.c
index 202dd51..932c809 100644
--- a/plugins/project-manager/project-view.c
+++ b/plugins/project-manager/project-view.c
@@ -1458,7 +1458,7 @@ on_node_loaded (AnjutaPmProject *sender, AnjutaProjectNode *node, gboolean compl
 				path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->model), &iter);
 				filter = GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
 				child_path = gtk_tree_model_filter_convert_child_path_to_path (filter, path);
-				gtk_tree_view_expand_row (GTK_TREE_VIEW (view), child_path, FALSE);
+				if (child_path != NULL) gtk_tree_view_expand_row (GTK_TREE_VIEW (view), child_path, FALSE);
 				gtk_tree_path_free (child_path);
 				gtk_tree_path_free (path);
 			}
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index 6908f28..b3f56a0 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -131,8 +131,6 @@ anjuta_pm_project_load (AnjutaPmProject *project, GFile *file, GError **error)
 	
 	g_return_val_if_fail (file != NULL, FALSE);
 
-	anjuta_pm_project_unload (project, NULL);
-	
 	DEBUG_PRINT ("loading gbf backendâ?¦\n");
 	plugin_manager = anjuta_shell_get_plugin_manager (project->plugin->shell, NULL);
 
@@ -209,12 +207,19 @@ anjuta_pm_project_load (AnjutaPmProject *project, GFile *file, GError **error)
 	
 	project->root = ianjuta_project_get_root (project->project, NULL);
 
+	/* Export project root shell variable */
 	g_value_init (&value, G_TYPE_OBJECT);
 	g_value_set_object (&value, project->project);
 	anjuta_shell_add_value (project->plugin->shell,
 	                        IANJUTA_PROJECT_MANAGER_CURRENT_PROJECT,
 	                        &value, NULL);
 	g_value_unset(&value);
+	g_value_init (&value, G_TYPE_STRING);
+	g_value_set_string (&value, ANJUTA_PLUGIN_PROJECT_MANAGER (project->plugin)->project_root_uri);
+	anjuta_shell_add_value (project->plugin->shell,
+							IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI,
+							&value, NULL);
+	g_value_unset(&value);
 	
 	ianjuta_project_load_node (project->project, project->root, NULL);
 	



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