[anjuta] project-manager: Display current project backend



commit c3d4bcd95764c30c1853b545159cd7195498977b
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Thu Jan 3 22:31:53 2013 +0100

    project-manager: Display current project backend

 libanjuta/anjuta-plugin-manager.c |   30 ++++++++++++++++++++++++++++++
 libanjuta/anjuta-plugin-manager.h |    5 ++++-
 plugins/project-manager/dialogs.c |    7 +++++++
 plugins/project-manager/project.c |   11 ++++++++++-
 plugins/project-manager/project.h |    2 ++
 5 files changed, 53 insertions(+), 2 deletions(-)
---
diff --git a/libanjuta/anjuta-plugin-manager.c b/libanjuta/anjuta-plugin-manager.c
index b2ce92c..2568672 100644
--- a/libanjuta/anjuta-plugin-manager.c
+++ b/libanjuta/anjuta-plugin-manager.c
@@ -2186,6 +2186,36 @@ anjuta_plugin_manager_select_and_activate (AnjutaPluginManager *plugin_manager,
 	return NULL;
 }
 
+/*
+ * anjuta_plugin_manager_get_plugin_description:
+ * @plugin_manager: #AnjutaPluginManager object
+ * @plugin: #AnjutaPlugin object
+ *
+ * Get the description corresponding to the plugin or %NULL if the plugin is not
+ * activated.
+ *
+ * Returns: A #AnjutaPluginDescription or %NULL.
+ */
+AnjutaPluginDescription*
+anjuta_plugin_manager_get_plugin_description (AnjutaPluginManager *plugin_manager,
+											  GObject *plugin)
+{
+	GHashTableIter iter;
+	gpointer key, value;
+
+	g_hash_table_iter_init (&iter, plugin_manager->priv->activated_plugins);
+	while (g_hash_table_iter_next (&iter, &key, &value))
+	{
+		if (G_OBJECT(value) == plugin)
+		{
+			return anjuta_plugin_handle_get_description (ANJUTA_PLUGIN_HANDLE (key));
+		}
+	}
+
+	return NULL;
+}
+
+
 /* Plugin manager */
 
 static void
diff --git a/libanjuta/anjuta-plugin-manager.h b/libanjuta/anjuta-plugin-manager.h
index 422da50..0baa5c2 100644
--- a/libanjuta/anjuta-plugin-manager.h
+++ b/libanjuta/anjuta-plugin-manager.h
@@ -111,11 +111,14 @@ AnjutaPluginDescription* anjuta_plugin_manager_select (AnjutaPluginManager *plug
 													   gchar *title, gchar *description,
 													   GList *plugin_descriptions);
 
-
 GObject*  anjuta_plugin_manager_select_and_activate (AnjutaPluginManager *plugin_manager,
 													   gchar *title, gchar *description,
 			   GList *plugin_descriptions);
 
+AnjutaPluginDescription* anjuta_plugin_manager_get_plugin_description (AnjutaPluginManager *plugin_manager,
+																	   GObject *plugin);
+
+
 void anjuta_plugin_manager_activate_plugins (AnjutaPluginManager *plugin_manager,
 											 GList *plugin_descs);
 
diff --git a/plugins/project-manager/dialogs.c b/plugins/project-manager/dialogs.c
index 50eafe4..cd0bd7c 100644
--- a/plugins/project-manager/dialogs.c
+++ b/plugins/project-manager/dialogs.c
@@ -649,6 +649,13 @@ update_properties (PropertiesTable *table)
 		add_label (_("Name:"), anjuta_project_node_get_name (table->node), table->head, &head_pos);
 	}
 
+	/* Display project backend if the root node is selected */
+	if ((anjuta_project_node_get_node_type (table->node) == ANJUTA_PROJECT_ROOT) ||
+		((anjuta_project_node_get_full_type (table->node) & ANJUTA_PROJECT_ID_MASK) == ANJUTA_PROJECT_ROOT_GROUP))
+	{
+		add_label (_("Backend:"), anjuta_pm_project_get_backend_name (table->project), table->main, &main_pos);
+	}
+
 	/* Display node type only if several types are possible */
 	node_info = NULL;
 	single = TRUE;
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index 147ba88..feee40b 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -126,6 +126,7 @@ anjuta_pm_project_load (AnjutaPmProject *project, GFile *file, GError **error)
 	AnjutaPluginManager *plugin_manager;
 	GList *desc;
 	IAnjutaProjectBackend *backend;
+	AnjutaPluginDescription *backend_desc;
 	gint found = 0;
 	GValue value = {0, };
 
@@ -145,7 +146,6 @@ anjuta_pm_project_load (AnjutaPmProject *project, GFile *file, GError **error)
 											 NULL);
 		backend = NULL;
 		for (desc = g_list_first (descs); desc != NULL; desc = g_list_next (desc)) {
-			AnjutaPluginDescription *backend_desc;
 			gchar *location = NULL;
 			IAnjutaProjectBackend *plugin;
 			gint backend_val;
@@ -191,6 +191,8 @@ anjuta_pm_project_load (AnjutaPmProject *project, GFile *file, GError **error)
 
 		return FALSE;
 	}
+	backend_desc = anjuta_plugin_manager_get_plugin_description (plugin_manager, G_OBJECT(backend));
+	if (backend_desc) anjuta_plugin_description_get_locale_string (backend_desc, "Anjuta Plugin", "Name", &project->backend);
 
 	g_signal_connect (G_OBJECT (project->project),
 						"file-changed",
@@ -236,6 +238,7 @@ anjuta_pm_project_unload (AnjutaPmProject *project, GError **error)
 
 	if (project->project) g_object_unref (project->project);
 	project->project = NULL;
+	project->backend = NULL;
 	project->root = NULL;
 	project->loaded = FALSE;
 	project->node_capabilities = 0;
@@ -399,6 +402,12 @@ anjuta_pm_project_is_open (AnjutaPmProject *project)
 	return project->project != NULL;
 }
 
+const gchar *
+anjuta_pm_project_get_backend_name (AnjutaPmProject *project)
+{
+	return project->backend;
+}
+
 IAnjutaProject *
 anjuta_pm_project_get_project (AnjutaPmProject *project)
 {
diff --git a/plugins/project-manager/project.h b/plugins/project-manager/project.h
index 60c5073..8c9a94f 100644
--- a/plugins/project-manager/project.h
+++ b/plugins/project-manager/project.h
@@ -57,6 +57,7 @@ struct _AnjutaPmProject
 	AnjutaPlugin *plugin;
 
 	IAnjutaProject *project;
+	const gchar *backend;
 
 	AnjutaProjectNode *root;
 
@@ -93,6 +94,7 @@ gboolean anjuta_pm_project_remove_data (AnjutaPmProject *project, GbfTreeData *d
 
 
 gboolean anjuta_pm_project_is_open (AnjutaPmProject *project);
+const gchar *anjuta_pm_project_get_backend_name (AnjutaPmProject *project);
 
 IAnjutaProject *anjuta_pm_project_get_project (AnjutaPmProject *project);
 GbfProjectModel *anjuta_pm_project_get_model (AnjutaPmProject *project);



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