[anjuta/newproject] Move interface with ianjuta_project interface in a single object
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] Move interface with ianjuta_project interface in a single object
- Date: Sun, 28 Mar 2010 20:58:09 +0000 (UTC)
commit 59b43e2ffee8bf1c46a36980e761df15251bd6f4
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Mar 28 19:03:46 2010 +0200
Move interface with ianjuta_project interface in a single object
plugins/project-manager/Makefile.am | 4 +-
plugins/project-manager/gbf-project-model.c | 21 +-
plugins/project-manager/gbf-project-model.h | 6 +-
plugins/project-manager/gbf-project-util.c | 20 +-
plugins/project-manager/gbf-tree-data.c | 4 +-
plugins/project-manager/gbf-tree-data.h | 40 ++--
plugins/project-manager/plugin.c | 181 ++++------------
plugins/project-manager/plugin.h | 4 +-
plugins/project-manager/project.c | 303 +++++++++++++++++++++++++++
plugins/project-manager/project.h | 57 +++++
10 files changed, 456 insertions(+), 184 deletions(-)
---
diff --git a/plugins/project-manager/Makefile.am b/plugins/project-manager/Makefile.am
index cdff830..ffbc597 100644
--- a/plugins/project-manager/Makefile.am
+++ b/plugins/project-manager/Makefile.am
@@ -47,7 +47,9 @@ libanjuta_project_manager_la_SOURCES = \
gbf-project-util.h \
gbf-project-util.c \
pkg-config.c \
- pkg-config.h
+ pkg-config.h \
+ project.h \
+ project.c
libanjuta_project_manager_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/project-manager/gbf-project-model.c b/plugins/project-manager/gbf-project-model.c
index 8b68585..b3327af 100644
--- a/plugins/project-manager/gbf-project-model.c
+++ b/plugins/project-manager/gbf-project-model.c
@@ -31,12 +31,14 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
+
+#include "project.h"
#include "gbf-project-util.h"
#include "gbf-project-model.h"
struct _GbfProjectModelPrivate {
- IAnjutaProject *proj;
+ ProjectManagerProject *proj;
gulong project_updated_handler;
GtkTreeRowReference *root_row;
@@ -58,7 +60,7 @@ static void gbf_project_model_drag_source_init (GtkTreeDragSourceIface *if
static void gbf_project_model_drag_dest_init (GtkTreeDragDestIface *iface);
static void load_project (GbfProjectModel *model,
- IAnjutaProject *proj);
+ ProjectManagerProject *proj);
static void insert_empty_node (GbfProjectModel *model);
static void unload_project (GbfProjectModel *model);
@@ -703,7 +705,7 @@ project_updated_cb (IAnjutaProject *project, GbfProjectModel *model)
}
static void
-load_project (GbfProjectModel *model, IAnjutaProject *proj)
+load_project (GbfProjectModel *model, ProjectManagerProject *proj)
{
model->priv->proj = proj;
g_object_ref (proj);
@@ -711,10 +713,10 @@ load_project (GbfProjectModel *model, IAnjutaProject *proj)
/* to get rid of the empty node */
gbf_project_model_clear (model);
- add_target_group (model, ianjuta_project_get_root (proj, NULL), NULL);
+ add_target_group (model, pm_project_get_root (proj), NULL);
model->priv->project_updated_handler =
- g_signal_connect (model->priv->proj, "project-updated",
+ g_signal_connect (pm_project_get_project (model->priv->proj), "project-updated",
(GCallback) project_updated_cb, model);
}
@@ -744,10 +746,9 @@ unload_project (GbfProjectModel *model)
g_list_free (model->priv->shortcuts);
model->priv->shortcuts = NULL;
- g_signal_handler_disconnect (model->priv->proj,
+ g_signal_handler_disconnect (pm_project_get_project (model->priv->proj),
model->priv->project_updated_handler);
model->priv->project_updated_handler = 0;
- g_object_unref (model->priv->proj);
model->priv->proj = NULL;
insert_empty_node (model);
@@ -815,10 +816,10 @@ gbf_project_model_new (IAnjutaProject *project)
}
void
-gbf_project_model_set_project (GbfProjectModel *model, IAnjutaProject *project)
+gbf_project_model_set_project (GbfProjectModel *model, ProjectManagerProject *project)
{
g_return_if_fail (model != NULL && GBF_IS_PROJECT_MODEL (model));
- g_return_if_fail (project == NULL || IANJUTA_IS_PROJECT (project));
+ g_return_if_fail (project != NULL);
if (model->priv->proj)
unload_project (model);
@@ -827,7 +828,7 @@ gbf_project_model_set_project (GbfProjectModel *model, IAnjutaProject *project)
load_project (model, project);
}
-IAnjutaProject *
+ProjectManagerProject *
gbf_project_model_get_project (GbfProjectModel *model)
{
g_return_val_if_fail (model != NULL && GBF_IS_PROJECT_MODEL (model), NULL);
diff --git a/plugins/project-manager/gbf-project-model.h b/plugins/project-manager/gbf-project-model.h
index 93e72ca..cd99c19 100644
--- a/plugins/project-manager/gbf-project-model.h
+++ b/plugins/project-manager/gbf-project-model.h
@@ -25,8 +25,8 @@
#include <glib-object.h>
#include <gtk/gtk.h>
-#include <libanjuta/interfaces/ianjuta-project.h>
#include <libanjuta/anjuta-project.h>
+#include "project.h"
#include "gbf-tree-data.h"
#define GBF_TYPE_PROJECT_MODEL (gbf_project_model_get_type ())
@@ -57,8 +57,8 @@ GType gbf_project_model_get_type (void);
GbfProjectModel *gbf_project_model_new (IAnjutaProject *project);
void gbf_project_model_set_project (GbfProjectModel *model,
- IAnjutaProject *project);
-IAnjutaProject *gbf_project_model_get_project (GbfProjectModel *model);
+ ProjectManagerProject *project);
+ProjectManagerProject *gbf_project_model_get_project (GbfProjectModel *model);
GtkTreePath *gbf_project_model_get_project_root (GbfProjectModel *model);
gboolean gbf_project_model_remove (GbfProjectModel *model,
diff --git a/plugins/project-manager/gbf-project-util.c b/plugins/project-manager/gbf-project-util.c
index 32b07e0..2171877 100644
--- a/plugins/project-manager/gbf-project-util.c
+++ b/plugins/project-manager/gbf-project-util.c
@@ -171,7 +171,7 @@ gbf_project_util_new_group (GbfProjectModel *model,
GtkWidget *dialog, *group_name_entry, *ok_button;
GtkWidget *groups_view;
gint response;
- IAnjutaProject *project;
+ ProjectManagerProject *project;
gboolean finished = FALSE;
AnjutaProjectNode *new_group = NULL;
@@ -225,7 +225,7 @@ gbf_project_util_new_group (GbfProjectModel *model,
group = gbf_project_view_find_selected (GBF_PROJECT_VIEW (groups_view),
ANJUTA_PROJECT_GROUP);
if (group) {
- new_group = ianjuta_project_add_group (project, group, name, &err);
+ new_group = pm_project_add_group (project, group, name, &err);
if (err) {
error_dialog (parent, _("Cannot add group"), "%s",
err->message);
@@ -261,14 +261,14 @@ enum {
/* create a tree model with the target types */
static GtkListStore *
-build_types_store (IAnjutaProject *project)
+build_types_store (ProjectManagerProject *project)
{
GtkListStore *store;
GtkTreeIter iter;
GList *types;
GList *node;
- types = ianjuta_project_get_target_types (project, NULL);
+ types = pm_project_get_target_types (project);
store = gtk_list_store_new (TARGET_TYPE_N_COLUMNS,
G_TYPE_POINTER,
G_TYPE_STRING,
@@ -313,7 +313,7 @@ gbf_project_util_new_target (GbfProjectModel *model,
GtkListStore *types_store;
GtkCellRenderer *renderer;
gint response;
- IAnjutaProject *project;
+ ProjectManagerProject *project;
gboolean finished = FALSE;
AnjutaProjectNode *new_target = NULL;
@@ -403,7 +403,7 @@ gbf_project_util_new_target (GbfProjectModel *model,
}
if (group && type) {
- new_target = ianjuta_project_add_target (project, group, name, type, &err);
+ new_target = pm_project_add_target (project, group, name, type, &err);
if (err) {
error_dialog (parent, _("Cannot add target"), "%s",
err->message);
@@ -666,7 +666,7 @@ gbf_project_util_add_source_multi (GbfProjectModel *model,
GtkWidget *ok_button, *browse_button;
GtkWidget *targets_view;
gint response;
- IAnjutaProject *project;
+ ProjectManagerProject *project;
gboolean finished = FALSE;
gchar *project_root;
GtkListStore* list;
@@ -776,7 +776,7 @@ gbf_project_util_add_source_multi (GbfProjectModel *model,
COLUMN_URI, &uri, -1);
source_file = g_file_new_for_uri (uri);
- new_source = ianjuta_project_add_source (project,
+ new_source = pm_project_add_source (project,
target,
source_file,
&err);
@@ -907,7 +907,7 @@ gbf_project_util_add_module (GbfProjectModel *model,
GtkWidget *targets_view;
GtkWidget *modules_view;
gint response;
- IAnjutaProject *project;
+ ProjectManagerProject *project;
gboolean finished = FALSE;
GList* new_modules = NULL;
GtkTreeSelection *module_selection;
@@ -1116,7 +1116,7 @@ gbf_project_util_add_package (GbfProjectModel *model,
GList *packages = NULL;
GtkTreeViewColumn *col;
gint response;
- IAnjutaProject *project;
+ ProjectManagerProject *project;
gboolean finished = FALSE;
GtkTreeSelection *package_selection;
GtkTreeIter root;
diff --git a/plugins/project-manager/gbf-tree-data.c b/plugins/project-manager/gbf-tree-data.c
index d8483b1..8d648b5 100644
--- a/plugins/project-manager/gbf-tree-data.c
+++ b/plugins/project-manager/gbf-tree-data.c
@@ -53,7 +53,7 @@
*/
AnjutaProjectNode *
-gbf_tree_data_get_node (GbfTreeData *data, IAnjutaProject *project)
+gbf_tree_data_get_node (GbfTreeData *data, ProjectManagerProject *project)
{
AnjutaProjectNode *node = NULL;
@@ -63,7 +63,7 @@ gbf_tree_data_get_node (GbfTreeData *data, IAnjutaProject *project)
AnjutaProjectNode *group = NULL;
AnjutaProjectNode *target = NULL;
- root = ianjuta_project_get_root (project, NULL);
+ root = pm_project_get_root (project);
if ((root != NULL) && (data->group != NULL))
{
group = anjuta_project_group_get_node_from_file (root, data->group);
diff --git a/plugins/project-manager/gbf-tree-data.h b/plugins/project-manager/gbf-tree-data.h
index a1d0a03..ad198d6 100644
--- a/plugins/project-manager/gbf-tree-data.h
+++ b/plugins/project-manager/gbf-tree-data.h
@@ -24,7 +24,7 @@
#include <glib-object.h>
#include <gtk/gtk.h>
-#include <libanjuta/interfaces/ianjuta-project.h>
+#include "project.h"
#include <libanjuta/anjuta-project.h>
G_BEGIN_DECLS
@@ -54,29 +54,29 @@ struct _GbfTreeData
GtkWidget *properties_dialog;
};
-AnjutaProjectNode *gbf_tree_data_get_node (GbfTreeData *data,
- IAnjutaProject *project);
+AnjutaProjectNode *gbf_tree_data_get_node (GbfTreeData *data,
+ ProjectManagerProject *project);
-gchar *gbf_tree_data_get_uri (GbfTreeData *data);
-GFile *gbf_tree_data_get_file (GbfTreeData *data);
-const gchar *gdb_tree_data_get_name (GbfTreeData *data);
+gchar *gbf_tree_data_get_uri (GbfTreeData *data);
+GFile *gbf_tree_data_get_file (GbfTreeData *data);
+const gchar *gdb_tree_data_get_name (GbfTreeData *data);
-gchar *gbf_tree_data_get_path (GbfTreeData *data);
+gchar *gbf_tree_data_get_path (GbfTreeData *data);
-gboolean gbf_tree_data_equal (GbfTreeData *data_a,
- GbfTreeData *data_b);
+gboolean gbf_tree_data_equal (GbfTreeData *data_a,
+ GbfTreeData *data_b);
-GbfTreeData *gbf_tree_data_new_for_path (const gchar *data);
-GbfTreeData *gbf_tree_data_new_for_file (GFile *file,
- GbfTreeNodeType type);
-GbfTreeData *gbf_tree_data_new_string (const gchar *string);
-GbfTreeData *gbf_tree_data_new_shortcut (GbfTreeData *src);
-GbfTreeData *gbf_tree_data_new_group (AnjutaProjectNode *group);
-GbfTreeData *gbf_tree_data_new_target (AnjutaProjectNode *target);
-GbfTreeData *gbf_tree_data_new_source (AnjutaProjectNode *source);
-GbfTreeData *gbf_tree_data_new_module (AnjutaProjectNode *module);
-GbfTreeData *gbf_tree_data_new_package (AnjutaProjectNode *package);
-void gbf_tree_data_free (GbfTreeData *data);
+GbfTreeData *gbf_tree_data_new_for_path (const gchar *data);
+GbfTreeData *gbf_tree_data_new_for_file (GFile *file,
+ GbfTreeNodeType type);
+GbfTreeData *gbf_tree_data_new_string (const gchar *string);
+GbfTreeData *gbf_tree_data_new_shortcut (GbfTreeData *src);
+GbfTreeData *gbf_tree_data_new_group (AnjutaProjectNode *group);
+GbfTreeData *gbf_tree_data_new_target (AnjutaProjectNode *target);
+GbfTreeData *gbf_tree_data_new_source (AnjutaProjectNode *source);
+GbfTreeData *gbf_tree_data_new_module (AnjutaProjectNode *module);
+GbfTreeData *gbf_tree_data_new_package (AnjutaProjectNode *package);
+void gbf_tree_data_free (GbfTreeData *data);
G_END_DECLS
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index fbc48ed..d0796dd 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -438,7 +438,7 @@ project_manager_show_node_properties_dialog (ProjectManagerPlugin *plugin,
node = gbf_tree_data_get_node (data, plugin->project);
if (node != NULL)
{
- properties = ianjuta_project_configure_node (plugin->project, node, NULL);
+ properties = pm_project_configure (plugin->project, node);
if (properties == NULL)
{
@@ -452,7 +452,7 @@ project_manager_show_node_properties_dialog (ProjectManagerPlugin *plugin,
node = gbf_tree_data_get_node (data, plugin->project);
if (node != NULL)
{
- properties = ianjuta_project_configure_node (plugin->project, node, NULL);
+ properties = pm_project_configure (plugin->project, node);
if (properties == NULL)
{
@@ -490,7 +490,7 @@ project_manager_show_project_properties_dialog (ProjectManagerPlugin *plugin)
project_manager_create_properties_dialog(plugin,
&plugin->properties_dialog,
_("Project properties"),
- ianjuta_project_configure (plugin->project, NULL));
+ pm_project_configure (plugin->project, NULL));
}
}
@@ -511,7 +511,7 @@ on_refresh_idle (gpointer user_data)
anjuta_status_push (status, _("Refreshing symbol treeâ?¦"));
anjuta_status_busy_push (status);
- ianjuta_project_refresh (IANJUTA_PROJECT (plugin->project), &err);
+ pm_project_refresh (plugin->project, &err);
if (err)
{
anjuta_util_dialog_error (get_plugin_parent_window (plugin),
@@ -845,7 +845,7 @@ on_popup_remove (GtkAction *action, ProjectManagerPlugin *plugin)
if (node != NULL)
{
if (!update) update_operation_begin (plugin);
- ianjuta_project_remove_node (plugin->project, node, &err);
+ pm_project_remove (plugin->project, node, &err);
if (err)
{
gchar *name;
@@ -1056,10 +1056,9 @@ update_ui (ProjectManagerPlugin *plugin)
AnjutaUI *ui;
gint j;
GtkAction *action;
- IAnjutaProjectCapabilities caps = IANJUTA_PROJECT_CAN_ADD_NONE;
+ IAnjutaProjectCapabilities caps;
- if (plugin->project)
- caps = ianjuta_project_get_capabilities (plugin->project, NULL);
+ caps = pm_project_get_capabilities (plugin->project);
ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
for (j = 0; j < G_N_ELEMENTS (pm_actions); j++)
@@ -1071,7 +1070,7 @@ update_ui (ProjectManagerPlugin *plugin)
{
/* 'close' menuitem is never disabled */
g_object_set (G_OBJECT (action), "sensitive",
- (plugin->project != NULL), NULL);
+ pm_project_is_open (plugin->project), NULL);
}
}
@@ -1079,19 +1078,19 @@ update_ui (ProjectManagerPlugin *plugin)
action = anjuta_ui_get_action (ui, "ActionGroupProjectManager",
"ActionProjectAddGroup");
g_object_set (G_OBJECT (action), "sensitive",
- ((plugin->project != NULL) &&
+ (pm_project_is_open (plugin->project) &&
(caps & IANJUTA_PROJECT_CAN_ADD_GROUP)), NULL);
action = anjuta_ui_get_action (ui, "ActionGroupProjectManager",
"ActionProjectAddTarget");
g_object_set (G_OBJECT (action), "sensitive",
- ((plugin->project != NULL) &&
+ (pm_project_is_open (plugin->project) &&
(caps & IANJUTA_PROJECT_CAN_ADD_TARGET)), NULL);
action = anjuta_ui_get_action (ui, "ActionGroupProjectManager",
"ActionProjectAddSource");
g_object_set (G_OBJECT (action), "sensitive",
- ((plugin->project != NULL) &&
+ (pm_project_is_open (plugin->project) &&
(caps & IANJUTA_PROJECT_CAN_ADD_SOURCE)), NULL);
/* Popup menus */
@@ -1102,7 +1101,7 @@ update_ui (ProjectManagerPlugin *plugin)
if (popup_actions[j].callback)
{
g_object_set (G_OBJECT (action), "sensitive",
- (plugin->project != NULL), NULL);
+ pm_project_is_open (plugin->project), NULL);
}
}
}
@@ -1115,7 +1114,7 @@ on_treeview_selection_changed (GtkTreeSelection *sel,
GtkAction *action;
AnjutaProjectNode *node;
GFile *selected_file;
- IAnjutaProjectCapabilities caps = IANJUTA_PROJECT_CAN_ADD_NONE;
+ IAnjutaProjectCapabilities caps;
ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
/* Popup menu */
@@ -1132,8 +1131,7 @@ on_treeview_selection_changed (GtkTreeSelection *sel,
"ActionPopupProjectRemove");
g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
- if (plugin->project)
- caps = ianjuta_project_get_capabilities (plugin->project, NULL);
+ caps = pm_project_get_capabilities (plugin->project);
node = gbf_project_view_find_selected (GBF_PROJECT_VIEW (plugin->view),
ANJUTA_PROJECT_SOURCE);
if (node && anjuta_project_node_get_type (node) == ANJUTA_PROJECT_SOURCE)
@@ -1379,16 +1377,12 @@ value_removed_current_editor (AnjutaPlugin *plugin,
static void
project_manager_load_gbf (ProjectManagerPlugin *pm_plugin)
{
- AnjutaPluginManager *plugin_manager;
AnjutaStatus *status;
gchar *dirname;
GFile *dirfile;
gchar *basename;
const gchar *root_uri;
GError *error = NULL;
- GList *desc;
- IAnjutaProjectBackend *backend;
- gint found = 0;
root_uri = pm_plugin->project_root_uri;
@@ -1396,86 +1390,17 @@ project_manager_load_gbf (ProjectManagerPlugin *pm_plugin)
dirfile = g_file_new_for_uri (root_uri);
g_return_if_fail (dirname != NULL);
-
- if (pm_plugin->project != NULL)
- g_object_unref (pm_plugin->project);
-
- DEBUG_PRINT ("loading gbf backendâ?¦\n");
- plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN(pm_plugin)->shell, NULL);
- if (!anjuta_plugin_manager_is_active_plugin (plugin_manager, "IAnjutaProjectBackend"))
- {
- GList *descs = NULL;
-
- descs = anjuta_plugin_manager_query (plugin_manager,
- "Anjuta Plugin",
- "Interfaces",
- "IAnjutaProjectBackend",
- 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;
-
- backend_desc = (AnjutaPluginDescription *)desc->data;
- anjuta_plugin_description_get_string (backend_desc, "Anjuta Plugin", "Location", &location);
- plugin = (IAnjutaProjectBackend *)anjuta_plugin_manager_get_plugin_by_id (plugin_manager, location);
- g_free (location);
-
- backend_val = ianjuta_project_backend_probe (plugin, dirfile, NULL);
- if (backend_val > found)
- {
- /* Backend found */;
- backend = plugin;
- found = backend_val;
- }
- }
- g_list_free (descs);
- }
- else
- {
- /* A backend is already loaded, use it */
- backend = IANJUTA_PROJECT_BACKEND (anjuta_shell_get_object (ANJUTA_PLUGIN (pm_plugin)->shell,
- "IAnjutaProjectBackend", NULL));
-
- g_object_ref (backend);
- }
-
- if (!backend)
- {
- /* FIXME: Set err */
- g_warning ("no backend available for this project\n");
- g_free (dirname);
- g_object_unref (dirfile);
- return;
- }
-
- DEBUG_PRINT ("%s", "Creating new gbf project\n");
- pm_plugin->project = ianjuta_project_backend_new_project (backend, NULL);
- if (!pm_plugin->project)
- {
- /* FIXME: Set err */
- g_warning ("project creation failed\n");
- g_free (dirname);
- g_object_unref (dirfile);
- return;
- }
-
status = anjuta_shell_get_status (ANJUTA_PLUGIN (pm_plugin)->shell, NULL);
anjuta_status_progress_add_ticks (status, 1);
basename = g_path_get_basename (dirname);
anjuta_status_push (status, _("Loading project: %s"), basename);
anjuta_status_busy_push (status);
-
+
DEBUG_PRINT ("loading project %s\n\n", dirname);
- /* FIXME: use the error parameter to determine if the project
- * was loaded successfully */
- ianjuta_project_load (pm_plugin->project, dirfile, &error);
-
- anjuta_status_progress_tick (status, NULL, _("Created project viewâ?¦"));
-
+ pm_project_load (pm_plugin->project, dirfile, &error);
+ g_message ("try loading %s %p", dirname, error);
+
if (error)
{
GtkWidget *toplevel;
@@ -1490,26 +1415,20 @@ project_manager_load_gbf (ProjectManagerPlugin *pm_plugin)
anjuta_util_dialog_error (win, _("Failed to parse project (the project is opened, but there will be no project view) %s: %s\n"
""),
dirname, error->message);
- /* g_propagate_error (err, error); */
- g_object_unref (pm_plugin->project);
- pm_plugin->project = NULL;
- g_free (basename);
- g_free (dirname);
- g_object_unref (dirfile);
- /* gtk_widget_destroy (progress_win); */
- anjuta_status_pop (status);
- anjuta_status_busy_pop (status);
- return;
}
- g_object_set (G_OBJECT (pm_plugin->model), "project",
+ else
+ {
+ g_object_set (G_OBJECT (pm_plugin->model), "project",
pm_plugin->project, NULL);
+ anjuta_status_progress_tick (status, NULL, _("Created project viewâ?¦"));
+ update_ui (pm_plugin);
+ anjuta_shell_present_widget (ANJUTA_PLUGIN (pm_plugin)->shell,
+ pm_plugin->scrolledwindow,
+ NULL);
- update_ui (pm_plugin);
- anjuta_shell_present_widget (ANJUTA_PLUGIN (pm_plugin)->shell,
- pm_plugin->scrolledwindow,
- NULL);
+ anjuta_status_set_default (status, _("Project"), basename);
+ }
- anjuta_status_set_default (status, _("Project"), basename);
anjuta_status_pop (status);
anjuta_status_busy_pop (status);
g_free (basename);
@@ -1522,7 +1441,7 @@ project_manager_unload_gbf (ProjectManagerPlugin *pm_plugin)
{
AnjutaStatus *status;
- if (pm_plugin->project)
+ if (pm_project_is_open (pm_plugin->project))
{
IAnjutaDocumentManager *docman;
@@ -1586,9 +1505,8 @@ project_manager_unload_gbf (ProjectManagerPlugin *pm_plugin)
pm_plugin->properties_dialog = NULL;
/* Release project */
- g_object_unref (pm_plugin->project);
- pm_plugin->project = NULL;
g_object_set (G_OBJECT (pm_plugin->model), "project", NULL, NULL);
+ pm_project_unload (pm_plugin->project, NULL);
update_ui (pm_plugin);
status = anjuta_shell_get_status (ANJUTA_PLUGIN (pm_plugin)->shell,
NULL);
@@ -1706,6 +1624,9 @@ project_manager_plugin_activate_plugin (AnjutaPlugin *plugin)
pm_plugin->ui = anjuta_shell_get_ui (plugin->shell, NULL);
pm_plugin->prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
+ /* Create project */
+ pm_plugin->project = pm_project_new (plugin);
+
/* create model & view and bind them */
model = gbf_project_model_new (NULL);
view = gbf_project_view_new ();
@@ -1855,6 +1776,9 @@ project_manager_plugin_deactivate_plugin (AnjutaPlugin *plugin)
anjuta_ui_remove_action_group (pm_plugin->ui, pm_plugin->pm_action_group);
anjuta_ui_remove_action_group (pm_plugin->ui,
pm_plugin->popup_action_group);
+
+ /* Destroy project */
+ pm_project_free (pm_plugin->project);
return TRUE;
}
@@ -1978,7 +1902,7 @@ get_element_file_from_node (ProjectManagerPlugin *plugin, AnjutaProjectNode *nod
{
gchar *rel_path;
- rel_path = g_file_get_relative_path (anjuta_project_group_get_directory (ianjuta_project_get_root (plugin->project, NULL)), file);
+ rel_path = g_file_get_relative_path (anjuta_project_group_get_directory (pm_project_get_root (plugin->project)), file);
if (rel_path)
{
@@ -2059,9 +1983,8 @@ iproject_manager_get_elements (IAnjutaProjectManager *project_manager,
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), NULL);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- g_return_val_if_fail (IANJUTA_IS_PROJECT (plugin->project), NULL);
- return gbf_project_util_replace_by_file (gbf_project_util_node_all (ianjuta_project_get_root (plugin->project, NULL), element_type));
+ return gbf_project_util_replace_by_file (gbf_project_util_node_all (pm_project_get_root (plugin->project), element_type));
}
static AnjutaProjectTargetClass
@@ -2076,8 +1999,6 @@ iproject_manager_get_target_type (IAnjutaProjectManager *project_manager,
ANJUTA_TARGET_UNKNOWN);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- g_return_val_if_fail (IANJUTA_IS_PROJECT (plugin->project),
- ANJUTA_TARGET_UNKNOWN);
g_return_val_if_fail (file_is_inside_project (plugin, target_file),
ANJUTA_TARGET_UNKNOWN);
@@ -2107,10 +2028,9 @@ iproject_manager_get_targets (IAnjutaProjectManager *project_manager,
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), NULL);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- g_return_val_if_fail (IANJUTA_IS_PROJECT (plugin->project), NULL);
/* Get all targets */
- targets = gbf_project_util_node_all (ianjuta_project_get_root (plugin->project, NULL), ANJUTA_PROJECT_TARGET);
+ targets = gbf_project_util_node_all (pm_project_get_root (plugin->project), ANJUTA_PROJECT_TARGET);
/* Remove all targets not in specified class */
for (node = g_list_first (targets); node != NULL;)
@@ -2150,7 +2070,6 @@ iproject_manager_get_parent (IAnjutaProjectManager *project_manager,
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), NULL);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- g_return_val_if_fail (IANJUTA_IS_PROJECT (plugin->project), NULL);
type = get_element_type (plugin, element);
/* FIXME: */
@@ -2167,7 +2086,6 @@ iproject_manager_get_children (IAnjutaProjectManager *project_manager,
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), NULL);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- g_return_val_if_fail (IANJUTA_IS_PROJECT (plugin->project), NULL);
/* FIXME: */
return NULL;
}
@@ -2182,9 +2100,7 @@ iproject_manager_get_selected (IAnjutaProjectManager *project_manager,
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), NULL);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- if (plugin->project == NULL) return NULL;
-
- g_return_val_if_fail (IANJUTA_IS_PROJECT (plugin->project), NULL);
+ if (!pm_project_is_open (plugin->project)) return NULL;
node = gbf_project_view_find_selected (GBF_PROJECT_VIEW (plugin->view),
ANJUTA_PROJECT_SOURCE);
@@ -2220,7 +2136,7 @@ iproject_manager_get_capabilities (IAnjutaProjectManager *project_manager,
IANJUTA_PROJECT_CAN_ADD_NONE);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- return ianjuta_project_get_capabilities (plugin->project, NULL);
+ return pm_project_get_capabilities (plugin->project);
}
static GFile*
@@ -2238,7 +2154,6 @@ iproject_manager_add_source (IAnjutaProjectManager *project_manager,
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), FALSE);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- g_return_val_if_fail (IANJUTA_IS_PROJECT (plugin->project), FALSE);
update_operation_begin (plugin);
if (default_target_file != NULL)
@@ -2270,12 +2185,11 @@ iproject_manager_add_source_quiet (IAnjutaProjectManager *project_manager,
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), FALSE);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- g_return_val_if_fail (IANJUTA_IS_PROJECT (plugin->project), FALSE);
target = get_project_node_from_file (plugin, location_file, ANJUTA_PROJECT_TARGET);
source_file = g_file_new_for_uri (source_uri_to_add);
update_operation_begin (plugin);
- source_id = ianjuta_project_add_source (plugin->project,
+ source_id = pm_project_add_source (plugin->project,
target,
source_file,
err);
@@ -2300,7 +2214,6 @@ iproject_manager_add_source_multi (IAnjutaProjectManager *project_manager,
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), FALSE);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- g_return_val_if_fail (IANJUTA_IS_PROJECT (plugin->project), FALSE);
update_operation_begin (plugin);
if (default_target_file != NULL)
@@ -2341,8 +2254,6 @@ iproject_manager_add_target (IAnjutaProjectManager *project_manager,
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), FALSE);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
-
- g_return_val_if_fail (IANJUTA_IS_PROJECT (plugin->project), FALSE);
if (default_group_file != NULL)
{
@@ -2375,7 +2286,6 @@ iproject_manager_add_group (IAnjutaProjectManager *project_manager,
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), FALSE);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- g_return_val_if_fail (IANJUTA_IS_PROJECT (plugin->project), FALSE);
if (default_group_file != NULL)
{
@@ -2400,7 +2310,7 @@ iproject_manager_is_open (IAnjutaProjectManager *project_manager, GError **err)
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- return IANJUTA_IS_PROJECT (plugin->project);
+ return pm_project_is_open (plugin->project);
}
static GList*
@@ -2409,11 +2319,8 @@ iproject_manager_get_packages (IAnjutaProjectManager *project_manager, GError **
ProjectManagerPlugin *plugin;
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
-
- /* Check if a current project is opened */
- if (plugin->project == NULL) return NULL;
- return ianjuta_project_get_packages (plugin->project, NULL);
+ return pm_project_get_packages (plugin->project);
}
static void
diff --git a/plugins/project-manager/plugin.h b/plugins/project-manager/plugin.h
index 57169cb..4ff0854 100644
--- a/plugins/project-manager/plugin.h
+++ b/plugins/project-manager/plugin.h
@@ -26,6 +26,7 @@
#include <libanjuta/interfaces/ianjuta-project.h>
#include "gbf-project-model.h"
#include "gbf-project-view.h"
+#include "project.h"
extern GType project_manager_plugin_get_type (GTypeModule *module);
#define ANJUTA_TYPE_PLUGIN_PROJECT_MANAGER (project_manager_plugin_get_type (NULL))
@@ -40,10 +41,11 @@ typedef struct _ProjectManagerPluginClass ProjectManagerPluginClass;
struct _ProjectManagerPlugin{
AnjutaPlugin parent;
+
+ ProjectManagerProject *project;
AnjutaUI *ui;
AnjutaPreferences *prefs;
- IAnjutaProject *project;
GtkWidget *view;
GbfProjectModel *model;
GtkWidget *scrolledwindow;
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
new file mode 100644
index 0000000..b68ae77
--- /dev/null
+++ b/plugins/project-manager/project.c
@@ -0,0 +1,303 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/* project.c
+ *
+ * Copyright (C) 2010 Sébastien Granjoux
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "project.h"
+#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/interfaces/ianjuta-project-backend.h>
+#include "gbf-project-model.h"
+#include "gbf-project-view.h"
+
+/* Public functions
+ *---------------------------------------------------------------------------*/
+
+struct _ProjectManagerProject{
+ AnjutaPlugin *plugin;
+
+ AnjutaUI *ui;
+ AnjutaPreferences *prefs;
+ IAnjutaProject *project;
+ GtkWidget *view;
+ GbfProjectModel *model;
+ GtkWidget *scrolledwindow;
+
+ GtkActionGroup *pm_action_group;
+ GtkActionGroup *popup_action_group;
+ gint merge_id;
+
+ gint fm_watch_id;
+ gint editor_watch_id;
+
+ gchar *fm_current_uri;
+ gchar *current_editor_uri;
+ gchar *project_root_uri;
+ gchar *project_uri;
+
+ /* Update state recording */
+ GList *pre_update_sources;
+ GList *pre_update_targets;
+ GList *pre_update_groups;
+
+ /* Session flag */
+ gboolean session_by_me;
+
+ /* Idle callback id */
+ guint close_project_idle;
+
+ /* project properties dialog */
+ GtkWidget *properties_dialog;
+};
+
+/* Public functions
+ *---------------------------------------------------------------------------*/
+
+gboolean
+pm_project_load (ProjectManagerProject *project, GFile *file, GError **error)
+{
+ AnjutaPluginManager *plugin_manager;
+ GList *desc;
+ IAnjutaProjectBackend *backend;
+ gint found = 0;
+ gboolean ok;
+
+ g_return_val_if_fail (file != NULL, FALSE);
+
+ if (project->project != NULL)
+ {
+ g_object_unref (project->project);
+ project->project = NULL;
+ }
+
+ DEBUG_PRINT ("loading gbf backendâ?¦\n");
+ plugin_manager = anjuta_shell_get_plugin_manager (project->plugin->shell, NULL);
+
+ if (!anjuta_plugin_manager_is_active_plugin (plugin_manager, "IAnjutaProjectBackend"))
+ {
+ GList *descs = NULL;
+
+ descs = anjuta_plugin_manager_query (plugin_manager,
+ "Anjuta Plugin",
+ "Interfaces",
+ "IAnjutaProjectBackend",
+ 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;
+
+ backend_desc = (AnjutaPluginDescription *)desc->data;
+ anjuta_plugin_description_get_string (backend_desc, "Anjuta Plugin", "Location", &location);
+ plugin = (IAnjutaProjectBackend *)anjuta_plugin_manager_get_plugin_by_id (plugin_manager, location);
+ g_free (location);
+
+ backend_val = ianjuta_project_backend_probe (plugin, file, NULL);
+ if (backend_val > found)
+ {
+ /* Backend found */;
+ backend = plugin;
+ found = backend_val;
+ }
+ }
+ g_list_free (descs);
+ }
+ else
+ {
+ /* A backend is already loaded, use it */
+ backend = IANJUTA_PROJECT_BACKEND (anjuta_shell_get_object (project->plugin->shell,
+ "IAnjutaProjectBackend", NULL));
+
+ g_object_ref (backend);
+ }
+
+ if (!backend)
+ {
+ /* FIXME: Set err */
+ g_warning ("no backend available for this project\n");
+
+ return FALSE;
+ }
+
+ DEBUG_PRINT ("%s", "Creating new gbf project\n");
+ project->project = ianjuta_project_backend_new_project (backend, NULL);
+ if (!project->project)
+ {
+ /* FIXME: Set err */
+ g_warning ("project creation failed\n");
+
+ return FALSE;
+ }
+
+ /* FIXME: use the error parameter to determine if the project
+ * was loaded successfully */
+ ok = ianjuta_project_load (project->project, file, error);
+ g_message ("load project %s %p ok %d", g_file_get_path (file), project->project, ok);
+ if (!ok)
+ {
+ g_warning ("unable to load project");
+ /* Unable to load project, destroy project object */
+ g_object_unref (project->project);
+ project->project = NULL;
+ }
+
+ return ok;
+}
+
+gboolean
+pm_project_unload (ProjectManagerProject *project, GError **error)
+{
+ g_object_unref (project->project);
+ project->project = NULL;
+
+ return TRUE;
+}
+
+gboolean
+pm_project_refresh (ProjectManagerProject *project, GError **error)
+{
+ ianjuta_project_refresh (project->project, error);
+
+ return TRUE;
+}
+
+GtkWidget *
+pm_project_configure (ProjectManagerProject *project, AnjutaProjectNode *node)
+{
+ GtkWidget *properties;
+
+ if (node == NULL)
+ {
+ properties = ianjuta_project_configure (project->project, NULL);
+ }
+ else
+ {
+ properties = ianjuta_project_configure_node (project->project, node, NULL);
+ }
+
+ return properties;
+}
+
+gboolean
+pm_project_remove (ProjectManagerProject *project, AnjutaProjectNode *node, GError **error)
+{
+ ianjuta_project_remove_node (project->project, node, error);
+
+ return TRUE;
+}
+
+IAnjutaProjectCapabilities
+pm_project_get_capabilities (ProjectManagerProject *project)
+{
+ IAnjutaProjectCapabilities caps = IANJUTA_PROJECT_CAN_ADD_NONE;
+
+ if (project->project != NULL)
+ caps = ianjuta_project_get_capabilities (project->project, NULL);
+
+ return caps;
+}
+
+GList *
+pm_project_get_target_types (ProjectManagerProject *project)
+{
+ g_return_val_if_fail (project->project != NULL, NULL);
+
+ return ianjuta_project_get_target_types (project->project, NULL);
+}
+
+AnjutaProjectNode *
+pm_project_get_root (ProjectManagerProject *project)
+{
+ if (project->project == NULL) return NULL;
+
+ return ianjuta_project_get_root (project->project, NULL);
+}
+
+GList *
+pm_project_get_packages (ProjectManagerProject *project)
+{
+ if (project->project == NULL) return NULL;
+
+ return ianjuta_project_get_packages (project->project, NULL);
+}
+
+AnjutaProjectNode *
+pm_project_add_group (ProjectManagerProject *project, AnjutaProjectNode *group, const gchar *name, GError **error)
+{
+ g_return_val_if_fail (project->project != NULL, NULL);
+
+ return ianjuta_project_add_group (project->project, group, name, error);
+}
+
+AnjutaProjectNode *
+pm_project_add_target (ProjectManagerProject *project, AnjutaProjectNode *group, const gchar *name, AnjutaProjectTargetType type, GError **error)
+{
+ g_return_val_if_fail (project->project != NULL, NULL);
+
+ return ianjuta_project_add_target (project->project, group, name, type, error);
+}
+
+AnjutaProjectNode *
+pm_project_add_source (ProjectManagerProject *project, AnjutaProjectNode *target, GFile *file, GError **error)
+{
+ AnjutaProjectNode *source;
+
+ g_return_val_if_fail (project->project != NULL, NULL);
+
+ source = ianjuta_project_add_source (project->project, target, file, error);
+
+ return source;
+}
+
+gboolean
+pm_project_is_open (ProjectManagerProject *project)
+{
+ return project->project != NULL;
+}
+
+IAnjutaProject *
+pm_project_get_project (ProjectManagerProject *project)
+{
+ return project->project;
+}
+
+/* Constructor & Destructor
+ *---------------------------------------------------------------------------*/
+
+ProjectManagerProject*
+pm_project_new (AnjutaPlugin *plugin)
+{
+ ProjectManagerProject *project;
+
+ project = g_new0 (ProjectManagerProject, 1);
+ project->plugin = plugin;
+ project->project = NULL;
+
+ return project;
+}
+
+void
+pm_project_free (ProjectManagerProject* project)
+{
+}
diff --git a/plugins/project-manager/project.h b/plugins/project-manager/project.h
new file mode 100644
index 0000000..20afbf5
--- /dev/null
+++ b/plugins/project-manager/project.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/* project.h
+ *
+ * Copyright (C) 2010 Sébastien Granjoux
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _PROJECT_H_
+#define _PROJECT_H_
+
+#include <glib.h>
+#include <glib-object.h>
+#include <libanjuta/anjuta-plugin.h>
+#include <libanjuta/anjuta-project.h>
+#include <libanjuta/interfaces/ianjuta-project.h>
+
+G_BEGIN_DECLS
+
+typedef struct _ProjectManagerProject ProjectManagerProject;
+
+ProjectManagerProject* pm_project_new (AnjutaPlugin *plugin);
+void pm_project_free (ProjectManagerProject* project);
+
+gboolean pm_project_load (ProjectManagerProject *project, GFile *file, GError **error);
+gboolean pm_project_unload (ProjectManagerProject *project, GError **error);
+gboolean pm_project_refresh (ProjectManagerProject *project, GError **error);
+GtkWidget *pm_project_configure (ProjectManagerProject *project, AnjutaProjectNode *node);
+gboolean pm_project_remove (ProjectManagerProject *project, AnjutaProjectNode *node, GError **error);
+IAnjutaProjectCapabilities pm_project_get_capabilities (ProjectManagerProject *project);
+GList *pm_project_get_target_types (ProjectManagerProject *project);
+GList *pm_project_get_packages (ProjectManagerProject *project);
+AnjutaProjectNode *pm_project_add_group (ProjectManagerProject *project, AnjutaProjectNode *group, const gchar *name, GError **error);
+AnjutaProjectNode *pm_project_add_target (ProjectManagerProject *project, AnjutaProjectNode *group, const gchar *name, AnjutaProjectTargetType type, GError **error);
+AnjutaProjectNode *pm_project_add_source (ProjectManagerProject *project, AnjutaProjectNode *target, GFile *file, GError **error);
+AnjutaProjectNode *pm_project_get_root (ProjectManagerProject *project);
+
+gboolean pm_project_is_open (ProjectManagerProject *project);
+
+IAnjutaProject *pm_project_get_project (ProjectManagerProject *project);
+
+G_END_DECLS
+
+#endif /* _PROJECT_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]