[anjuta/newproject] Fix issue with change on target types



commit 68d9b89e6be3b68981b4cb9c895a1cb1dcdd45d7
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sun Apr 25 23:17:18 2010 +0200

    Fix issue with change on target types

 libanjuta/anjuta-project.h               |   26 ++---------------
 plugins/am-project/am-project.c          |    8 +++---
 plugins/build-basic-autotools/executer.c |    2 +-
 plugins/debug-manager/start.c            |    4 +-
 plugins/project-manager/plugin.c         |   44 +++++++++++++++++++++++++-----
 plugins/project-manager/project-model.c  |    2 +-
 plugins/run-program/parameters.c         |    2 +-
 7 files changed, 49 insertions(+), 39 deletions(-)
---
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index df06b16..d4f5006 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -51,9 +51,11 @@ typedef enum
 	ANJUTA_PROJECT_MKENUMS,
 	ANJUTA_PROJECT_GENMARSHAL,
 	ANJUTA_PROJECT_SCRIPT,
-	ANJUTA_PROJECT_PROXY = 1 << 14,
+	ANJUTA_PROJECT_PROXY = 1 << 13,
+	ANJUTA_PROJECT_PRIMARY = 1 << 14,
 	ANJUTA_PROJECT_EXECUTABLE = 1 << 15,
 	ANJUTA_PROJECT_ID_MASK = 0xFFF,
+	ANJUTA_PROJECT_FLAG_MASK = 0x0F << 12,
 	ANJUTA_PROJECT_TYPE_MASK = 0xFFFF << 16,
 	ANJUTA_PROJECT_ROOT = 1 << 16,
 	ANJUTA_PROJECT_GROUP = 2 << 16,
@@ -79,28 +81,6 @@ typedef enum
 	ANJUTA_PROJECT_CAN_SAVE = 1 << 17
 } AnjutaProjectNodeState;
 
-typedef enum
-{
-	ANJUTA_TARGET_UNKNOWN,
-	ANJUTA_TARGET_SHAREDLIB,
-	ANJUTA_TARGET_STATICLIB,
-	ANJUTA_TARGET_EXECUTABLE,
-	ANJUTA_TARGET_PYTHON,
-	ANJUTA_TARGET_JAVA,
-	ANJUTA_TARGET_LISP,
-	ANJUTA_TARGET_HEADER,
-	ANJUTA_TARGET_MAN,
-	ANJUTA_TARGET_INFO,
-	ANJUTA_TARGET_GENERIC,
-	ANJUTA_TARGET_DATA,
-	ANJUTA_TARGET_EXTRA,
-	ANJUTA_TARGET_INTLTOOL,
-	ANJUTA_TARGET_CONFIGURE,
-	ANJUTA_TARGET_IDL,
-	ANJUTA_TARGET_MKENUMS,
-	ANJUTA_TARGET_GENMARSHAL
-} AnjutaProjectTargetClass;
-
 typedef struct 
 {
 	AnjutaProjectNodeType type;
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 75200a3..bc043b2 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -191,21 +191,21 @@ static AmpNodeInfo AmpNodeInformations[] = {
 	NULL,
 	NULL},
 
-	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_SHAREDLIB,
+	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_PRIMARY |  ANJUTA_PROJECT_SHAREDLIB,
 	N_("Shared Library"),
 	"application/x-sharedlib"},
 	AM_TOKEN__LTLIBRARIES,
 	"_LTLIBRARIES",
 	"lib"},
 	
-	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_STATICLIB,
+	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_PRIMARY |  ANJUTA_PROJECT_STATICLIB,
 	N_("Static Library"),
 	"application/x-archive"},
 	AM_TOKEN__LIBRARIES,
 	"_LIBRARIES",
 	"lib"},
 
