[anjuta/newproject] pm: Update project view when reloading the project
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] pm: Update project view when reloading the project
- Date: Sun, 22 Aug 2010 12:48:47 +0000 (UTC)
commit 26a61ca9bd68384ea8c75ee8459a2977d689b30f
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Aug 22 14:45:37 2010 +0200
pm: Update project view when reloading the project
plugins/am-project/am-project.c | 50 +++++++++++++++++-----------
plugins/project-manager/project-model.c | 54 ++++++++++++++++++++++++++++++-
plugins/project-manager/project-model.h | 3 ++
plugins/project-manager/project.c | 9 +++--
4 files changed, 91 insertions(+), 25 deletions(-)
---
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 8e26187..2630be5 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -1991,7 +1991,7 @@ project_load_group_properties (AmpProject *project, AnjutaToken *token, AnjutaTo
return NULL;
}
-static AmpGroup* project_load_makefile (AmpProject *project, GFile *file, AmpGroup *parent, gboolean dist_only);
+static AmpGroup* project_load_makefile (AmpProject *project, AmpGroup *group);
static void
project_load_subdirs (AmpProject *project, AnjutaToken *list, AmpGroup *parent, gboolean dist_only)
@@ -2026,7 +2026,10 @@ project_load_subdirs (AmpProject *project, AnjutaToken *list, AmpGroup *parent,
else
{
/* Create new group */
- group = project_load_makefile (project, subdir, parent, dist_only);
+ group = amp_group_new (subdir, dist_only);
+ g_hash_table_insert (project->groups, g_file_get_uri (subdir), group);
+ anjuta_project_node_append (parent, group);
+ group = project_load_makefile (project, group);
}
amp_group_add_token (group, arg, dist_only ? AM_GROUP_TOKEN_DIST_SUBDIRS : AM_GROUP_TOKEN_SUBDIRS);
g_object_unref (subdir);
@@ -2046,25 +2049,13 @@ remove_config_file (gpointer data, GObject *object, gboolean is_last_ref)
}
static AmpGroup*
-project_load_makefile (AmpProject *project, GFile *file, AnjutaProjectNode *parent, gboolean dist_only)
+project_load_makefile (AmpProject *project, AmpGroup *group)
{
const gchar **filename;
- AmpGroup *group;
AnjutaTokenFile *tfile;
GFile *makefile = NULL;
+ GFile *file = anjuta_project_node_get_file ((AnjutaProjectNode *)group);
- /* Create group */
- if (parent != NULL)
- {
- group = amp_group_new (file, dist_only);
- g_hash_table_insert (project->groups, g_file_get_uri (file), group);
- anjuta_project_node_append (parent, group);
- }
- else
- {
- group = project->root_node;
- }
-
/* Find makefile name
* It has to be in the config_files list with .am extension */
for (filename = valid_am_makefiles; *filename != NULL; filename++)
@@ -2189,7 +2180,7 @@ amp_project_load_root (AmpProject *project, AnjutaProjectNode *node, GError **er
{
AmpAcScanner *scanner;
AnjutaToken *arg;
- AnjutaProjectNode *group;
+ AmpGroup *group;
GFile *root_file;
GFile *configure_file;
gboolean ok = TRUE;
@@ -2256,10 +2247,12 @@ amp_project_load_root (AmpProject *project, AnjutaProjectNode *node, GError **er
return NULL;
}
-// monitors_setup (project);
-
/* Load all makefiles recursively */
- if (project_load_makefile (project, project->root_file, node, FALSE) == NULL)
+ group = amp_group_new (root_file, FALSE);
+ g_hash_table_insert (project->groups, g_file_get_uri (root_file), group);
+ anjuta_project_node_append (node, group);
+
+ if (project_load_makefile (project, group) == NULL)
{
g_set_error (error, IANJUTA_PROJECT_ERROR,
IANJUTA_PROJECT_ERROR_DOESNT_EXIST,
@@ -2365,6 +2358,21 @@ amp_project_load_package (AmpProject *project, AnjutaProjectNode *node, GError *
return node;
}
+static AnjutaProjectNode *
+amp_project_load_group (AmpProject *project, AnjutaProjectNode *node, GError **error)
+{
+ if (project_load_makefile (project, node) == NULL)
+ {
+ g_set_error (error, IANJUTA_PROJECT_ERROR,
+ IANJUTA_PROJECT_ERROR_DOESNT_EXIST,
+ _("Project doesn't exist or invalid path"));
+
+ return NULL;
+ }
+
+ return node;
+}
+
AnjutaProjectNode *
amp_project_load_node (AmpProject *project, AnjutaProjectNode *node, GError **error)
{
@@ -2374,6 +2382,8 @@ amp_project_load_node (AmpProject *project, AnjutaProjectNode *node, GError **er
return amp_project_load_root (project, node, error);
case ANJUTA_PROJECT_PACKAGE:
return amp_project_load_package (project, node, error);
+ case ANJUTA_PROJECT_GROUP:
+ return amp_project_load_group (project, node, error);
default:
return NULL;
}
diff --git a/plugins/project-manager/project-model.c b/plugins/project-manager/project-model.c
index b941c83..6d4120b 100644
--- a/plugins/project-manager/project-model.c
+++ b/plugins/project-manager/project-model.c
@@ -844,6 +844,58 @@ recursive_find_tree_data (GtkTreeModel *model,
}
void
+gbf_project_model_update_shortcut (GbfProjectModel *model, GtkTreeIter *iter, GHashTable *map)
+{
+ GtkTreeIter child;
+ gboolean valid;
+
+ /* Get all children */
+ valid = gtk_tree_model_iter_children (GTK_TREE_MODEL (model), &child, iter);
+
+ while (valid)
+ {
+ GbfTreeData *data;
+ AnjutaProjectNode* new_node = NULL;
+ AnjutaProjectNode* old_node = NULL;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (model), &child,
+ GBF_PROJECT_MODEL_COLUMN_DATA, &data,
+ -1);
+
+ /* Shortcuts are always at the beginning */
+ if ((iter == NULL) && (data->type != GBF_TREE_NODE_SHORTCUT)) break;
+
+ old_node = gbf_tree_data_get_node (data);
+ if (g_hash_table_lookup_extended (map, old_node, NULL, &new_node))
+ {
+ /* Find node */
+ if (new_node != NULL)
+ {
+ /* Node has been changed */
+ gbf_tree_data_replace_node (data, new_node);
+
+ /* update recursively */
+ gbf_project_model_update_tree (model, new_node, &child, map);
+
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &child);
+ }
+ else
+ {
+ /* Node has been removed */
+ valid = gbf_project_model_remove (model, &child);
+ }
+ }
+ else
+ {
+ /* Node has not changed */
+ gbf_project_model_update_shortcut (model, &child, map);
+
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &child);
+ }
+ }
+}
+
+void
gbf_project_model_update_tree (GbfProjectModel *model, AnjutaProjectNode *parent, GtkTreeIter *iter, GHashTable *map)
{
GtkTreeIter child;
@@ -861,11 +913,11 @@ gbf_project_model_update_tree (GbfProjectModel *model, AnjutaProjectNode *parent
while (valid) {
GbfTreeData *data = NULL;
AnjutaProjectNode* new_node = NULL;
+ AnjutaProjectNode* old_node = NULL;
if (map != NULL)
{
/* Look for old node */
- AnjutaProjectNode* old_node;
gtk_tree_model_get (GTK_TREE_MODEL (model), &child,
GBF_PROJECT_MODEL_COLUMN_DATA, &data,
diff --git a/plugins/project-manager/project-model.h b/plugins/project-manager/project-model.h
index e16cb68..1c179ba 100644
--- a/plugins/project-manager/project-model.h
+++ b/plugins/project-manager/project-model.h
@@ -88,6 +88,9 @@ void gbf_project_model_update_tree (GbfProjectModel *model,
AnjutaProjectNode *parent,
GtkTreeIter *iter,
GHashTable *map);
+void gbf_project_model_update_shortcut (GbfProjectModel *model,
+ GtkTreeIter *iter,
+ GHashTable *map);
#endif
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index 779bf6d..c295ee4 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -247,8 +247,8 @@ pm_project_map_node (PmJob *job)
job->map = g_hash_table_new (g_direct_hash, NULL);
old_node = job->node;
new_node = job->proxy;
-
- //g_hash_table_insert (job->map, old_node, new_node);
+
+ g_hash_table_insert (job->map, old_node, new_node);
pm_project_map_children (job, old_node, new_node);
}
@@ -504,6 +504,7 @@ pm_command_load_complete (AnjutaPmProject *project, PmJob *job)
if (project->root == job->node)
{
gbf_project_model_update_tree (project->model, job->node, NULL, job->map);
+ gbf_project_model_update_shortcut (project->model, NULL, job->map);
}
else
{
@@ -511,8 +512,8 @@ pm_command_load_complete (AnjutaPmProject *project, PmJob *job)
gboolean found;
found = gbf_project_model_find_node (project->model, &iter, NULL, job->node);
- //g_message ("reload node %p found %d", job->node, found);
- gbf_project_model_update_tree (project->model, job->node, &iter, job->map);
+ gbf_project_model_update_tree (project->model, job->node, found ? &iter : NULL, job->map);
+ gbf_project_model_update_shortcut (project->model, NULL, job->map);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]