[anjuta/newproject] Move GbfProjectModel in ProjectManagerProject object
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] Move GbfProjectModel in ProjectManagerProject object
- Date: Sun, 28 Mar 2010 20:58:14 +0000 (UTC)
commit 4431f7b434f4795ea84681b70d47847b30b3e9c2
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Mar 28 22:53:11 2010 +0200
Move GbfProjectModel in ProjectManagerProject object
plugins/project-manager/gbf-project-model.c | 8 +-
plugins/project-manager/gbf-project-model.h | 5 +-
plugins/project-manager/gbf-project-util.c | 81 ++++++++------------
plugins/project-manager/gbf-project-util.h | 14 ++--
plugins/project-manager/gbf-tree-data.c | 33 --------
plugins/project-manager/gbf-tree-data.h | 4 -
plugins/project-manager/plugin.c | 51 +++++--------
plugins/project-manager/plugin.h | 1 -
plugins/project-manager/project.c | 112 ++++++++++++++++++---------
plugins/project-manager/project.h | 14 +++-
10 files changed, 151 insertions(+), 172 deletions(-)
---
diff --git a/plugins/project-manager/gbf-project-model.c b/plugins/project-manager/gbf-project-model.c
index b3327af..213deae 100644
--- a/plugins/project-manager/gbf-project-model.c
+++ b/plugins/project-manager/gbf-project-model.c
@@ -421,7 +421,7 @@ add_target_shortcut (GbfProjectModel *model,
-1);
/* add sources */
- parent = gbf_tree_data_get_node (target, model->priv->proj);
+ parent = pm_project_get_node (model->priv->proj, target);
for (node = anjuta_project_node_first_child (parent); node; node = anjuta_project_node_next_sibling (node))
add_source (model, node, &iter);
@@ -479,7 +479,7 @@ move_target_shortcut (GbfProjectModel *model,
-1);
/* add sources */
- parent = gbf_tree_data_get_node (shortcut->shortcut, model->priv->proj);
+ parent = pm_project_get_node (model->priv->proj, shortcut->shortcut);
for (node = anjuta_project_node_first_child (parent); node; node = anjuta_project_node_next_sibling (node))
add_source (model, node, iter);
}
@@ -808,7 +808,7 @@ gbf_project_model_find_tree_data (GbfProjectModel *model,
}
GbfProjectModel *
-gbf_project_model_new (IAnjutaProject *project)
+gbf_project_model_new (ProjectManagerProject *project)
{
return GBF_PROJECT_MODEL (g_object_new (GBF_TYPE_PROJECT_MODEL,
"project", project,
@@ -859,7 +859,7 @@ gbf_project_model_get_node (GbfProjectModel *model,
GBF_PROJECT_MODEL_COLUMN_DATA, &data,
-1);
- return gbf_tree_data_get_node (data, model->priv->proj);
+ return pm_project_get_node (model->priv->proj, data);
}
void
diff --git a/plugins/project-manager/gbf-project-model.h b/plugins/project-manager/gbf-project-model.h
index cd99c19..37306f9 100644
--- a/plugins/project-manager/gbf-project-model.h
+++ b/plugins/project-manager/gbf-project-model.h
@@ -26,7 +26,6 @@
#include <glib-object.h>
#include <gtk/gtk.h>
#include <libanjuta/anjuta-project.h>
-#include "project.h"
#include "gbf-tree-data.h"
#define GBF_TYPE_PROJECT_MODEL (gbf_project_model_get_type ())
@@ -53,8 +52,10 @@ struct _GbfProjectModelClass {
GtkTreeStoreClass parent_class;
};
+typedef struct _ProjectManagerProject ProjectManagerProject;
+
GType gbf_project_model_get_type (void);
-GbfProjectModel *gbf_project_model_new (IAnjutaProject *project);
+GbfProjectModel *gbf_project_model_new (ProjectManagerProject *project);
void gbf_project_model_set_project (GbfProjectModel *model,
ProjectManagerProject *project);
diff --git a/plugins/project-manager/gbf-project-util.c b/plugins/project-manager/gbf-project-util.c
index 2171877..52d8f6a 100644
--- a/plugins/project-manager/gbf-project-util.c
+++ b/plugins/project-manager/gbf-project-util.c
@@ -76,16 +76,18 @@ groups_filter_fn (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
}
static void
-setup_groups_treeview (GbfProjectModel *model,
+setup_groups_treeview (ProjectManagerProject *project,
GtkWidget *view,
GtkTreeIter *select_group)
{
GtkTreeModel *filter;
GtkTreePath *path;
-
- g_return_if_fail (model != NULL);
+ GbfProjectModel *model;
+
+ g_return_if_fail (project != NULL);
g_return_if_fail (view != NULL && GBF_IS_PROJECT_VIEW (view));
+ model = pm_project_get_model (project);
filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (model), NULL);
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
groups_filter_fn, NULL, NULL);
@@ -162,7 +164,7 @@ entry_changed_cb (GtkEditable *editable, gpointer user_data)
}
AnjutaProjectNode*
-gbf_project_util_new_group (GbfProjectModel *model,
+gbf_project_util_new_group (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_group,
const gchar *default_group_name_to_add)
@@ -171,16 +173,11 @@ gbf_project_util_new_group (GbfProjectModel *model,
GtkWidget *dialog, *group_name_entry, *ok_button;
GtkWidget *groups_view;
gint response;
- ProjectManagerProject *project;
gboolean finished = FALSE;
AnjutaProjectNode *new_group = NULL;
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (project != NULL, NULL);
- project = gbf_project_model_get_project (model);
- if (!project)
- return NULL;
-
gui = load_interface ("new_group_dialog");
g_return_val_if_fail (gui != NULL, NULL);
@@ -201,7 +198,7 @@ gbf_project_util_new_group (GbfProjectModel *model,
else
gtk_widget_set_sensitive (ok_button, FALSE);
- setup_groups_treeview (model, groups_view, default_group);
+ setup_groups_treeview (project, groups_view, default_group);
gtk_widget_show (groups_view);
if (parent) {
@@ -302,7 +299,7 @@ build_types_store (ProjectManagerProject *project)
}
AnjutaProjectNode*
-gbf_project_util_new_target (GbfProjectModel *model,
+gbf_project_util_new_target (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_group,
const gchar *default_target_name_to_add)
@@ -313,16 +310,11 @@ gbf_project_util_new_target (GbfProjectModel *model,
GtkListStore *types_store;
GtkCellRenderer *renderer;
gint response;
- ProjectManagerProject *project;
gboolean finished = FALSE;
AnjutaProjectNode *new_target = NULL;
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (project != NULL, NULL);
- project = gbf_project_model_get_project (model);
- if (!project)
- return NULL;
-
gui = load_interface ("new_target_dialog");
g_return_val_if_fail (gui != NULL, NULL);
@@ -344,7 +336,7 @@ gbf_project_util_new_target (GbfProjectModel *model,
else
gtk_widget_set_sensitive (ok_button, FALSE);
- setup_groups_treeview (model, groups_view, default_group);
+ setup_groups_treeview (project, groups_view, default_group);
gtk_widget_show (groups_view);
/* setup target types combo box */
@@ -449,17 +441,19 @@ targets_filter_fn (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
}
static void
-setup_targets_treeview (GbfProjectModel *model,
+setup_targets_treeview (ProjectManagerProject *project,
GtkWidget *view,
GtkTreeIter *select_target)
{
GtkTreeModel *filter;
GtkTreeIter iter_filter;
GtkTreePath *path = NULL;
+ GbfProjectModel *model;
- g_return_if_fail (model != NULL);
+ g_return_if_fail (project != NULL);
g_return_if_fail (view != NULL && GBF_IS_PROJECT_VIEW (view));
+ model = pm_project_get_model (project);
filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (model), NULL);
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
targets_filter_fn, NULL, NULL);
@@ -504,17 +498,19 @@ modules_filter_fn (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
}
static void
-setup_modules_treeview (GbfProjectModel *model,
+setup_modules_treeview (ProjectManagerProject *project,
GtkWidget *view,
GtkTreeIter *select_module)
{
GtkTreeModel *filter;
GtkTreeIter iter_filter;
GtkTreePath *path = NULL;
+ GbfProjectModel *model;
g_return_if_fail (model != NULL);
g_return_if_fail (view != NULL && GBF_IS_PROJECT_VIEW (view));
+ model = pm_project_get_model (project);
filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (model), NULL);
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
modules_filter_fn, NULL, NULL);
@@ -626,7 +622,7 @@ on_row_changed(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpoint
}
AnjutaProjectNode*
-gbf_project_util_add_source (GbfProjectModel *model,
+gbf_project_util_add_source (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
const gchar *default_uri)
@@ -640,7 +636,7 @@ gbf_project_util_add_source (GbfProjectModel *model,
uris = g_list_append (NULL, uri);
}
new_sources =
- gbf_project_util_add_source_multi (model, parent,
+ gbf_project_util_add_source_multi (project, parent,
default_target, uris);
g_free (uri);
g_list_free (uris);
@@ -656,7 +652,7 @@ gbf_project_util_add_source (GbfProjectModel *model,
}
GList*
-gbf_project_util_add_source_multi (GbfProjectModel *model,
+gbf_project_util_add_source_multi (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
GList *uris_to_add)
@@ -666,7 +662,6 @@ gbf_project_util_add_source_multi (GbfProjectModel *model,
GtkWidget *ok_button, *browse_button;
GtkWidget *targets_view;
gint response;
- ProjectManagerProject *project;
gboolean finished = FALSE;
gchar *project_root;
GtkListStore* list;
@@ -675,12 +670,8 @@ gbf_project_util_add_source_multi (GbfProjectModel *model,
GList* new_sources = NULL;
GList* uri_node;
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (project != NULL, NULL);
- project = gbf_project_model_get_project (model);
- if (!project)
- return NULL;
-
gui = load_interface ("add_source_dialog");
g_return_val_if_fail (gui != NULL, NULL);
@@ -735,7 +726,7 @@ gbf_project_util_add_source_multi (GbfProjectModel *model,
g_object_set_data_full (G_OBJECT (browse_button), "root",
project_root, g_free);
- setup_targets_treeview (model, targets_view, default_target);
+ setup_targets_treeview (project, targets_view, default_target);
gtk_widget_show (targets_view);
if (parent) {
@@ -896,7 +887,7 @@ on_cursor_changed(GtkTreeView* view, gpointer data)
}
GList*
-gbf_project_util_add_module (GbfProjectModel *model,
+gbf_project_util_add_module (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
const gchar *default_module)
@@ -907,17 +898,12 @@ gbf_project_util_add_module (GbfProjectModel *model,
GtkWidget *targets_view;
GtkWidget *modules_view;
gint response;
- ProjectManagerProject *project;
gboolean finished = FALSE;
GList* new_modules = NULL;
GtkTreeSelection *module_selection;
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (project != NULL, NULL);
- project = gbf_project_model_get_project (model);
- if (!project)
- return NULL;
-
gui = load_interface ("add_module_dialog");
g_return_val_if_fail (gui != NULL, NULL);
@@ -928,9 +914,9 @@ gbf_project_util_add_module (GbfProjectModel *model,
new_button = GTK_WIDGET (gtk_builder_get_object (gui, "new_package_button"));
ok_button = GTK_WIDGET (gtk_builder_get_object (gui, "ok_module_button"));
- setup_targets_treeview (model, targets_view, default_target);
+ setup_targets_treeview (project, targets_view, default_target);
gtk_widget_show (targets_view);
- setup_modules_treeview (model, modules_view, NULL);
+ setup_modules_treeview (project, modules_view, NULL);
gtk_widget_show (modules_view);
module_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (modules_view));
gtk_tree_selection_set_mode (module_selection, GTK_SELECTION_MULTIPLE);
@@ -964,7 +950,7 @@ gbf_project_util_add_module (GbfProjectModel *model,
switch (response) {
case 1:
{
- gbf_project_util_add_package (model, parent, NULL, NULL);
+ gbf_project_util_add_package (project, parent, NULL, NULL);
break;
}
@@ -1101,7 +1087,7 @@ on_changed_disconnect (GtkEditable* entry, gpointer data)
}
GList*
-gbf_project_util_add_package (GbfProjectModel *model,
+gbf_project_util_add_package (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_module,
GList *packages_to_add)
@@ -1116,19 +1102,15 @@ gbf_project_util_add_package (GbfProjectModel *model,
GList *packages = NULL;
GtkTreeViewColumn *col;
gint response;
- ProjectManagerProject *project;
gboolean finished = FALSE;
GtkTreeSelection *package_selection;
GtkTreeIter root;
gboolean valid;
gint default_pos = -1;
+ GbfProjectModel *model;
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (project != NULL, NULL);
- project = gbf_project_model_get_project (model);
- if (!project)
- return NULL;
-
gui = load_interface ("add_package_dialog");
g_return_val_if_fail (gui != NULL, NULL);
@@ -1142,6 +1124,7 @@ gbf_project_util_add_package (GbfProjectModel *model,
store = gtk_list_store_new(1, G_TYPE_STRING);
gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (module_entry), 0);
+ model = pm_project_get_model(project);
for (valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &root); valid != FALSE; valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &root))
{
GbfTreeData *data;
diff --git a/plugins/project-manager/gbf-project-util.h b/plugins/project-manager/gbf-project-util.h
index 94b8cc2..b3835fd 100644
--- a/plugins/project-manager/gbf-project-util.h
+++ b/plugins/project-manager/gbf-project-util.h
@@ -26,37 +26,37 @@
#include <glib.h>
#include <gtk/gtk.h>
#include <libanjuta/anjuta-project.h>
-#include "gbf-project-model.h"
+#include "project.h"
G_BEGIN_DECLS
-AnjutaProjectNode* gbf_project_util_new_group (GbfProjectModel *model,
+AnjutaProjectNode* gbf_project_util_new_group (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_group,
const gchar *default_group_name_to_add);
-AnjutaProjectNode* gbf_project_util_new_target (GbfProjectModel *model,
+AnjutaProjectNode* gbf_project_util_new_target (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_group,
const gchar *default_target_name_to_add);
-AnjutaProjectNode* gbf_project_util_add_source (GbfProjectModel *model,
+AnjutaProjectNode* gbf_project_util_add_source (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
const gchar *default_uri_to_add);
-GList* gbf_project_util_add_module (GbfProjectModel *model,
+GList* gbf_project_util_add_module (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
const gchar *default_module_name_to_add);
-GList* gbf_project_util_add_package (GbfProjectModel *model,
+GList* gbf_project_util_add_package (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_module,
GList *packages_to_add);
-GList* gbf_project_util_add_source_multi (GbfProjectModel *model,
+GList* gbf_project_util_add_source_multi (ProjectManagerProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
GList *uris_to_add);
diff --git a/plugins/project-manager/gbf-tree-data.c b/plugins/project-manager/gbf-tree-data.c
index 8d648b5..3748398 100644
--- a/plugins/project-manager/gbf-tree-data.c
+++ b/plugins/project-manager/gbf-tree-data.c
@@ -52,39 +52,6 @@
* the tree view.
*/
-AnjutaProjectNode *
-gbf_tree_data_get_node (GbfTreeData *data, ProjectManagerProject *project)
-{
- AnjutaProjectNode *node = NULL;
-
- if (data != NULL)
- {
- AnjutaProjectNode *root = NULL;
- AnjutaProjectNode *group = NULL;
- AnjutaProjectNode *target = NULL;
-
- root = pm_project_get_root (project);
- if ((root != NULL) && (data->group != NULL))
- {
- group = anjuta_project_group_get_node_from_file (root, data->group);
- node = group;
- }
-
- if ((group != NULL) && (data->target != NULL))
- {
- target = anjuta_project_target_get_node_from_name (group, data->target);
- node = target;
- }
-
- if (((group != NULL) || (target != NULL)) && (data->source != NULL))
- {
- node = anjuta_project_source_get_node_from_file (target != NULL ? target : group, data->source);
- }
- }
-
- return node;
-}
-
gchar *
gbf_tree_data_get_uri (GbfTreeData *data)
{
diff --git a/plugins/project-manager/gbf-tree-data.h b/plugins/project-manager/gbf-tree-data.h
index ad198d6..3b2a9d9 100644
--- a/plugins/project-manager/gbf-tree-data.h
+++ b/plugins/project-manager/gbf-tree-data.h
@@ -24,7 +24,6 @@
#include <glib-object.h>
#include <gtk/gtk.h>
-#include "project.h"
#include <libanjuta/anjuta-project.h>
G_BEGIN_DECLS
@@ -54,9 +53,6 @@ struct _GbfTreeData
GtkWidget *properties_dialog;
};
-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);
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index d0796dd..e642307 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -435,7 +435,7 @@ project_manager_show_node_properties_dialog (ProjectManagerPlugin *plugin,
{
case GBF_TREE_NODE_GROUP:
title = _("Group properties");
- node = gbf_tree_data_get_node (data, plugin->project);
+ node = pm_project_get_node (plugin->project, data);
if (node != NULL)
{
properties = pm_project_configure (plugin->project, node);
@@ -449,7 +449,7 @@ project_manager_show_node_properties_dialog (ProjectManagerPlugin *plugin,
break;
case GBF_TREE_NODE_TARGET:
title = _("Target properties");
- node = gbf_tree_data_get_node (data, plugin->project);
+ node = pm_project_get_node (plugin->project, data);
if (node != NULL)
{
properties = pm_project_configure (plugin->project, node);
@@ -566,7 +566,7 @@ on_add_package (GtkAction *action, ProjectManagerPlugin *plugin)
update_operation_begin (plugin);
gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_module);
- new_module = gbf_project_util_add_package (plugin->model,
+ new_module = gbf_project_util_add_package (plugin->project,
get_plugin_parent_window (plugin),
&selected_module, NULL);
update_operation_end (plugin, TRUE);
@@ -581,7 +581,7 @@ on_add_module (GtkAction *action, ProjectManagerPlugin *plugin)
update_operation_begin (plugin);
gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_target);
- new_modules = gbf_project_util_add_module (plugin->model,
+ new_modules = gbf_project_util_add_module (plugin->project,
get_plugin_parent_window (plugin),
&selected_target, NULL);
g_list_free (new_modules);
@@ -656,12 +656,12 @@ static void
on_popup_add_package (GtkAction *action, ProjectManagerPlugin *plugin)
{
GtkTreeIter selected_module;
- AnjutaProjectNode *module;
+ GList *packages;
update_operation_begin (plugin);
gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_module);
- module = gbf_project_util_add_package (plugin->model,
+ packages = gbf_project_util_add_package (plugin->project,
get_plugin_parent_window (plugin),
&selected_module, NULL);
update_operation_end (plugin, TRUE);
@@ -676,7 +676,7 @@ on_popup_add_module (GtkAction *action, ProjectManagerPlugin *plugin)
update_operation_begin (plugin);
gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_target);
- new_modules = gbf_project_util_add_module (plugin->model,
+ new_modules = gbf_project_util_add_module (plugin->project,
get_plugin_parent_window (plugin),
&selected_target, NULL);
g_list_free (new_modules);
@@ -692,7 +692,7 @@ on_popup_add_group (GtkAction *action, ProjectManagerPlugin *plugin)
update_operation_begin (plugin);
gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_group);
- new_group = gbf_project_util_new_group (plugin->model,
+ new_group = gbf_project_util_new_group (plugin->project,
get_plugin_parent_window (plugin),
&selected_group, NULL);
update_operation_end (plugin, TRUE);
@@ -707,7 +707,7 @@ on_popup_add_target (GtkAction *action, ProjectManagerPlugin *plugin)
update_operation_begin (plugin);
gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_group);
- new_target = gbf_project_util_new_target (plugin->model,
+ new_target = gbf_project_util_new_target (plugin->project,
get_plugin_parent_window (plugin),
&selected_group, NULL);
@@ -723,7 +723,7 @@ on_popup_add_source (GtkAction *action, ProjectManagerPlugin *plugin)
update_operation_begin (plugin);
gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_target);
- new_source = gbf_project_util_add_source (plugin->model,
+ new_source = gbf_project_util_add_source (plugin->project,
get_plugin_parent_window (plugin),
&selected_target, NULL);
@@ -834,14 +834,13 @@ on_popup_remove (GtkAction *action, ProjectManagerPlugin *plugin)
{
GbfTreeData *data = (GbfTreeData *)(item->data);
AnjutaProjectNode *node;
- GtkTreeIter iter;
switch (data->type)
{
case GBF_TREE_NODE_GROUP:
case GBF_TREE_NODE_TARGET:
case GBF_TREE_NODE_SOURCE:
- node = gbf_tree_data_get_node(data, plugin->project);
+ node = pm_project_get_node(plugin->project, data);
if (node != NULL)
{
if (!update) update_operation_begin (plugin);
@@ -862,10 +861,7 @@ on_popup_remove (GtkAction *action, ProjectManagerPlugin *plugin)
}
break;
case GBF_TREE_NODE_SHORTCUT:
- if (gbf_project_model_find_tree_data (plugin->model, &iter, data))
- {
- gbf_project_model_remove (plugin->model, &iter);
- }
+ pm_project_remove_data (plugin->project, data, NULL);
break;
default:
break;
@@ -1418,8 +1414,6 @@ project_manager_load_gbf (ProjectManagerPlugin *pm_plugin)
}
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,
@@ -1505,7 +1499,6 @@ project_manager_unload_gbf (ProjectManagerPlugin *pm_plugin)
pm_plugin->properties_dialog = NULL;
/* Release project */
- 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,
@@ -1609,7 +1602,6 @@ project_manager_plugin_activate_plugin (AnjutaPlugin *plugin)
{
AnjutaProfileManager *profile_manager;
GtkWidget *view, *scrolled_window;
- GbfProjectModel *model;
static gboolean initialized = FALSE;
GtkTreeSelection *selection;
/* GladeXML *gxml; */
@@ -1628,11 +1620,10 @@ project_manager_plugin_activate_plugin (AnjutaPlugin *plugin)
pm_plugin->project = pm_project_new (plugin);
/* create model & view and bind them */
- model = gbf_project_model_new (NULL);
view = gbf_project_view_new ();
gtk_tree_view_set_model (GTK_TREE_VIEW (view),
- GTK_TREE_MODEL (model));
+ GTK_TREE_MODEL (pm_project_get_model (pm_plugin->project)));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
@@ -1661,7 +1652,6 @@ project_manager_plugin_activate_plugin (AnjutaPlugin *plugin)
pm_plugin->scrolledwindow = scrolled_window;
pm_plugin->view = view;
- pm_plugin->model = model;
pm_plugin->properties_dialog = NULL;
/* Action groups */
@@ -1767,8 +1757,6 @@ project_manager_plugin_deactivate_plugin (AnjutaPlugin *plugin)
anjuta_plugin_remove_watch (plugin, pm_plugin->fm_watch_id, TRUE);
anjuta_plugin_remove_watch (plugin, pm_plugin->editor_watch_id, TRUE);
- g_object_unref (G_OBJECT (pm_plugin->model));
-
/* Widget is removed from the shell when destroyed */
gtk_widget_destroy (pm_plugin->scrolledwindow);
@@ -1804,7 +1792,6 @@ project_manager_plugin_instance_init (GObject *obj)
plugin->scrolledwindow = NULL;
plugin->project = NULL;
plugin->view = NULL;
- plugin->model = NULL;
plugin->pre_update_sources = NULL;
plugin->pre_update_targets = NULL;
plugin->pre_update_groups = NULL;
@@ -1944,7 +1931,7 @@ get_project_node_from_file (ProjectManagerPlugin *plugin, GFile *file, AnjutaPro
break;
}
- node = gbf_tree_data_get_node (data, plugin->project);
+ node = pm_project_get_node (plugin->project, data);
gbf_tree_data_free (data);
return node;
@@ -1957,7 +1944,7 @@ get_tree_iter_from_file (ProjectManagerPlugin *plugin, GtkTreeIter* iter, GFile
gboolean found;
data = gbf_tree_data_new_for_file (file, type);
- found = gbf_project_model_find_tree_data (plugin->model, iter, data);
+ found = gbf_project_model_find_tree_data (pm_project_get_model (plugin->project), iter, data);
gbf_tree_data_free (data);
return found ? iter : NULL;
@@ -2160,7 +2147,7 @@ iproject_manager_add_source (IAnjutaProjectManager *project_manager,
{
iter = get_tree_iter_from_file (plugin, &target_iter, default_target_file, GBF_TREE_NODE_TARGET);
}
- source_id = gbf_project_util_add_source (plugin->model,
+ source_id = gbf_project_util_add_source (plugin->project,
get_plugin_parent_window (plugin),
iter,
source_uri_to_add);
@@ -2221,7 +2208,7 @@ iproject_manager_add_source_multi (IAnjutaProjectManager *project_manager,
iter = get_tree_iter_from_file (plugin, &target_iter, default_target_file, GBF_TREE_NODE_TARGET);
}
- source_ids = gbf_project_util_add_source_multi (plugin->model,
+ source_ids = gbf_project_util_add_source_multi (plugin->project,
get_plugin_parent_window (plugin),
iter,
source_add_uris);
@@ -2261,7 +2248,7 @@ iproject_manager_add_target (IAnjutaProjectManager *project_manager,
}
update_operation_begin (plugin);
- target_id = gbf_project_util_new_target (plugin->model,
+ target_id = gbf_project_util_new_target (plugin->project,
get_plugin_parent_window (plugin),
iter,
target_name_to_add);
@@ -2293,7 +2280,7 @@ iproject_manager_add_group (IAnjutaProjectManager *project_manager,
}
update_operation_begin (plugin);
- group_id = gbf_project_util_new_group (plugin->model,
+ group_id = gbf_project_util_new_group (plugin->project,
get_plugin_parent_window (plugin),
iter,
group_name_to_add);
diff --git a/plugins/project-manager/plugin.h b/plugins/project-manager/plugin.h
index 4ff0854..e3ebc10 100644
--- a/plugins/project-manager/plugin.h
+++ b/plugins/project-manager/plugin.h
@@ -47,7 +47,6 @@ struct _ProjectManagerPlugin{
AnjutaUI *ui;
AnjutaPreferences *prefs;
GtkWidget *view;
- GbfProjectModel *model;
GtkWidget *scrolledwindow;
GtkActionGroup *pm_action_group;
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index b68ae77..8587450 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -35,38 +35,8 @@
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
@@ -161,6 +131,10 @@ pm_project_load (ProjectManagerProject *project, GFile *file, GError **error)
g_object_unref (project->project);
project->project = NULL;
}
+ else
+ {
+ g_object_set (G_OBJECT (project->model), "project", project, NULL);
+ }
return ok;
}
@@ -168,6 +142,7 @@ pm_project_load (ProjectManagerProject *project, GFile *file, GError **error)
gboolean
pm_project_unload (ProjectManagerProject *project, GError **error)
{
+ g_object_set (G_OBJECT (project->model), "project", NULL, NULL);
g_object_unref (project->project);
project->project = NULL;
@@ -199,14 +174,6 @@ pm_project_configure (ProjectManagerProject *project, AnjutaProjectNode *node)
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)
{
@@ -271,6 +238,32 @@ pm_project_add_source (ProjectManagerProject *project, AnjutaProjectNode *target
}
gboolean
+pm_project_remove (ProjectManagerProject *project, AnjutaProjectNode *node, GError **error)
+{
+ ianjuta_project_remove_node (project->project, node, error);
+
+ return TRUE;
+}
+
+gboolean
+pm_project_remove_data (ProjectManagerProject *project, GbfTreeData *data, GError **error)
+{
+ GtkTreeIter iter;
+
+ if (gbf_project_model_find_tree_data (project->model, &iter, data))
+ {
+ gbf_project_model_remove (project->model, &iter);
+
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+
+gboolean
pm_project_is_open (ProjectManagerProject *project)
{
return project->project != NULL;
@@ -282,6 +275,46 @@ pm_project_get_project (ProjectManagerProject *project)
return project->project;
}
+GbfProjectModel *
+pm_project_get_model (ProjectManagerProject *project)
+{
+ return project->model;
+}
+
+AnjutaProjectNode *
+pm_project_get_node (ProjectManagerProject *project, GbfTreeData *data)
+{
+ AnjutaProjectNode *node = NULL;
+
+ if (data != NULL)
+ {
+ AnjutaProjectNode *root = NULL;
+ AnjutaProjectNode *group = NULL;
+ AnjutaProjectNode *target = NULL;
+
+ root = pm_project_get_root (project);
+ if ((root != NULL) && (data->group != NULL))
+ {
+ group = anjuta_project_group_get_node_from_file (root, data->group);
+ node = group;
+ }
+
+ if ((group != NULL) && (data->target != NULL))
+ {
+ target = anjuta_project_target_get_node_from_name (group, data->target);
+ node = target;
+ }
+
+ if (((group != NULL) || (target != NULL)) && (data->source != NULL))
+ {
+ node = anjuta_project_source_get_node_from_file (target != NULL ? target : group, data->source);
+ }
+ }
+
+ return node;
+}
+
+
/* Constructor & Destructor
*---------------------------------------------------------------------------*/
@@ -293,6 +326,7 @@ pm_project_new (AnjutaPlugin *plugin)
project = g_new0 (ProjectManagerProject, 1);
project->plugin = plugin;
project->project = NULL;
+ project->model = gbf_project_model_new (NULL);
return project;
}
@@ -300,4 +334,6 @@ pm_project_new (AnjutaPlugin *plugin)
void
pm_project_free (ProjectManagerProject* project)
{
+ g_object_unref (G_OBJECT (project->model));
+ g_free (project);
}
diff --git a/plugins/project-manager/project.h b/plugins/project-manager/project.h
index 20afbf5..4126177 100644
--- a/plugins/project-manager/project.h
+++ b/plugins/project-manager/project.h
@@ -28,9 +28,12 @@
#include <libanjuta/anjuta-project.h>
#include <libanjuta/interfaces/ianjuta-project.h>
+#include "gbf-project-model.h"
+#include "gbf-tree-data.h"
+
G_BEGIN_DECLS
-typedef struct _ProjectManagerProject ProjectManagerProject;
+//typedef struct _ProjectManagerProject ProjectManagerProject;
ProjectManagerProject* pm_project_new (AnjutaPlugin *plugin);
void pm_project_free (ProjectManagerProject* project);
@@ -38,19 +41,26 @@ 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_remove (ProjectManagerProject *project, AnjutaProjectNode *node, GError **error);
+gboolean pm_project_remove_data (ProjectManagerProject *project, GbfTreeData *data, GError **error);
gboolean pm_project_is_open (ProjectManagerProject *project);
IAnjutaProject *pm_project_get_project (ProjectManagerProject *project);
+GbfProjectModel *pm_project_get_model (ProjectManagerProject *project);
+
+AnjutaProjectNode *pm_project_get_node (ProjectManagerProject *project, GbfTreeData *data);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]