-	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_EXECUTABLE | ANJUTA_PROJECT_BINARY,
+	{{ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_PRIMARY | ANJUTA_PROJECT_EXECUTABLE | ANJUTA_PROJECT_BINARY,
 	N_("Program"),
 	"application/x-executable"},
 	AM_TOKEN__PROGRAMS,
@@ -2510,7 +2510,7 @@ amp_project_add_sibling_target (AmpProject  *project, AmpGroup *parent, const gc
 			return NULL;
 		}
 	}
-	else if ((type & ANJUTA_PROJECT_ID_MASK) == ANJUTA_TARGET_STATICLIB) {
+	else if ((type & ANJUTA_PROJECT_ID_MASK) == ANJUTA_PROJECT_STATICLIB) {
 		if (strlen (name) < 6 ||
 		    strncmp (name, "lib", strlen("lib")) != 0 ||
 		    strcmp (&name[strlen(name) - 2], ".a") != 0) {
diff --git a/plugins/build-basic-autotools/executer.c b/plugins/build-basic-autotools/executer.c
index 14f569e..579c5ef 100644
--- a/plugins/build-basic-autotools/executer.c
+++ b/plugins/build-basic-autotools/executer.c
@@ -64,7 +64,7 @@ get_program_parameters (BasicAutotoolsPlugin *plugin,
 		g_return_val_if_fail (pm != NULL, FALSE);
 		exec_targets =
 		ianjuta_project_manager_get_targets (pm, 
-							ANJUTA_TARGET_EXECUTABLE,
+							ANJUTA_PROJECT_EXECUTABLE,
                             NULL);
 		if (!exec_targets)
 		{
diff --git a/plugins/debug-manager/start.c b/plugins/debug-manager/start.c
index e6a8775..682f505 100644
--- a/plugins/debug-manager/start.c
+++ b/plugins/debug-manager/start.c
@@ -209,11 +209,11 @@ get_source_directories (AnjutaPlugin *plugin)
 		{
 			slibs_dirs =
 				ianjuta_project_manager_get_targets (pm,
-					ANJUTA_TARGET_SHAREDLIB,
+					ANJUTA_PROJECT_SHAREDLIB,
 				    NULL);
 			libs_dirs =
 				ianjuta_project_manager_get_targets (pm,
-					ANJUTA_TARGET_STATICLIB,
+					ANJUTA_PROJECT_STATICLIB,
 				    NULL);
 		}
 	}
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index 3454c1d..b246d9e 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -1831,6 +1831,17 @@ iproject_manager_get_elements (IAnjutaProjectManager *project_manager,
 	plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
 
 	return gbf_project_util_replace_by_file (gbf_project_util_node_all (anjuta_pm_project_get_root (plugin->project), element_type)); 
+	/*GList *list;
+	GList *item;
+	
+	g_message ("get elements root %p", anjuta_pm_project_get_root (plugin->project));
+	list = gbf_project_util_replace_by_file (gbf_project_util_node_all (anjuta_pm_project_get_root (plugin->project), element_type)); 
+	for (item = g_list_first (list); item != NULL; item = g_list_next (item))
+	{
+		g_message ("get element type %d file %s", element_type, g_file_get_path ((GFile *)item->data));
+	}
+	
+	return list;*/
 }
 
 static AnjutaProjectNodeType
@@ -1842,12 +1853,12 @@ iproject_manager_get_target_type (IAnjutaProjectManager *project_manager,
 	AnjutaProjectNode *target;
 	
 	g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager),
-						  ANJUTA_TARGET_UNKNOWN);
+						  ANJUTA_PROJECT_UNKNOWN);
 	
 	plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
 	
 	g_return_val_if_fail (file_is_inside_project (plugin, target_file),
-						  ANJUTA_TARGET_UNKNOWN);
+						  ANJUTA_PROJECT_UNKNOWN);
 	
 	target = anjuta_pm_project_get_node_from_file (plugin->project, ANJUTA_PROJECT_TARGET,  target_file);
 
@@ -1857,10 +1868,9 @@ iproject_manager_get_target_type (IAnjutaProjectManager *project_manager,
 	}
 	else
 	{
-		return ANJUTA_TARGET_UNKNOWN;
+		return ANJUTA_PROJECT_UNKNOWN;
 	}
 }
