[anjuta] project-manager: Add a function to get the current project object
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] project-manager: Add a function to get the current project object
- Date: Sun, 19 Dec 2010 21:48:05 +0000 (UTC)
commit aaf8fa1b60ce895c36056a96958e7524f3008f9f
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sat Dec 18 22:00:12 2010 +0100
project-manager: Add a function to get the current project object
libanjuta/interfaces/libanjuta.idl | 19 +++++++++++++++++++
plugins/project-manager/plugin.c | 11 +++++++++++
plugins/project-manager/project.c | 26 ++++++++++++++++++--------
3 files changed, 48 insertions(+), 8 deletions(-)
---
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index 8a50327..ebfe08f 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -3341,6 +3341,14 @@ interface IAnjutaProjectManager
#define PROJECT_ROOT_URI "project_root_uri"
/**
+ * IANJUTA_PROJECT_MANAGER_CURRENT_PROJECT
+ *
+ * Anjuta shell value set by project manager to the current project object
+ * which implement #IAnjutaProject interface.
+ */
+ #define CURRENT_PROJECT "project_manager_current_project"
+
+ /**
* IANJUTA_PROJECT_MANAGER_CURRENT_URI
*
* Anjuta shell value set by project manager to the current uri.
@@ -3604,6 +3612,17 @@ interface IAnjutaProjectManager
* opened currently or no package is required.
*/
List<gchar*> get_packages();
+
+ /**
+ * ianjuta_project_manager_get_current_project:
+ * @obj: Self
+ * @err: Error propagation and reporting.
+ *
+ * Gets the current project.
+ *
+ * Return value: the currently active project. NULL if none is there.
+ */
+ IAnjutaProject* get_current_project ();
}
/**
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index e4663bd..a8a758d 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -2176,6 +2176,16 @@ iproject_manager_get_packages (IAnjutaProjectManager *project_manager, GError **
return anjuta_pm_project_get_packages (plugin->project);
}
+static IAnjutaProject*
+iproject_manager_get_current_project (IAnjutaProjectManager *project_manager, GError **err)
+{
+ ProjectManagerPlugin *plugin;
+
+ plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
+
+ return anjuta_pm_project_get_project (plugin->project);
+}
+
static void
iproject_manager_iface_init(IAnjutaProjectManagerIface *iface)
{
@@ -2193,6 +2203,7 @@ iproject_manager_iface_init(IAnjutaProjectManagerIface *iface)
iface->add_group = iproject_manager_add_group;
iface->is_open = iproject_manager_is_open;
iface->get_packages = iproject_manager_get_packages;
+ iface->get_current_project = iproject_manager_get_current_project;
}
static void
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index 60c5b53..09c1758 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -27,6 +27,7 @@
#include "project-marshal.h"
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/interfaces/ianjuta-project-backend.h>
+#include <libanjuta/interfaces/ianjuta-project-manager.h>
#include "project-model.h"
#include "project-view.h"
#include "dialogs.h"
@@ -122,15 +123,11 @@ anjuta_pm_project_load (AnjutaPmProject *project, GFile *file, GError **error)
GList *desc;
IAnjutaProjectBackend *backend;
gint found = 0;
+ GValue value = {0, };
g_return_val_if_fail (file != NULL, FALSE);
-
- if (project->project != NULL)
- {
- g_object_unref (project->project);
- project->project = NULL;
- project->loaded = FALSE;
- }
+
+ anjuta_pm_project_unload (project, NULL);
DEBUG_PRINT ("loading gbf backendâ?¦\n");
plugin_manager = anjuta_shell_get_plugin_manager (project->plugin->shell, NULL);
@@ -207,6 +204,14 @@ anjuta_pm_project_load (AnjutaPmProject *project, GFile *file, GError **error)
project);
project->root = ianjuta_project_get_root (project->project, NULL);
+
+ 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);
+
ianjuta_project_load_node (project->project, project->root, NULL);
return TRUE;
@@ -215,7 +220,12 @@ anjuta_pm_project_load (AnjutaPmProject *project, GFile *file, GError **error)
gboolean
anjuta_pm_project_unload (AnjutaPmProject *project, GError **error)
{
- g_object_unref (project->project);
+ /* Remove value from Anjuta shell */
+ anjuta_shell_remove_value (project->plugin->shell,
+ IANJUTA_PROJECT_MANAGER_CURRENT_PROJECT,
+ NULL);
+
+ if (project->project) g_object_unref (project->project);
project->project = NULL;
project->loaded = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]