[anjuta] am-project: Relax naming rules when loadind project nodes from a file



commit aaab3bd934c92e3d6d32eb19900d044df85fdee5
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Tue Oct 18 20:59:06 2011 +0200

    am-project: Relax naming rules when loadind project nodes from a file

 plugins/am-project/am-project.c |   15 ++++++++-------
 plugins/am-project/amp-node.c   |    4 ++--
 plugins/am-project/amp-object.c |   11 ++++++-----
 plugins/am-project/amp-object.h |    4 ++--
 plugins/am-project/amp-source.c |   13 +++++++------
 plugins/am-project/amp-source.h |    4 ++--
 6 files changed, 27 insertions(+), 24 deletions(-)
---
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 5e59751..2d8c131 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -33,6 +33,7 @@
 #include "amp-group.h"
 #include "amp-target.h"
 #include "amp-source.h"
+#include "amp-object.h"
 #include "command-queue.h"
 
 #include <libanjuta/interfaces/ianjuta-project.h>
@@ -865,7 +866,7 @@ project_load_target (AmpProject *project, AnjutaProjectNode *parent, AnjutaToken
 		}
 
 		/* Create target */
-		target = amp_target_node_new_valid (value, info->base.type, install, flags, NULL);
+		target = amp_target_node_new (value, info->base.type, install, flags);
 		if (target != NULL)
 		{
 			amp_target_node_add_token (target, ANJUTA_TOKEN_ARGUMENT, arg);
@@ -1048,7 +1049,7 @@ project_load_sources (AmpProject *project, AnjutaProjectNode *group, AnjutaToken
 							obj_file = g_file_get_child (group_file, basename);
 							g_free (basename);
 							g_free (object_name);
-							object = amp_node_new_valid (group, ANJUTA_PROJECT_OBJECT | ANJUTA_PROJECT_PROJECT, obj_file, NULL, NULL);
+							object = amp_object_node_new (obj_file, ANJUTA_PROJECT_PROJECT);
 							g_object_unref (obj_file);
 							anjuta_project_node_append (parent, object);
 							parent = object;
@@ -1059,7 +1060,7 @@ project_load_sources (AmpProject *project, AnjutaProjectNode *group, AnjutaToken
 			}
 
 			/* Create source */
-			source = amp_node_new_valid (group, ANJUTA_PROJECT_SOURCE | ANJUTA_PROJECT_PROJECT, src_file, NULL, NULL);
+			source = amp_source_node_new (src_file, ANJUTA_PROJECT_PROJECT);
 			g_object_unref (src_file);
 			if (source != NULL)
 			{
@@ -1072,7 +1073,7 @@ project_load_sources (AmpProject *project, AnjutaProjectNode *group, AnjutaToken
 
 			g_free (value);
 		}
-		amp_target_changed (target);
+		amp_target_changed (AMP_TARGET_NODE (target));
 	}
 
 	g_object_unref (group_file);
@@ -1112,7 +1113,7 @@ project_load_data (AmpProject *project, AnjutaProjectNode *parent, AnjutaToken *
 	if ((gchar *)find == target_id)
 	{
 		/* Create target */
-		target = amp_target_node_new_valid (target_id, info->base.type, install, flags, NULL);
+		target = amp_target_node_new (target_id, info->base.type, install, flags);
 		if (target != NULL)
 		{
 			anjuta_project_node_append (parent, ANJUTA_PROJECT_NODE (target));
@@ -1142,7 +1143,7 @@ project_load_data (AmpProject *project, AnjutaProjectNode *parent, AnjutaToken *
 
 			/* Create source */
 			src_file = g_file_get_child (parent_file, value);
-			source = amp_node_new_valid (parent, ANJUTA_PROJECT_SOURCE | ANJUTA_PROJECT_PROJECT | data_flags, src_file, NULL, NULL);
+			source = amp_source_node_new (src_file, ANJUTA_PROJECT_PROJECT | data_flags);
 			g_object_unref (src_file);
 			if (source != NULL)
 			{
@@ -1317,7 +1318,7 @@ project_load_subdirs (AmpProject *project, AnjutaToken *list, AnjutaProjectNode
 			else
 			{
 				/* Create new group */
-				group = amp_group_node_new_valid (subdir, dist_only, NULL);
+				group = amp_group_node_new (subdir, dist_only);
 
 				/* Group can be NULL if the name is not valid */
 				if (group != NULL)
diff --git a/plugins/am-project/amp-node.c b/plugins/am-project/amp-node.c
index d725d65..67b94ae 100644
--- a/plugins/am-project/amp-node.c
+++ b/plugins/am-project/amp-node.c
@@ -73,7 +73,7 @@ amp_node_new_valid(AnjutaProjectNode *parent, AnjutaProjectNodeType type, GFile
 			node = ANJUTA_PROJECT_NODE (amp_target_node_new_valid (name, type, NULL, 0, error));
 			break;
 		case ANJUTA_PROJECT_OBJECT:
-			node = ANJUTA_PROJECT_NODE (amp_object_node_new_valid (file, error));
+			node = ANJUTA_PROJECT_NODE (amp_object_node_new_valid (file, type, error));
 			break;
 		case ANJUTA_PROJECT_SOURCE:
 			/* Look for parent */
@@ -126,7 +126,7 @@ amp_node_new_valid(AnjutaProjectNode *parent, AnjutaProjectNodeType type, GFile
 				}
 			}
 
-			node = ANJUTA_PROJECT_NODE (amp_source_node_new_valid (file, error));
+			node = ANJUTA_PROJECT_NODE (amp_source_node_new_valid (file, type, error));
 			break;
 		case ANJUTA_PROJECT_MODULE:
 			node = ANJUTA_PROJECT_NODE (amp_module_node_new_valid (name, error));
diff --git a/plugins/am-project/amp-object.c b/plugins/am-project/amp-object.c
index ad9f489..0476ce7 100644
--- a/plugins/am-project/amp-object.c
+++ b/plugins/am-project/amp-object.c
@@ -56,20 +56,21 @@ struct _AmpObjectNode {
  *---------------------------------------------------------------------------*/
 
 AnjutaProjectNode*
-amp_object_node_new (GFile *file)
+amp_object_node_new (GFile *file, AnjutaProjectNodeType type)
 {
 	AmpObjectNode *node = NULL;
 
 	node = g_object_new (AMP_TYPE_OBJECT_NODE, NULL);
 	node->base.file = g_object_ref (file);
+	node->base.type = ANJUTA_PROJECT_OBJECT | type;
 
 	return ANJUTA_PROJECT_NODE (node);
 }
 
 AnjutaProjectNode*
-amp_object_node_new_valid (GFile *file, GError **error)
+amp_object_node_new_valid (GFile *file, AnjutaProjectNodeType type, GError **error)
 {
-	return amp_object_node_new (file);
+	return amp_object_node_new (file, type);
 }
 
 void
@@ -135,13 +136,13 @@ amp_object_node_class_init (AmpObjectNodeClass *klass)
 {
 	GObjectClass* object_class = G_OBJECT_CLASS (klass);
 	AmpNodeClass* node_class;
-	
+
 	object_class->finalize = amp_object_node_finalize;
 
 	node_class = AMP_NODE_CLASS (klass);
 	node_class->update = amp_object_node_update;
 	node_class->write = amp_object_node_write;
-	node_class->erase = amp_object_node_erase;	
+	node_class->erase = amp_object_node_erase;
 }
 
 static void
diff --git a/plugins/am-project/amp-object.h b/plugins/am-project/amp-object.h
index deda26b..6b291e5 100644
--- a/plugins/am-project/amp-object.h
+++ b/plugins/am-project/amp-object.h
@@ -45,8 +45,8 @@ GType amp_object_node_get_type (void) G_GNUC_CONST;
 
 void amp_object_node_register (GTypeModule *module);
 
-AnjutaProjectNode* amp_object_node_new (GFile *file);
-AnjutaProjectNode* amp_object_node_new_valid (GFile *file, GError **error);
+AnjutaProjectNode* amp_object_node_new (GFile *file, AnjutaProjectNodeType type);
+AnjutaProjectNode* amp_object_node_new_valid (GFile *file, AnjutaProjectNodeType type, GError **error);
 
 void amp_object_node_free (AmpObjectNode *node);
 
diff --git a/plugins/am-project/amp-source.c b/plugins/am-project/amp-source.c
index e816a33..e9f3b6e 100644
--- a/plugins/am-project/amp-source.c
+++ b/plugins/am-project/amp-source.c
@@ -47,7 +47,7 @@
 
 struct _AmpSourceNode {
 	AnjutaProjectNode base;
-	AnjutaToken* token;	
+	AnjutaToken* token;
 };
 
 
@@ -75,20 +75,21 @@ amp_source_node_update_node (AmpSourceNode *node, AmpSourceNode *new_node)
 }
 
 AnjutaProjectNode*
-amp_source_node_new (GFile *file)
+amp_source_node_new (GFile *file, AnjutaProjectNodeType type)
 {
 	AmpSourceNode *node = NULL;
 
 	node = g_object_new (AMP_TYPE_SOURCE_NODE, NULL);
 	node->base.file = g_object_ref (file);
+	node->base.type = ANJUTA_PROJECT_SOURCE | type;
 
 	return ANJUTA_PROJECT_NODE (node);
 }
 
 AnjutaProjectNode*
-amp_source_node_new_valid (GFile *file, GError **error)
+amp_source_node_new_valid (GFile *file, AnjutaProjectNodeType type, GError **error)
 {
-	return amp_source_node_new (file);
+	return amp_source_node_new (file, type);
 }
 
 gboolean
@@ -166,13 +167,13 @@ amp_source_node_class_init (AmpSourceNodeClass *klass)
 {
 	GObjectClass* object_class = G_OBJECT_CLASS (klass);
 	AmpNodeClass* node_class;
-	
+
 	object_class->finalize = amp_source_node_finalize;
 
 	node_class = AMP_NODE_CLASS (klass);
 	node_class->update = amp_source_node_update;
 	node_class->write = amp_source_node_write;
-	node_class->erase = amp_source_node_erase;	
+	node_class->erase = amp_source_node_erase;
 }
 
 static void
diff --git a/plugins/am-project/amp-source.h b/plugins/am-project/amp-source.h
index 755ecb9..802a40d 100644
--- a/plugins/am-project/amp-source.h
+++ b/plugins/am-project/amp-source.h
@@ -45,8 +45,8 @@ GType amp_source_node_get_type (void) G_GNUC_CONST;
 
 void amp_source_node_register (GTypeModule *module);
 
-AnjutaProjectNode* amp_source_node_new (GFile *file);
-AnjutaProjectNode* amp_source_node_new_valid (GFile *file, GError **error);
+AnjutaProjectNode* amp_source_node_new (GFile *file, AnjutaProjectNodeType type);
+AnjutaProjectNode* amp_source_node_new_valid (GFile *file, AnjutaProjectNodeType type, GError **error);
 void amp_source_node_free (AmpSourceNode *node);
 AnjutaToken *amp_source_node_get_token (AmpSourceNode *node);
 void amp_source_node_add_token (AmpSourceNode *node, AnjutaToken *token);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]