[anjuta/newproject] Implement add group for dir project (not completly working yet)
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] Implement add group for dir project (not completly working yet)
- Date: Wed, 5 May 2010 20:21:24 +0000 (UTC)
commit 689aabd1e37473e59badf575ba9c825f87f9e955
Author: Sébastien Granjoux <seb sfo free fr>
Date: Wed May 5 22:21:07 2010 +0200
Implement add group for dir project (not completly working yet)
libanjuta/anjuta-project.c | 87 +++++++++++++++++++++++++++++-
libanjuta/anjuta-project.h | 3 +
plugins/am-project/am-project.c | 1 -
plugins/dir-project/dir-project.c | 34 +++++++-----
plugins/project-manager/plugin.c | 2 -
plugins/project-manager/project-model.c | 14 -----
plugins/project-manager/project-util.c | 1 -
plugins/project-manager/project.c | 78 +++++++++++++++++-----------
8 files changed, 155 insertions(+), 65 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index a2549b2..b891903 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -301,6 +301,77 @@ anjuta_project_node_replace (AnjutaProjectNode *node, AnjutaProjectNode *replace
}
AnjutaProjectNode *
+anjuta_project_node_exchange (AnjutaProjectNode *node, AnjutaProjectNode *replacement)
+{
+ GNode *marker = g_node_new (NULL);
+ GNode *child;
+ GNode *sibling;
+ GNode *next;
+
+ if (node->parent != NULL)
+ {
+ g_node_insert_after (node->parent, node, marker);
+ g_node_unlink (node);
+ }
+ if (replacement->parent != NULL)
+ {
+ g_node_insert_after (replacement->parent, replacement, node);
+ g_node_unlink (replacement);
+ }
+ if (marker->parent != NULL)
+ {
+ g_node_insert_after (marker->parent, marker, replacement);
+ g_node_unlink (marker);
+ }
+ g_node_destroy (marker);
+
+ /* Move all children from node to replacement */
+ sibling = NULL;
+ for (child = g_node_first_child (node); child != NULL; child = next)
+ {
+ next = g_node_next_sibling (child);
+ g_node_unlink (child);
+ sibling = g_node_insert_after (replacement, sibling, child);
+ child = next;
+ }
+
+ /* Move all children from replacement to node */
+ child = g_node_next_sibling (sibling);
+ sibling = NULL;
+ for (; child != NULL; child = next)
+ {
+ next = g_node_next_sibling (child);
+ g_node_unlink (child);
+ sibling = g_node_insert_after (node, sibling, child);
+ child = next;
+ }
+
+ return replacement;
+}
+
+AnjutaProjectNode *
+anjuta_project_node_grab_children (AnjutaProjectNode *parent, AnjutaProjectNode *node)
+{
+ AnjutaProjectNode *child;
+ AnjutaProjectNode *sibling;
+
+ sibling = g_node_last_child (parent);
+
+ for (child = g_node_first_child (node); child != NULL;)
+ {
+ AnjutaProjectNode *remove;
+
+ remove = child;
+ child = g_node_next_sibling (child);
+ g_node_unlink (remove);
+ sibling = g_node_insert_after (parent, sibling, remove);
+ }
+
+ return parent;
+}
+
+
+AnjutaProjectNode *
anjuta_project_node_prepend (AnjutaProjectNode *parent, AnjutaProjectNode *node)
{
return g_node_prepend (parent, node);
@@ -749,9 +820,7 @@ anjuta_project_proxy_new (AnjutaProjectNode *node)
}
}
- /* Replace node */
- node->data = proxy;
- node = anjuta_project_node_replace (node, g_node_new (data));
+ node = g_node_new (proxy);
}
return node;
@@ -793,6 +862,18 @@ anjuta_project_proxy_unref (AnjutaProjectNode *node)
return node;
}
+AnjutaProjectNode *
+anjuta_project_proxy_exchange_data (AnjutaProjectNode *proxy, AnjutaProjectNode *node)
+{
+ AnjutaProjectNodeData *data;
+
+ data = proxy->data;
+ proxy->data = node->data;
+ node->data = data;
+
+ return proxy;
+}
+
gboolean
anjuta_project_node_is_proxy (AnjutaProjectNode *node)
{
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index 8d5b1e9..7f67f57 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -167,6 +167,8 @@ AnjutaProjectNode *anjuta_project_node_prepend (AnjutaProjectNode *parent, Anjut
AnjutaProjectNode *anjuta_project_node_insert_before (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_node_insert_after (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_node_replace (AnjutaProjectNode *node, AnjutaProjectNode *replacement);
+AnjutaProjectNode *anjuta_project_node_grab_children (AnjutaProjectNode *parent, AnjutaProjectNode *node);
+AnjutaProjectNode *anjuta_project_node_exchange (AnjutaProjectNode *node, AnjutaProjectNode *replacement);
void anjuta_project_node_all_foreach (AnjutaProjectNode *node, AnjutaProjectNodeFunc func, gpointer data);
void anjuta_project_node_children_foreach (AnjutaProjectNode *node, AnjutaProjectNodeFunc func, gpointer data);
@@ -206,6 +208,7 @@ AnjutaProjectNodeType anjuta_project_node_info_type (const AnjutaProjectNodeInfo
AnjutaProjectNode *anjuta_project_proxy_new (AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_proxy_unref (AnjutaProjectNode *node);
+AnjutaProjectNode *anjuta_project_proxy_exchange_data (AnjutaProjectNode *proxy, AnjutaProjectNode *node);
gboolean anjuta_project_node_is_proxy (AnjutaProjectNode *node);
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 7010c82..d17badd 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -2476,7 +2476,6 @@ amp_project_add_sibling_target (AmpProject *project, AmpGroup *parent, const gc
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (parent != NULL, NULL);
- g_message ("add sibling target %x", type);
info = (AmpNodeInfo *)amp_project_get_type_info (project, type);
/* Validate target name */
diff --git a/plugins/dir-project/dir-project.c b/plugins/dir-project/dir-project.c
index 29c46d9..b0955f7 100644
--- a/plugins/dir-project/dir-project.c
+++ b/plugins/dir-project/dir-project.c
@@ -146,15 +146,17 @@ on_file_changed (GFileMonitor *monitor,
{
AnjutaProjectNode *node = data;
- g_message ("on_file_changed %s type %d emitter %p node %p proxy %d", g_file_get_path (file), event_type, DIR_GROUP_DATA (node)->emitter, node, NODE_DATA (node)->type & ANJUTA_PROJECT_PROXY);
- switch (event_type) {
- case G_FILE_MONITOR_EVENT_CHANGED:
- case G_FILE_MONITOR_EVENT_DELETED:
- case G_FILE_MONITOR_EVENT_CREATED:
- g_signal_emit_by_name (DIR_GROUP_DATA (node)->emitter, "node-updated", node);
- break;
- default:
- break;
+ if (!anjuta_project_node_is_proxy (node))
+ {
+ switch (event_type) {
+ case G_FILE_MONITOR_EVENT_CHANGED:
+ case G_FILE_MONITOR_EVENT_DELETED:
+ case G_FILE_MONITOR_EVENT_CREATED:
+ g_signal_emit_by_name (DIR_GROUP_DATA (node)->emitter, "node-updated", node);
+ break;
+ default:
+ break;
+ }
}
}
@@ -219,7 +221,6 @@ dir_group_new (GFile *file, GObject *emitter)
G_CALLBACK (on_file_changed),
node);
}
- g_message ("new group %p monitor %p", node, group->monitor);
return node;
}
@@ -232,7 +233,7 @@ dir_group_free (DirGroup *node)
if (group->monitor != NULL) g_file_monitor_cancel (group->monitor);
if (group->base.file) g_object_unref (group->base.file);
g_slice_free (DirGroupData, group);
- g_message ("free group %p monitor %p", node, group->monitor);
+ //g_message ("free group %p monitor %p", node, group->monitor);
g_node_destroy (node);
}
@@ -284,7 +285,7 @@ foreach_node_destroy (AnjutaProjectNode *node,
{
gint type = NODE_DATA (node)->type;
- g_message ("dir free node %p", node);
+ //g_message ("dir free node %p", node);
switch (type & ANJUTA_PROJECT_TYPE_MASK)
{
case ANJUTA_PROJECT_GROUP:
@@ -357,8 +358,13 @@ project_node_new (DirProject *project, AnjutaProjectNode *parent, AnjutaProjectN
g_assert_not_reached ();
break;
}
- if (node != NULL) NODE_DATA (node)->type = type;
- g_message ("dir new node %p type %x", node, type);
+ if (node != NULL)
+ {
+ NODE_DATA (node)->type = type;
+ node->parent = parent;
+ }
+
+ //g_message ("dir new node %p type %x", node, type);
return node;
}
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index 580f2d7..7c5bdf6 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -1011,7 +1011,6 @@ on_treeview_selection_changed (GtkTreeSelection *sel,
ANJUTA_PROJECT_UNKNOWN);
state = node != NULL ? anjuta_project_node_get_state (node) : 0;
- g_message ("state %x", state);
/* Popup menu */
action = anjuta_ui_get_action (ui, "ActionGroupProjectManagerPopup",
"ActionPopupProjectAddGroup");
@@ -1365,7 +1364,6 @@ project_manager_load_gbf (ProjectManagerPlugin *pm_plugin)
DEBUG_PRINT ("loading project %s\n\n", dirname);
anjuta_pm_project_load (pm_plugin->project, dirfile, &error);
- g_message ("try loading %s %p", dirname, error);
g_free (basename);
g_free (dirname);
diff --git a/plugins/project-manager/project-model.c b/plugins/project-manager/project-model.c
index 9ef94a7..6ad090c 100644
--- a/plugins/project-manager/project-model.c
+++ b/plugins/project-manager/project-model.c
@@ -743,20 +743,8 @@ gbf_project_model_update_tree (GbfProjectModel *model, AnjutaProjectNode *parent
GList *node;
GList *nodes;
- /* Update parent */
- if (iter != NULL)
- {
- GbfTreeData *data = NULL;
-
- gtk_tree_model_get (GTK_TREE_MODEL (model), iter,
- GBF_PROJECT_MODEL_COLUMN_DATA, &data,
- -1);
- gbf_tree_data_replace_node (data, parent);
- }
-
/* Get all new nodes */
nodes = gbf_project_util_all_child (parent, ANJUTA_PROJECT_UNKNOWN);
- g_message ("gbf_project_model_update_tree %p", nodes);
/* walk the tree nodes */
if (gtk_tree_model_iter_children (GTK_TREE_MODEL (model), &child, iter))
@@ -806,11 +794,9 @@ gbf_project_model_update_tree (GbfProjectModel *model, AnjutaProjectNode *parent
/* add the remaining sources, targets and groups */
for (node = nodes; node; node = node->next)
{
- //g_message ("Add node %p type %x", node->data, anjuta_project_node_get_type (node->data));
switch (anjuta_project_node_get_type (node->data))
{
case ANJUTA_PROJECT_GROUP:
- //g_message ("Add group %p name %s", anjuta_project_node_get_name (node));
add_target_group (model, node->data, iter);
break;
case ANJUTA_PROJECT_TARGET:
diff --git a/plugins/project-manager/project-util.c b/plugins/project-manager/project-util.c
index e825732..732f00a 100644
--- a/plugins/project-manager/project-util.c
+++ b/plugins/project-manager/project-util.c
@@ -964,7 +964,6 @@ gbf_project_util_add_module (AnjutaPmProject *project,
while (!finished) {
response = gtk_dialog_run (GTK_DIALOG (dialog));
- g_message ("response %d", response);
switch (response) {
case 1:
{
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index 28fadd6..6ba12c3 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -204,7 +204,6 @@ pm_project_map_children (PmJob *job, AnjutaProjectNode *old_node, AnjutaProjectN
for (new_node = anjuta_project_node_first_child (new_node); new_node != NULL; new_node = anjuta_project_node_next_sibling (new_node))
{
children = g_list_prepend (children, new_node);
- g_message ("prepend %p", new_node);
}
children = g_list_reverse (children);
@@ -217,7 +216,6 @@ pm_project_map_children (PmJob *job, AnjutaProjectNode *old_node, AnjutaProjectN
if (same != NULL)
{
g_hash_table_insert (job->map, old_node, (AnjutaProjectNode *)same->data);
- g_message ("map %p->%p", old_node, same->data);
pm_project_map_children ((PmJob *)job, old_node, (AnjutaProjectNode *)same->data);
children = g_list_delete_link (children, same);
@@ -239,13 +237,9 @@ pm_project_map_node (PmJob *job)
old_node = job->node;
new_node = job->proxy;
- if (pm_project_compare_node (old_node, new_node) == 0)
- {
- g_hash_table_insert (job->map, old_node, new_node);
- g_message ("map %p->%p", old_node, new_node);
+ //g_hash_table_insert (job->map, old_node, new_node);
- pm_project_map_children (job, old_node, new_node);
- }
+ pm_project_map_children (job, old_node, new_node);
}
}
@@ -254,9 +248,8 @@ pm_command_load_work (AnjutaPmProject *project, PmJob *job)
{
AnjutaProjectNode *node;
- g_message ("thread load node %p", job->proxy);
+
node = ianjuta_project_load_node (project->project, job->proxy, &(job->error));
- g_message ("thread load node complete");
if (job->error == NULL)
{
pm_project_map_node (job);
@@ -279,7 +272,6 @@ static gboolean
pm_command_exit_work (AnjutaPmProject *project, PmJob *job)
{
g_return_val_if_fail (job != NULL, FALSE);
- g_return_val_if_fail (job->node != NULL, FALSE);
/* Push job in complete queue as g_thread_exit will stop the thread
* immediatly */
@@ -417,6 +409,7 @@ on_pm_project_load_incomplete (AnjutaProjectNode *node, AnjutaPmProject *project
{
project->incomplete_node++;
anjuta_project_node_set_state (node, ANJUTA_PROJECT_LOADING);
+ //g_message ("load incomplete %p", node);
pm_project_push_command (project, RELOAD, node);
}
}
@@ -428,24 +421,50 @@ pm_command_load_setup (AnjutaPmProject *project, PmJob *job)
g_return_val_if_fail (job->node != NULL, FALSE);
job->proxy = anjuta_project_proxy_new (job->node);
+ anjuta_project_node_replace (job->node, job->proxy);
+ anjuta_project_proxy_exchange_data (job->node, job->proxy);
return TRUE;
}
+static void
+check_queue (GQueue *queue, GHashTable *map)
+{
+ guint i;
+
+ //g_message ("check queue size %d", g_queue_get_length (queue));
+ for (i = 0;; i++)
+ {
+ PmJob *job = (PmJob *)g_queue_peek_nth (queue, i);
+
+ if (job == NULL) break;
+ if (job->node != NULL)
+ {
+ AnjutaProjectNode *replace;
+
+ replace = (AnjutaProjectNode *)g_hash_table_lookup (map, job->node);
+ if (replace != NULL)
+ {
+ //g_message ("*** delete node %p used ***", job->node);
+ job->node = replace;
+ }
+ }
+ }
+}
+
static gboolean
pm_command_load_complete (AnjutaPmProject *project, PmJob *job)
{
+ anjuta_project_proxy_exchange_data (job->proxy, job->node);
+ anjuta_project_node_exchange (job->proxy, job->node);
+
if (job->error != NULL)
{
g_warning ("unable to load node");
- pm_project_stop_thread (project);
- g_object_unref (project->project);
- project->project = NULL;
- g_signal_emit (G_OBJECT (project), signals[LOADED], 0, job->error);
+ g_signal_emit (G_OBJECT (project), signals[job->command == LOAD ? LOADED : UPDATED], 0, job->error);
}
else
{
- g_message ("reloaded node");
if (job->command == LOAD)
{
g_object_set (G_OBJECT (project->model), "project", project, NULL);
@@ -454,9 +473,7 @@ pm_command_load_complete (AnjutaPmProject *project, PmJob *job)
if (project->root == job->node)
{
- project->root = job->proxy;
- g_message ("reload root");
- gbf_project_model_update_tree (project->model, job->proxy, NULL, job->map);
+ gbf_project_model_update_tree (project->model, job->node, NULL, job->map);
}
else
{
@@ -464,26 +481,28 @@ 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 %d", found);
- gbf_project_model_update_tree (project->model, job->proxy, &iter, job->map);
+ //g_message ("reload node %p found %d", job->node, found);
+ gbf_project_model_update_tree (project->model, job->node, &iter, job->map);
}
// Check for incompletely loaded object and load them
- if (anjuta_project_node_get_state (job->proxy) & ANJUTA_PROJECT_INCOMPLETE)
+ if (anjuta_project_node_get_state (job->node) & ANJUTA_PROJECT_INCOMPLETE)
{
project->incomplete_node--;
- g_message ("remaining node %d", project->incomplete_node);
+ //g_message ("remaining node %d", project->incomplete_node);
}
- anjuta_project_node_clear_state (job->proxy, ANJUTA_PROJECT_LOADING | ANJUTA_PROJECT_INCOMPLETE);
- anjuta_project_node_all_foreach (job->proxy, (AnjutaProjectNodeFunc)on_pm_project_load_incomplete, project);
+ anjuta_project_node_clear_state (job->node, ANJUTA_PROJECT_LOADING | ANJUTA_PROJECT_INCOMPLETE);
+ anjuta_project_node_all_foreach (job->node, (AnjutaProjectNodeFunc)on_pm_project_load_incomplete, project);
if (project->incomplete_node == 0)
{
g_signal_emit (G_OBJECT (project), signals[job->command == LOAD ? LOADED : UPDATED], 0, NULL);
}
+ check_queue (project->job_queue, job->map);
}
- anjuta_project_node_all_foreach (job->node, (AnjutaProjectNodeFunc)pm_free_node, project->project);
+
+ anjuta_project_node_all_foreach (job->proxy, (AnjutaProjectNodeFunc)pm_free_node, project->project);
return TRUE;
}
@@ -499,7 +518,7 @@ pm_command_add_setup (AnjutaPmProject *project, PmJob *job)
/* Add new node in project tree.
* It is safe to do it here because the worker thread is waiting */
parent = anjuta_project_node_parent (job->node);
- g_message ("parent %p node name %s", parent, anjuta_project_node_get_name (job->node));
+ job->node->parent = NULL;
anjuta_project_node_insert_before (parent, NULL, job->node);
return TRUE;
@@ -604,7 +623,7 @@ pm_project_idle_func (AnjutaPmProject *project)
static void
on_node_updated (IAnjutaProject *sender, AnjutaProjectNode *node, AnjutaPmProject *project)
{
- g_message ("on node updated");
+ g_message ("on node updated %p", node);
pm_project_push_command (project, RELOAD, node);
}
@@ -690,7 +709,6 @@ anjuta_pm_project_load (AnjutaPmProject *project, GFile *file, GError **error)
{
return FALSE;
}
- g_message ("connect node-update %p", project->project);
g_signal_connect (G_OBJECT (project->project),
"node-updated",
G_CALLBACK (on_node_updated),
@@ -729,7 +747,7 @@ anjuta_pm_project_unload (AnjutaPmProject *project, GError **error)
gboolean
anjuta_pm_project_refresh (AnjutaPmProject *project, GError **error)
{
- g_message ("reload project");
+ //g_message ("reload project %p", project->root);
pm_project_push_command (project, RELOAD, project->root);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]