-
 static GList*
 iproject_manager_get_targets (IAnjutaProjectManager *project_manager,
 							  AnjutaProjectNodeType target_type,
@@ -1868,6 +1878,8 @@ iproject_manager_get_targets (IAnjutaProjectManager *project_manager,
 {
 	GList *targets, *node;
 	ProjectManagerPlugin *plugin;
+	gint type_id;
+	gint type_flag;
 	
 	g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), NULL);
 	
@@ -1877,21 +1889,29 @@ iproject_manager_get_targets (IAnjutaProjectManager *project_manager,
 	targets = gbf_project_util_node_all (anjuta_pm_project_get_root (plugin->project), ANJUTA_PROJECT_TARGET);
 
 	/* Remove all targets not in specified class */
+	type_id = target_type & ANJUTA_PROJECT_ID_MASK;
+	type_flag = target_type & ANJUTA_PROJECT_FLAG_MASK;
+	g_message ("get targets %p", targets);
 	for (node = g_list_first (targets); node != NULL;)
 	{
 		AnjutaProjectNodeType type;
 
 		type = anjuta_project_node_get_full_type (node->data);
-		if (type != target_type)
+		if ((type_id != 0) && (type_id != (type & ANJUTA_PROJECT_ID_MASK)))
 		{
 			GList *next = g_list_next (node);
 			targets = g_list_delete_link (targets, node);
 			node = next;
+			continue;
 		}
-		else
+		if ((type_flag != 0) && ((type & type_flag) == 0))
 		{
-			node = g_list_next (node);
+			GList *next = g_list_next (node);
+			targets = g_list_delete_link (targets, node);
+			node = next;
+			continue;
 		}
+		node = g_list_next (node);
 	}
 
 	/* Replace all targets by their corresponding URI */
@@ -2165,6 +2185,16 @@ iproject_manager_get_packages (IAnjutaProjectManager *project_manager, GError **
 	plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
 
 	return anjuta_pm_project_get_packages (plugin->project);
+	/*GList *list;
+	GList *item;
+	
+	list = anjuta_pm_project_get_packages (plugin->project);
+	for (item = g_list_first (list); item != NULL; item = g_list_next (item))
+	{
+		g_message ("get package %s", (const gchar *)item->data);
+	}
+	
+	return list;*/
 }
 
 static void
diff --git a/plugins/project-manager/project-model.c b/plugins/project-manager/project-model.c
index 686d5b0..6a650ea 100644
--- a/plugins/project-manager/project-model.c
+++ b/plugins/project-manager/project-model.c
@@ -568,7 +568,7 @@ add_target (GbfProjectModel 		*model,
 	 * set of public functions to add/remove shortcuts to save
 	 * this information in the project metadata (when that's
 	 * implemented) */
-	if (anjuta_project_node_get_type (target) & ANJUTA_PROJECT_EXECUTABLE)
+	if (anjuta_project_node_get_full_type (target) & ANJUTA_PROJECT_PRIMARY)
 	{
 		add_target_shortcut (model, NULL, data, NULL);
 	}
diff --git a/plugins/run-program/parameters.c b/plugins/run-program/parameters.c
index b7fa0ab..1c8536d 100644
--- a/plugins/run-program/parameters.c
+++ b/plugins/run-program/parameters.c
@@ -678,7 +678,7 @@ run_dialog_init (RunDialog *dlg, RunProgramPlugin *plugin)
 		if (pm != NULL)
 		{
 			exec_targets = ianjuta_project_manager_get_targets (pm,
-							 ANJUTA_TARGET_EXECUTABLE,
+							 ANJUTA_PROJECT_EXECUTABLE,
 							 NULL);
 		}
 		if (exec_targets != NULL)



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