[anjuta] am-project: Enable additonal target properties in GUI



commit 057905be742901b59a27932c1499b0e82b905187
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sun Apr 17 19:42:53 2011 +0200

    am-project: Enable additonal target properties in GUI

 libanjuta/anjuta-token.c               |    1 +
 plugins/am-project/am-properties.c     |   62 ++++++++++----------
 plugins/am-project/am-writer.c         |   38 ++++++++++--
 plugins/am-project/tests/properties.at |   99 ++++++++++++++++++++++++++++++++
 4 files changed, 163 insertions(+), 37 deletions(-)
---
diff --git a/libanjuta/anjuta-token.c b/libanjuta/anjuta-token.c
index a2e0301..e069f70 100644
--- a/libanjuta/anjuta-token.c
+++ b/libanjuta/anjuta-token.c
@@ -1003,6 +1003,7 @@ anjuta_token_merge (AnjutaToken *first, AnjutaToken *end)
 		anjuta_token_insert_before (end, first);
 	}
 	first->last = end;
+	if ((end->group != NULL) && (end->group != first) && (end->group->last == end)) end->group->last = first;
 	end->group = first;
 
 	return first;
diff --git a/plugins/am-project/am-properties.c b/plugins/am-project/am-properties.c
index 26f995f..db616f9 100644
--- a/plugins/am-project/am-properties.c
+++ b/plugins/am-project/am-properties.c
@@ -356,7 +356,7 @@ static AmpProperty AmpProgramTargetProperties[] = {
 	{
 		{N_("Do not install:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Build but do not install the target."),
 			"0"},
 		AM_TOKEN__PROGRAMS,	 3, "noinst_",
@@ -365,7 +365,7 @@ static AmpProperty AmpProgramTargetProperties[] = {
 	{
 		{N_("Installation directory:"),
 			ANJUTA_PROJECT_PROPERTY_STRING,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("It has to be a standard directory or a custom one defined in group properties.")},
 		AM_TOKEN__PROGRAMS, 	6, "bin_",
 		AM_PROPERTY_IN_MAKEFILE | AM_PROPERTY_DIRECTORY
@@ -469,7 +469,7 @@ static AmpProperty AmpProgramTargetProperties[] = {
 	{
 		{N_("Include in distribution:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Include this target in the distributed package."),
 			"1"},
 		AM_TOKEN__PROGRAMS, 	2, "nodist_",
@@ -478,7 +478,7 @@ static AmpProperty AmpProgramTargetProperties[] = {
 	{
 		{N_("Build for check only:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Build this target only when running automatic tests."),
 			"0"},
 		AM_TOKEN__PROGRAMS, 	4, 	"check_",
@@ -487,7 +487,7 @@ static AmpProperty AmpProgramTargetProperties[] = {
 	{
 		{N_("Do not use prefix:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Do not rename the target with an optional prefix, used to avoid overwritting system program. "),
 			"0"},
 		AM_TOKEN__PROGRAMS, 	1, "notrans_",
@@ -496,7 +496,7 @@ static AmpProperty AmpProgramTargetProperties[] = {
 	{
 		{N_("Keep target path:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY, 
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE, 
 			N_("Keep relative target path for installing it. "
 			   "By example if you have a program subdir/app installed in bin directory it will be installed in bin/subdir/app not in bin/app."),
 			"0"},
@@ -513,7 +513,7 @@ static AmpProperty AmpLibraryTargetProperties[] = {
 		{
 		{N_("Do not install:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Build but do not install the target."),
 			"0"},
 		AM_TOKEN__PROGRAMS,	 3, "noinst_",
@@ -522,7 +522,7 @@ static AmpProperty AmpLibraryTargetProperties[] = {
 	{
 		{N_("Installation directory:"),
 			ANJUTA_PROJECT_PROPERTY_STRING,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("It has to be a standard directory or a custom one defined in group properties.")},
 		AM_TOKEN__PROGRAMS, 	6, "lib",
 		AM_PROPERTY_IN_MAKEFILE | AM_PROPERTY_DIRECTORY
@@ -626,7 +626,7 @@ static AmpProperty AmpLibraryTargetProperties[] = {
 	{
 		{N_("Include in distribution:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Include this target in the distributed package."),
 			"1"},
 		AM_TOKEN__PROGRAMS, 	2, "nodist_",
@@ -635,7 +635,7 @@ static AmpProperty AmpLibraryTargetProperties[] = {
 	{
 		{N_("Build for check only:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Build this target only when running automatic tests."),
 			"0"},
 		AM_TOKEN__PROGRAMS, 	4, 	"check_",
@@ -644,7 +644,7 @@ static AmpProperty AmpLibraryTargetProperties[] = {
 	{
 		{N_("Do not use prefix:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Do not rename the target with an optional prefix, used to avoid overwritting system program. "),
 			"0"},
 		AM_TOKEN__PROGRAMS, 	1, "notrans_",
@@ -653,7 +653,7 @@ static AmpProperty AmpLibraryTargetProperties[] = {
 	{
 		{N_("Keep target path:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY, 
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE, 
 			N_("Keep relative target path for installing it. "
 			   "By example if you have a program subdir/app installed in bin directory it will be installed in bin/subdir/app not in bin/app."),
 			"0"},
@@ -678,7 +678,7 @@ static AmpProperty AmpManTargetProperties[] = {
 	{
 		{N_("Do not use prefix:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Do not rename the target with an optional prefix, used to avoid overwritting system program. "),
 			"0"},
 		AM_TOKEN__PROGRAMS,	1, "notrans_",
@@ -687,7 +687,7 @@ static AmpProperty AmpManTargetProperties[] = {
 	{
 		{N_("Manual section:"),
 			ANJUTA_PROJECT_PROPERTY_STRING,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Section where are installed the man pages. Valid section names are the digits â??0â?? through â??9â??, and the letters â??lâ?? and â??nâ??. ")},
 		AM_TOKEN__PROGRAMS,	 5, "man_",
 		AM_PROPERTY_IN_MAKEFILE
@@ -702,7 +702,7 @@ static AmpProperty AmpDataTargetProperties[] = {
 	{
 		{N_("Do not install:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Build but do not install the target."),
 			"0"},
 		AM_TOKEN__PROGRAMS,	 3, "noinst_",
@@ -711,7 +711,7 @@ static AmpProperty AmpDataTargetProperties[] = {
 	{
 		{N_("Installation directory:"),
 			ANJUTA_PROJECT_PROPERTY_STRING,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("It has to be a standard directory or a custom one defined in group properties.")},
 		AM_TOKEN__PROGRAMS, 	6, "data",
 		AM_PROPERTY_IN_MAKEFILE | AM_PROPERTY_DIRECTORY
@@ -727,7 +727,7 @@ static AmpProperty AmpDataTargetProperties[] = {
 	{
 		{N_("Include in distribution:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Include this target in the distributed package."),
 			"1"},
 		AM_TOKEN__PROGRAMS, 	2, "nodist_",
@@ -736,7 +736,7 @@ static AmpProperty AmpDataTargetProperties[] = {
 	{
 		{N_("Build for check only:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Build this target only when running automatic tests."),
 			"0"},
 		AM_TOKEN__PROGRAMS, 	4, 	"check_",
@@ -745,7 +745,7 @@ static AmpProperty AmpDataTargetProperties[] = {
 	{
 		{N_("Do not use prefix:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Do not rename the target with an optional prefix, used to avoid overwritting system program. "),
 			"0"},
 		AM_TOKEN__PROGRAMS, 	1, "notrans_",
@@ -754,7 +754,7 @@ static AmpProperty AmpDataTargetProperties[] = {
 	{
 		{N_("Keep target path:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY, 
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE, 
 			N_("Keep relative target path for installing it. "
 			   "By example if you have a program subdir/app installed in bin directory it will be installed in bin/subdir/app not in bin/app."),
 			"0"},
@@ -773,15 +773,15 @@ static AmpProperty AmpScriptTargetProperties[] = {
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
 			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
 			N_("Build but do not install the target.")},
-		AM_TOKEN__PROGRAMS,	 3, NULL,
+		AM_TOKEN__PROGRAMS,	 3, "noinst_",
 		AM_PROPERTY_IN_MAKEFILE
 	},
 	{
 		{N_("Installation directory:"),
 			ANJUTA_PROJECT_PROPERTY_STRING,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("It has to be a standard directory or a custom one defined in group properties.")},
-		AM_TOKEN__PROGRAMS, 	6, NULL,
+		AM_TOKEN__PROGRAMS, 	6, "bin",
 		AM_PROPERTY_IN_MAKEFILE
 	},
 	{
@@ -795,34 +795,34 @@ static AmpProperty AmpScriptTargetProperties[] = {
 	{
 		{N_("Include in distribution:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Include this target in the distributed package.")},
-		AM_TOKEN__PROGRAMS, 	2, NULL,
+		AM_TOKEN__PROGRAMS, 	2, "nodist_",
 		AM_PROPERTY_IN_MAKEFILE
 	},
 	{
 		{N_("Build for check only:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Build this target only when running automatic tests.")},
-		AM_TOKEN__PROGRAMS, 	4, 	NULL,
+		AM_TOKEN__PROGRAMS, 	4, 	"check_",
 		AM_PROPERTY_IN_MAKEFILE
 	},
 	{
 		{N_("Do not use prefix:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY,
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE,
 			N_("Do not rename the target with an optional prefix, used to avoid overwritting system program. ")},
-		AM_TOKEN__PROGRAMS, 	1, NULL,
+		AM_TOKEN__PROGRAMS, 	1, "notrans_",
 		AM_PROPERTY_IN_MAKEFILE
 	},
 	{
 		{N_("Keep target path:"),
 			ANJUTA_PROJECT_PROPERTY_BOOLEAN,
-			ANJUTA_PROJECT_PROPERTY_READ_ONLY, 
+			ANJUTA_PROJECT_PROPERTY_READ_WRITE, 
 			N_("Keep relative target path for installing it. "
 			   "By example if you have a program subdir/app installed in bin directory it will be installed in bin/subdir/app not in bin/app.")},
-		AM_TOKEN__PROGRAMS, 	0, NULL,
+		AM_TOKEN__PROGRAMS, 	0, "nobase_",
 		AM_PROPERTY_IN_MAKEFILE
 	},
 	{}
diff --git a/plugins/am-project/am-writer.c b/plugins/am-project/am-writer.c
index 9a6ce98..ba62a9c 100644
--- a/plugins/am-project/am-writer.c
+++ b/plugins/am-project/am-writer.c
@@ -726,7 +726,7 @@ amp_project_write_target (AmpGroupNode *group, gint type, const gchar *name, gbo
 		pos = anjuta_token_find_group_property_position (group, type);
 	}
 
-	pos = anjuta_token_insert_token_list (FALSE, pos,
+	pos = anjuta_token_insert_token_list (after, pos,
 	    		ANJUTA_TOKEN_LIST, NULL,
 	    		type, name,
 	    		ANJUTA_TOKEN_SPACE, " ",
@@ -736,7 +736,8 @@ amp_project_write_target (AmpGroupNode *group, gint type, const gchar *name, gbo
 	    		NULL);
 	pos = anjuta_token_last_item (pos);
 	amp_group_node_update_makefile (group, pos);
-	
+
+	/* Return list token */
 	return pos;
 }
 
@@ -1298,6 +1299,7 @@ amp_property_rename_target (AmpProject *project, AnjutaProjectNode *node)
 	GList *list;
 	AnjutaToken *update = NULL;
 	AnjutaToken *existing_target_list;
+	gboolean after;
 	const gchar *target_dir;
 
 	g_return_val_if_fail (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_TARGET, NULL);
@@ -1366,6 +1368,7 @@ amp_property_rename_target (AmpProject *project, AnjutaProjectNode *node)
 
 
     // Check if the target already exist.
+	after = TRUE; 
 	for (item = amp_group_node_get_token (AMP_GROUP_NODE (group), AM_GROUP_TARGET); item != NULL; item = g_list_next (item))
 	{
 		existing_target_list = (AnjutaToken *)item->data;
@@ -1375,6 +1378,30 @@ amp_property_rename_target (AmpProject *project, AnjutaProjectNode *node)
 		same = strcmp (target_name,  new_name->str) == 0;
 		g_free (target_name);
 
+		if (after)
+		{
+			GList *list;
+			GList *item;
+			
+			list = amp_target_node_get_token (AMP_TARGET_NODE (node), ANJUTA_TOKEN_ARGUMENT);
+			for (item = g_list_first (list); item != NULL; item = g_list_next (item))
+			{
+				AnjutaToken *arg = (AnjutaToken *)item->data;
+				AnjutaToken *target_list;
+
+				if (arg != NULL)
+				{
+					target_list = anjuta_token_list (arg);
+					if (anjuta_token_list (target_list) == existing_target_list)
+					{
+						/* token in group_node are stored in reverse order */
+						after = FALSE;
+						break;
+					}
+				}
+			}
+		}
+		
 		if (same)
 		{
 			existing_target_list = anjuta_token_last_item (existing_target_list);
@@ -1387,8 +1414,8 @@ amp_property_rename_target (AmpProject *project, AnjutaProjectNode *node)
 	{
 		amp_target_node_delete_token (project, AMP_TARGET_NODE (node), FALSE, NULL);
 			
-		/* Add target is already existing list */
-		amp_target_add_in_list (project, existing_target_list, node, TRUE, NULL);
+		/* Add target in already existing list */
+		amp_target_add_in_list (project, existing_target_list, node, after, NULL);
 	}
 	else
 	{
@@ -1458,7 +1485,7 @@ amp_property_rename_target (AmpProject *project, AnjutaProjectNode *node)
 				/* Add target in new list */
 				style = anjuta_token_style_new_from_base (project->am_space_list);
 				anjuta_token_style_update (style, target_list);
-		
+
 				info = (AmpNodeInfo *)amp_project_get_type_info (project, anjuta_project_node_get_full_type (node));
 				target_list = amp_project_write_target (AMP_GROUP_NODE (group), info->token, new_name->str, after, sibling);
 
@@ -1480,7 +1507,6 @@ amp_property_rename_target (AmpProject *project, AnjutaProjectNode *node)
 	}
 
 
-	
 	/* Add directory variable if needed */
 	target_dir = NULL;
 	for (item = anjuta_project_node_get_custom_properties (node); item != NULL; item = g_list_next (item))
diff --git a/plugins/am-project/tests/properties.at b/plugins/am-project/tests/properties.at
index 07662e3..c2be8af 100644
--- a/plugins/am-project/tests/properties.at
+++ b/plugins/am-project/tests/properties.at
@@ -471,4 +471,103 @@ AT_CHECK([diff -b output expect])
 
 
 
+AT_DATA([expect],
+[[    GROUP (): empty14
+        PROPERTY (Installation directories): progdir = plugindir = 
+        TARGET (): target1
+            PROPERTY (Installation directory): bindir
+            PROPERTY (Libraries): $(GDL_LIBS)
+            SOURCE (): source2
+        TARGET (): target2
+            PROPERTY (Installation directory): progdir
+            PROPERTY (Libraries): $(GDL_LIBS)
+            SOURCE (): source1
+        TARGET (): library1.la
+            PROPERTY (Installation directory): plugindir
+            PROPERTY (Libraries): $(GDL_LIBS)
+]])
+AT_DATA([reference.am],
+[[
+bin_PROGRAMS = target1
+
+progdir =
+prog_PROGRAMS = \
+	target2
+
+target1_SOURCES =  \
+	source2
+
+target1_LDADD = $(GDL_LIBS)
+
+target2_SOURCES =  \
+	source1
+
+target2_LDADD = $(GDL_LIBS)
+
+plugindir = 
+plugin_LTLIBRARIES =  \
+	library1.la
+
+library1_la_LIBADD = $(GDL_LIBS)
+]])
+AT_PARSER_CHECK([load empty13 \
+		move empty14 \
+		set 0:1 instdir 'progdir' \
+		list \
+		save])
+AT_CHECK([diff -b empty14/Makefile.am reference.am])
+AT_PARSER_CHECK([load empty14 \
+		 list])
+AT_CHECK([diff -b output expect])
+
+
+
+AT_DATA([expect],
+[[    GROUP (): empty15
+        PROPERTY (Installation directories): plugindir = 
+        TARGET (): target1
+            PROPERTY (Installation directory): bindir
+            PROPERTY (Libraries): $(GDL_LIBS)
+            SOURCE (): source2
+        TARGET (): target2
+            PROPERTY (Installation directory): bindir
+            PROPERTY (Libraries): $(GDL_LIBS)
+            SOURCE (): source1
+        TARGET (): library1.la
+            PROPERTY (Installation directory): plugindir
+            PROPERTY (Libraries): $(GDL_LIBS)
+]])
+AT_DATA([reference.am],
+[[
+bin_PROGRAMS = target1 \
+        target2
+
+target1_SOURCES =  \
+	source2
+
+target1_LDADD = $(GDL_LIBS)
+
+target2_SOURCES =  \
+	source1
+
+target2_LDADD = $(GDL_LIBS)
+
+plugindir = 
+plugin_LTLIBRARIES =  \
+	library1.la
+
+library1_la_LIBADD = $(GDL_LIBS)
+]])
+AT_PARSER_CHECK([load empty14 \
+		move empty15 \
+		set 0:1 instdir 'bindir' \
+		list \
+		save])
+AT_CHECK([diff -b empty15/Makefile.am reference.am])
+AT_PARSER_CHECK([load empty15 \
+		 list])
+AT_CHECK([diff -b output expect])
+
+
+
 AT_CLEANUP



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