示例#1
0
文件: project.c 项目: rosedu/anjuta
GList *
anjuta_pm_project_get_packages (AnjutaPmProject *project)
{
	AnjutaProjectNode *module;
	GHashTable *all;
	GList *packages;

	g_return_val_if_fail (project != NULL, NULL);
	
	all = g_hash_table_new (g_str_hash, g_str_equal);
	
	for (module = anjuta_project_node_first_child (project->root); module != NULL; module = anjuta_project_node_next_sibling (module))
	{
		if (anjuta_project_node_get_node_type(module) == ANJUTA_PROJECT_MODULE)
		{
			AnjutaProjectNode *package;

			for (package = anjuta_project_node_first_child (module); package != NULL; package = anjuta_project_node_next_sibling (package))
			{
				if (anjuta_project_node_get_node_type (package) == ANJUTA_PROJECT_PACKAGE)
				{
					g_hash_table_replace (all, (gpointer)anjuta_project_node_get_name (package), NULL);
				}
			}
		}
	}
	
	packages = g_hash_table_get_keys (all);
	g_hash_table_destroy (all);
	
	return packages;
}
示例#2
0
void
mkp_project_unload (MkpProject *project)
{
	AnjutaProjectNode *node;

	monitors_remove (project);

	/* project data */
	if (project->root_file) g_object_unref (project->root_file);
	project->root_file = NULL;

	/* Remove all children */
	while ((node = anjuta_project_node_first_child (ANJUTA_PROJECT_NODE (project))) != NULL)
	{
		g_object_unref (node);
	}

	/* shortcut hash tables */
	if (project->groups) g_hash_table_destroy (project->groups);
	project->groups = NULL;
	if (project->files) g_hash_table_destroy (project->files);
	project->files = NULL;
	if (project->variables) g_hash_table_destroy (project->variables);
	project->variables = NULL;

	mkp_project_free_rules (project);

	/* List styles */
	if (project->space_list) anjuta_token_style_free (project->space_list);
	if (project->arg_list) anjuta_token_style_free (project->arg_list);
}
示例#3
0
void 
gbf_project_model_move_target_shortcut (GbfProjectModel *model,
		     GtkTreeIter     *iter,
    		     GbfTreeData     *shortcut,
		     GtkTreePath     *before_path)
{
	AnjutaProjectNode *node;
	GtkTreeIter sibling;
	GtkTreePath *root_path;
	GtkTreePath *src_path;
	AnjutaProjectNode *parent;
	
	if (!shortcut)
		return;

	root_path = gbf_project_model_get_project_root (model);
	
	/* check before_path */
	if (!before_path ||
	    gtk_tree_path_get_depth (before_path) > 1)
	{
		/* Missing destination path, use root path */
		before_path = root_path;
	}
	else if (gtk_tree_path_compare (before_path, root_path) > 0)
	{
		/* Destination path outside shortcut are, remove shortcut */
		gbf_project_model_remove (model, iter);
		gtk_tree_path_free (root_path);
		
		return;
	}
		
	/* get the tree iter for the row before which to insert the shortcut */
	if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &sibling, before_path)) {
		gtk_tree_path_free (root_path);
		return;
	}

	src_path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
	if (gtk_tree_path_compare (src_path, before_path) != 0)
	{
		gtk_tree_store_remove (GTK_TREE_STORE (model), iter);			
		gtk_tree_store_insert_before (GTK_TREE_STORE (model), iter, NULL, &sibling);
		gtk_tree_store_set (GTK_TREE_STORE (model), iter, 
				    GBF_PROJECT_MODEL_COLUMN_DATA, shortcut,
				    -1);

		/* add sources */
		parent = gbf_tree_data_get_node (shortcut->shortcut);
		for (node = anjuta_project_node_first_child (parent); node; node = anjuta_project_node_next_sibling (node))
			gbf_project_model_add_node (model, node, iter);

	}

	gtk_tree_path_free (src_path);
	gtk_tree_path_free (root_path);

}
示例#4
0
static gboolean
amp_target_node_erase (AmpNode *target, AmpNode *parent, AmpProject *project, GError **error)
{
	gboolean ok;
	GList * token_list;

	token_list = amp_target_node_get_all_token (AMP_TARGET_NODE (target));
	ok = amp_target_node_delete_token (project, AMP_TARGET_NODE (target), token_list, error);
	g_list_free (token_list);

	/* Remove installation directory variable if the removed target was the
	 * only one using it */
	if (ok)
	{
		AnjutaProjectNode *node;
		const gchar *installdir;
		AnjutaProjectProperty *prop;
		gboolean used = FALSE;

		prop = amp_node_get_property_from_token (ANJUTA_PROJECT_NODE (target), AM_TOKEN__PROGRAMS, 6);
		installdir = prop->value;

		for (node = anjuta_project_node_first_child (ANJUTA_PROJECT_NODE (parent)); node != NULL; node = anjuta_project_node_next_sibling (node))
		{
			if (node != ANJUTA_PROJECT_NODE (target))
			{
				prop = amp_node_get_property_from_token (node, AM_TOKEN__PROGRAMS, 6);
				if ((prop != NULL) && (g_strcmp0 (installdir, prop->value) == 0))
				{
					used = TRUE;
					break;
				}
			}
		}

		if (!used)
		{
			GList *item;

			for (item = anjuta_project_node_get_properties (ANJUTA_PROJECT_NODE (parent)); item != NULL; item = g_list_next (item))
			{
				AmpProperty *prop = (AmpProperty *)item->data;

				if ((((AmpPropertyInfo *)prop->base.info)->token_type == AM_TOKEN_DIR) && (g_strcmp0 (prop->base.name, installdir) == 0))
				{
					/* Remove directory variable */
					anjuta_token_remove_list (anjuta_token_list (prop->token));
					amp_group_node_update_makefile (AMP_GROUP_NODE (parent), prop->token);
					break;
				}
			}
		}
	};

	return ok;
}
示例#5
0
void
gbf_project_model_add_node (GbfProjectModel    	   *model,
                            AnjutaProjectNode	   *node,
                            GtkTreeIter            *parent)
{
	GtkTreeIter iter;
	GbfTreeData *data;
	AnjutaProjectNode *child;
	AnjutaProjectNodeType child_types[] = {ANJUTA_PROJECT_GROUP,
		ANJUTA_PROJECT_TARGET,
		ANJUTA_PROJECT_SOURCE,
		ANJUTA_PROJECT_MODULE,
		ANJUTA_PROJECT_PACKAGE,
		0};
	AnjutaProjectNodeType *type;

	if (node == NULL) return;
	
	data = gbf_tree_data_new_node (node);
	gtk_tree_store_append (GTK_TREE_STORE (model), &iter, parent);
	gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 
			    GBF_PROJECT_MODEL_COLUMN_DATA, data,
			    -1);

	/* add children */
	for (type = child_types; *type != 0; type++)
	{
		for (child = anjuta_project_node_first_child (node); child != NULL; child = anjuta_project_node_next_sibling (child))
		{
			if (anjuta_project_node_get_node_type (child) == *type)
			{
				gbf_project_model_add_node (model, child, &iter);
			}
		}
	}

	/* Add shortcut if needed */
	if ((data != NULL) && 
	    model->priv->default_shortcut && 
	    (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_TARGET) &&
	    (anjuta_project_node_get_full_type (node) & ANJUTA_PROJECT_PRIMARY))
	{
		gbf_project_model_add_target_shortcut (model, NULL, data, NULL, NULL);
	}
}
示例#6
0
文件: amp-group.c 项目: GNOME/anjuta
static gboolean
amp_group_node_save (AmpNode *group, AmpNode *parent, AmpProject *project, GError **error)
{
	AnjutaTokenFile *tfile;
	AnjutaProjectNode *child;
	gboolean ok = TRUE;
	GFile *directory;

	/* Check if Makefile.am is missing, it happens in po directory by example */
	if (AMP_GROUP_NODE (group)->makefile == NULL) return FALSE;
	
	/* Create directory */
	directory = g_file_get_parent (AMP_GROUP_NODE (group)->makefile);
	g_file_make_directory (directory, NULL, NULL);
	g_object_unref (directory);

	/* Save group */
	tfile = AMP_GROUP_NODE (group)->tfile;
	if (tfile == NULL)
	{
		/* Create an empty makefile */
		g_file_replace_contents (AMP_GROUP_NODE (group)->makefile, "", 0, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL, NULL);

		return TRUE;
	}

	if (anjuta_token_file_is_dirty (tfile))
	{
		if (!anjuta_token_file_save (tfile, error)) return FALSE;
	}

	/* Save all children */
	for (child = anjuta_project_node_first_child (ANJUTA_PROJECT_NODE (group)); child != NULL; child = anjuta_project_node_next_sibling (child))
	{
		/* Try to save all children even if some fail */
		if (!amp_node_save (AMP_NODE (child), group, project, error)) ok = FALSE;
	}

	return ok;
}
示例#7
0
GList *
gbf_project_util_node_all (AnjutaProjectNode *parent, AnjutaProjectNodeType type)
{
    AnjutaProjectNode *node;
    GList *list = NULL;
    gint type_id;
    gint type_flag;
    gint type_type;

    type_type = type & ANJUTA_PROJECT_TYPE_MASK;
    type_flag = type & ANJUTA_PROJECT_FLAG_MASK;
    type_id = type & ANJUTA_PROJECT_ID_MASK;
    
    for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
    {
        GList *child_list;

        if ((type_type == 0) || (anjuta_project_node_get_node_type (node) == type_type))
        {
            gint type;
        
            type = anjuta_project_node_get_full_type (node);
            if (((type_id == 0) || (type_id == (type & ANJUTA_PROJECT_ID_MASK))) && 
                ((type_flag == 0) || ((type & type_flag) != 0)))
            {
                list = g_list_prepend (list, node);
            }
        }

        child_list = gbf_project_util_node_all (node, type);
        child_list = g_list_reverse (child_list);
        list = g_list_concat (child_list, list);
    }
 
    list = g_list_reverse (list);
 
    return list;
}
示例#8
0
void 
gbf_project_model_add_target_shortcut (GbfProjectModel *model,
                     GtkTreeIter     *shortcut,
		     GbfTreeData     *target,
		     GtkTreePath     *before_path,
                     gboolean	     *expanded)
{
	AnjutaProjectNode *node;
	GtkTreeIter iter, sibling;
	GtkTreePath *root_path;
	GbfTreeData *data;
	AnjutaProjectNode *parent;
	gboolean valid = FALSE;
	
	if (!target)
		return;

	if (expanded != NULL) *expanded = FALSE;

	root_path = gbf_project_model_get_project_root (model);
	if ((before_path == NULL) && (target->type != GBF_TREE_NODE_SHORTCUT))
	{
		/* Check is a proxy node is not already existing. It is used to
		 * save the shortcut order */

		for (valid = gtk_tree_model_iter_children (GTK_TREE_MODEL (model), &iter, NULL);
			valid;
			valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter))
		{
			GbfTreeData *data;

			/* Look for current node */
			gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
				GBF_PROJECT_MODEL_COLUMN_DATA, &data,
				-1);

			if (((data->type == GBF_TREE_NODE_UNKNOWN) || (data->type == GBF_TREE_NODE_SHORTCUT)) && (g_strcmp0 (target->name, data->name) == 0))
			{
				/* Find already existing node and replace it */
				if (expanded != NULL) *expanded = data->expanded;
				gbf_tree_data_free (data);
				
				data = gbf_tree_data_new_shortcut (target);
				gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 
				    GBF_PROJECT_MODEL_COLUMN_DATA, data,
				    -1);
				break;
			}
		}
	}
	if (!valid)
	{
		/* check before_path */
		if ((before_path == NULL) ||
		    gtk_tree_path_get_depth (before_path) > 1 ||
		    gtk_tree_path_compare (before_path, root_path) > 0)
		{
			before_path = root_path;
		}
		
		/* get the tree iter for the row before which to insert the shortcut */
		if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &sibling, before_path)) {
			gtk_tree_path_free (root_path);
			return;
		}

		if (target->type != GBF_TREE_NODE_SHORTCUT)
		{
			data = gbf_tree_data_new_shortcut (target);
		}
		else
		{
			data = target;
		}
		gtk_tree_store_insert_before (GTK_TREE_STORE (model), &iter, NULL, &sibling);
		gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 
				    GBF_PROJECT_MODEL_COLUMN_DATA, data,
				    -1);
	}
	
	/* add sources */
	parent = gbf_tree_data_get_node (target);
	for (node = anjuta_project_node_first_child (parent); node; node = anjuta_project_node_next_sibling (node))
		gbf_project_model_add_node (model, node, &iter);

	gtk_tree_path_free (root_path);

	if (shortcut) *shortcut = iter;
}
示例#9
0
文件: amp-module.c 项目: GNOME/anjuta
static gboolean
amp_module_node_erase (AmpNode *node, AmpNode *amp_parent, AmpProject *project, GError **error)
{
	AnjutaProjectNode *parent = ANJUTA_PROJECT_NODE (amp_parent);

	if ((parent != NULL) && (anjuta_project_node_get_node_type (parent) == ANJUTA_PROJECT_TARGET))
	{
		AnjutaProjectNode *group = anjuta_project_node_parent (parent);
		AnjutaProjectProperty *prop;
		AnjutaProjectPropertyInfo *group_cpp;
		AnjutaProjectPropertyInfo *target_cpp;
		AnjutaProjectPropertyInfo *target_lib;
		gchar *lib_flags;
		gchar *cpp_flags;
		gint type;

		lib_flags = g_strconcat ("$(", anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (node)), "_LIBS)", NULL);
		cpp_flags = g_strconcat ("$(", anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (node)), "_CFLAGS)", NULL);

		group_cpp = amp_node_get_property_info_from_token (group, AM_TOKEN__CPPFLAGS, 0);
		if (amp_node_property_has_flags (group, group_cpp->id, cpp_flags))
		{
			/* Remove flags in group variable if not more target has this module */
			gboolean used = FALSE;
			AnjutaProjectNode *target;

			for (target = anjuta_project_node_first_child (ANJUTA_PROJECT_NODE (group)); target != NULL; target = anjuta_project_node_next_sibling (target))
			{
				if (anjuta_project_node_get_node_type (target) == ANJUTA_PROJECT_TARGET)
				{
					AnjutaProjectNode *module;

					for (module = anjuta_project_node_first_child (target); module != NULL; module = anjuta_project_node_next_sibling (module))
					{
						if ((anjuta_project_node_get_node_type (module) == ANJUTA_PROJECT_MODULE) &&
						    (module != ANJUTA_PROJECT_NODE (node)) &&
						    (strcmp (anjuta_project_node_get_name (module), anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (node))) == 0))
						{
							used = TRUE;
							break;
						}
					}
				}
				if (used) break;
			}

			if (!used)
			{
				AnjutaProjectProperty *prop;

				prop = amp_node_property_remove_flags (group, group_cpp->id, cpp_flags);
				if (prop != NULL) amp_project_update_am_property (project, group, prop);
			}
		}

		type = anjuta_project_node_get_full_type (ANJUTA_PROJECT_NODE (parent)) & (ANJUTA_PROJECT_ID_MASK | ANJUTA_PROJECT_TYPE_MASK);
		switch (type)
		{
		case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_PROGRAM:
			target_lib = amp_node_get_property_info_from_token (parent, AM_TOKEN_TARGET_LDADD, 0);
			break;
		case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_STATICLIB:
		case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_SHAREDLIB:
		case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_LT_MODULE:
			target_lib = amp_node_get_property_info_from_token (parent, AM_TOKEN_TARGET_LIBADD, 0);
			break;
		default:
			target_lib = NULL;
			break;
		}
		target_cpp = amp_node_get_property_info_from_token (parent, AM_TOKEN_TARGET_CPPFLAGS, 0);

		prop = amp_node_property_remove_flags (parent, target_cpp->id, cpp_flags);
		if (prop != NULL) amp_project_update_am_property (project, parent, prop);
		prop = amp_node_property_remove_flags (parent, target_lib->id, lib_flags);
		if (prop != NULL) amp_project_update_am_property (project, parent, prop);

		g_free (lib_flags);
		g_free (cpp_flags);

		return TRUE;
	}
	else
	{
		return amp_module_node_delete_token (project, AMP_MODULE_NODE (node), error);
	}
}
示例#10
0
/* The target has changed which could change its children */
void
amp_target_changed (AmpTargetNode *node)
{
	GList *item;
	gboolean custom = FALSE;

	for (item = ANJUTA_PROJECT_NODE (node)->properties; item != NULL; item = g_list_next (item))
	{
		AmpProperty *prop = (AmpProperty *)item->data;

		custom = ((AmpPropertyInfo *)prop->base.info)->flags & AM_PROPERTY_PREFIX_OBJECT;
		if (custom) break;
	}

	if (custom)
	{
		/* Update object name if the target has some custom properties */
		AnjutaProjectNode *child;

		for (child = anjuta_project_node_first_child (ANJUTA_PROJECT_NODE (node)); child != NULL; child = anjuta_project_node_next_sibling (child))
		{
			if (anjuta_project_node_get_node_type (child) == ANJUTA_PROJECT_OBJECT)
			{
				if (child->file != NULL)
				{
					AnjutaProjectNode *source = anjuta_project_node_first_child (child);

					if (source != NULL)
					{
						gchar *obj_name;
						const gchar *obj_ext;

						if (child->name != NULL)
						{
							g_free (child->name);
							child->name = NULL;
						}
						obj_name = g_file_get_basename (child->file);
						obj_ext = strrchr (obj_name, '.');
						if ((obj_ext != NULL)  && (obj_ext != obj_name))
						{
							GFile *src_dir;
							gchar *src_name;
							gchar *src_ext;
							gchar *new_name;

							src_dir = g_file_get_parent (source->file);
							src_name = g_file_get_basename (source->file);
							src_ext = strrchr (src_name, '.');
							if ((src_ext != NULL) && (src_ext != src_name)) *src_ext = '\0';
							new_name = g_strconcat (node->base.name, "-", src_name, obj_ext, NULL);

							g_object_unref (child->file);
							child->file = g_file_get_child (src_dir, new_name);

							g_free (new_name);
							g_free (src_name);
							g_object_unref (src_dir);
						}
						g_free (obj_name);
					}
				}
			}
		}
	}
}
示例#11
0
文件: amp-group.c 项目: GNOME/anjuta
/* Find if pkg-config modules are used in group targets */
static gboolean
project_load_group_module (AmpProject *project, AmpGroupNode *group)
{
	AnjutaProjectNode *target;
	AnjutaProjectProperty *prop;
	gchar **group_cpp = NULL;

	prop = amp_node_get_property_from_token (ANJUTA_PROJECT_NODE (group), AM_TOKEN__CPPFLAGS, 0);
	if (prop && (prop->value != NULL)) group_cpp = g_strsplit_set (prop->value, " \t", 0);

	/* Check all targets */
	for (target = anjuta_project_node_first_child (ANJUTA_PROJECT_NODE (group)); target != NULL; target = anjuta_project_node_next_sibling (target))
	{
		gint type = anjuta_project_node_get_full_type (target) & (ANJUTA_PROJECT_ID_MASK | ANJUTA_PROJECT_TYPE_MASK);
		gchar **target_lib = NULL;
		gchar **target_cpp = NULL;

		prop = NULL;
		switch (type)
		{
		case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_PROGRAM:
			prop = amp_node_get_property_from_token (target, AM_TOKEN_TARGET_LDADD, 0);
			break;
		case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_STATICLIB:
		case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_SHAREDLIB:
		case ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_LT_MODULE:
			prop = amp_node_get_property_from_token (target, AM_TOKEN_TARGET_LIBADD, 0);
			break;
		default:
			break;
		}
		if (prop && (prop->value != NULL)) target_lib = g_strsplit_set (prop->value, " \t", 0);

		/* Check if targets use libraries */
		if (target_lib != NULL)
		{
			AnjutaProjectNode *module;

			prop = amp_node_get_property_from_token (target, AM_TOKEN_TARGET_CPPFLAGS, 0);
			if (prop && (prop->value != NULL)) target_cpp = g_strsplit_set (prop->value, " \t", 0);

			for (module = anjuta_project_node_first_child (ANJUTA_PROJECT_NODE (project)); module != NULL; module = anjuta_project_node_next_sibling (module))
			{
				if (anjuta_project_node_get_node_type (module) == ANJUTA_PROJECT_MODULE)
				{
					const gchar *name = anjuta_project_node_get_name (module);
					gchar *lib_flags = g_strconcat ("$(", name, "_LIBS)", NULL);
					gchar **flags;

					for (flags = target_lib; *flags != NULL; flags++)
					{

						if (strcmp (*flags, lib_flags) == 0)
						{
							gchar *cpp_flags = g_strconcat ("$(", name, "_CFLAGS)", NULL);
							gchar **cflags;
							gboolean found = FALSE;

							if (group_cpp != NULL)
							{
								for (cflags = group_cpp; *cflags != NULL; cflags++)
								{
									if (strcmp (*cflags, cpp_flags) == 0)
									{
										found = TRUE;
										break;
									}
								}
							}
							if ((target_cpp != NULL) && !found)
							{
								for (cflags = target_cpp; *cflags != NULL; cflags++)
								{
									if (strcmp (*cflags, cpp_flags) == 0)
									{
										found = TRUE;
										break;
									}
								}
							}
							if (found)
							{
								/* Add new module */
								AnjutaProjectNode *new_module;

								new_module = amp_node_new_valid (target, ANJUTA_PROJECT_MODULE, NULL, name, NULL);
								anjuta_project_node_append (target, new_module);
							}
							g_free (cpp_flags);
						}
					}
					g_free (lib_flags);
				}
			}
			g_strfreev (target_cpp);
			g_strfreev (target_lib);
		}
	}
	g_strfreev (group_cpp);

	return TRUE;
}
示例#12
0
文件: am-writer.c 项目: GNOME/anjuta
gboolean
amp_source_node_create_token (AmpProject  *project, AmpSourceNode *source, GError **error)
{
	AmpGroupNode *group;
	AmpTargetNode *target;
	AnjutaProjectNode *sibling;
	gboolean after;
	AnjutaToken *token;
	AnjutaToken *prev;
	AnjutaToken *args;
	gchar *relative_name;

	/* Get parent target */
	target = AMP_TARGET_NODE (anjuta_project_node_parent_type (ANJUTA_PROJECT_NODE (source), ANJUTA_PROJECT_TARGET));
	if (target == NULL) return FALSE;

	group = AMP_GROUP_NODE (anjuta_project_node_parent_type (ANJUTA_PROJECT_NODE (target), ANJUTA_PROJECT_GROUP));
	relative_name = get_relative_path (anjuta_project_node_get_file (ANJUTA_PROJECT_NODE (group)), anjuta_project_node_get_file (ANJUTA_PROJECT_NODE (source)));

	/* Add in Makefile.am */
	/* Find a sibling if possible */
	after = TRUE;
	for (sibling = anjuta_project_node_prev_sibling (ANJUTA_PROJECT_NODE (source)); sibling != NULL; sibling = anjuta_project_node_prev_sibling (sibling))
	{
		if (anjuta_project_node_get_node_type (sibling) == ANJUTA_PROJECT_SOURCE)
		{
			break;
		}
		else if (anjuta_project_node_get_node_type (sibling) == ANJUTA_PROJECT_OBJECT)
		{
			sibling = anjuta_project_node_first_child (sibling);
			break;
		}
	}
	if (sibling == NULL)
	{
		after = FALSE;
		for (sibling = anjuta_project_node_next_sibling (ANJUTA_PROJECT_NODE (source)); sibling != NULL; sibling = anjuta_project_node_next_sibling (sibling))
		{
			if (anjuta_project_node_get_node_type (sibling) == ANJUTA_PROJECT_SOURCE)
			{
				break;
			}
			else if (anjuta_project_node_get_node_type (sibling) == ANJUTA_PROJECT_OBJECT)
			{
				sibling = anjuta_project_node_first_child (sibling);
				break;
 			}
		}
	}
	if (sibling == NULL)
	{
		after = TRUE;
		prev = NULL;
		args = NULL;
	}
	else
	{
		prev = amp_source_node_get_token (AMP_SOURCE_NODE (sibling));
		args = anjuta_token_list (prev);
	}

	/* Check if a valid source variable is already defined */
	if (args == NULL)
	{
		GList *last;
		for (last = amp_target_node_get_token (target, AM_TOKEN__SOURCES); last != NULL; last = g_list_next (last))
		{
			args = anjuta_token_last_item ((AnjutaToken *)last->data);
			break;
		}
		if (last == NULL)
		{
			for (last = amp_target_node_get_token (target, AM_TOKEN__DATA); last != NULL; last = g_list_next (last))
			{
				args = anjuta_token_last_item ((AnjutaToken *)last->data);
				break;
			}
		}

	}

	if (args == NULL)
	{
		gchar *target_var;
		gchar *canon_name;
		AnjutaToken *var;

		canon_name = canonicalize_automake_variable (anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (target)));
		target_var = g_strconcat (canon_name,  "_SOURCES", NULL);

		var = anjuta_token_find_target_property_position (target, AM_TOKEN__SOURCES);
		if (var == NULL)
			var = anjuta_token_find_target_property_position (target, AM_TOKEN__DATA);

		args = anjuta_token_insert_token_list (FALSE, var,
					ANJUTA_TOKEN_LIST, NULL,
    				ANJUTA_TOKEN_NAME, target_var,
	    			ANJUTA_TOKEN_SPACE, " ",
					ANJUTA_TOKEN_OPERATOR, "=",
    				ANJUTA_TOKEN_LIST, NULL,
	            	ANJUTA_TOKEN_SPACE, " ",
					NULL);

		args = anjuta_token_last_item (args);
		g_free (target_var);
	}

	if (args != NULL)
	{
		AnjutaTokenStyle *style;

		style = anjuta_token_style_new_from_base (project->am_space_list);
		anjuta_token_style_update (style, args);

		token = anjuta_token_new_string (ANJUTA_TOKEN_NAME | ANJUTA_TOKEN_ADDED, relative_name);
		if (after)
		{
			anjuta_token_insert_word_after (args, prev, token);
		}
		else
		{
			anjuta_token_insert_word_before (args, prev, token);
		}

		/* Try to use the same style than the current target list */
		anjuta_token_style_format (style, args);
		anjuta_token_style_free (style);

		amp_group_node_update_makefile (group, token);

		amp_source_node_add_token (source, token);
	}

	return TRUE;
}
示例#13
0
static void
list_children (IAnjutaProject *project, AnjutaProjectNode *root, AnjutaProjectNode *parent, gint indent, const gchar *path)
{
	AnjutaProjectNode *node;
	guint count;

	indent++;

	count = 0;
	for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
	{
		if (anjuta_project_node_get_state (node) & ANJUTA_PROJECT_REMOVED) continue;
		if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_MODULE)
		{
			gchar *child_path = g_strdup_printf ("%s%s%d", path != NULL ? path : "", path != NULL ? ":" : "", count);
			list_module (project, root, node, indent, child_path);
			g_free (child_path);
		}
		count++;
	}

	count = 0;
	for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
	{
		if (anjuta_project_node_get_state (node) & ANJUTA_PROJECT_REMOVED) continue;
		if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_PACKAGE)
		{
			gchar *child_path = g_strdup_printf ("%s%s%d", path != NULL ? path : "", path != NULL ? ":" : "", count);
			list_package (project, root, node, indent, child_path);
			g_free (child_path);
		}
		count++;
	}

	count = 0;
	for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
	{
		if (anjuta_project_node_get_state (node) & ANJUTA_PROJECT_REMOVED) continue;
		if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_GROUP)
		{
			gchar *child_path = g_strdup_printf ("%s%s%d", path != NULL ? path : "", path != NULL ? ":" : "", count);
			list_group (project, root, node, indent, child_path);
			g_free (child_path);
		}
		count++;
	}

	count = 0;
	for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
	{
		if (anjuta_project_node_get_state (node) & ANJUTA_PROJECT_REMOVED) continue;
		if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_TARGET)
		{
			gchar *child_path = g_strdup_printf ("%s%s%d", path != NULL ? path : "", path != NULL ? ":" : "", count);
			list_target (project, root, node, indent, child_path);
			g_free (child_path);
		}
		count++;
	}

	count = 0;
	for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
	{
		if (anjuta_project_node_get_state (node) & ANJUTA_PROJECT_REMOVED) continue;
		if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_SOURCE)
		{
			gchar *child_path = g_strdup_printf ("%s%s%d", path != NULL ? path : "", path != NULL ? ":" : "", count);
			list_source (project, root, node, indent, child_path);
			g_free (child_path);
		}
		count++;
	}
}