Esempio n. 1
0
gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name
  , gboolean update, const char* name)
{
	if (0 == source_file_class_id)
		source_file_class_id = tm_work_object_register(tm_source_file_free
		  , tm_source_file_update, NULL);

#ifdef TM_DEBUG
	g_message("Source File init: %s", file_name);
#endif

	if (FALSE == tm_work_object_init(&(source_file->work_object),
		  source_file_class_id, file_name, FALSE))
		return FALSE;

	source_file->inactive = FALSE;
	if (NULL == LanguageTable)
	{
		initializeParsing();
		installLanguageMapDefaults();
		if (NULL == TagEntryFunction)
			TagEntryFunction = tm_source_file_tags;
		if (NULL == TagEntrySetArglistFunction)
			TagEntrySetArglistFunction = tm_source_file_set_tag_arglist;
	}

	if (name == NULL)
		source_file->lang = LANG_AUTO;
	else
		source_file->lang = getNamedLanguage(name);

	if (update)
		tm_source_file_update(TM_WORK_OBJECT(source_file), TRUE, FALSE, FALSE);
	return TRUE;
}
Esempio n. 2
0
static void workspace_add_tag(gchar *filename, TagObject *obj, gpointer foo)
{
	TMWorkObject *tm_obj = NULL;

	if (!document_find_by_filename(filename))
	{
		gchar *locale_filename;

		locale_filename = utils_get_locale_from_utf8(filename);
		tm_obj = tm_source_file_new(locale_filename, FALSE, filetypes_detect_from_file(filename)->name);
		g_free(locale_filename);

		if (tm_obj)
		{
			tm_workspace_add_object(tm_obj);
			tm_source_file_update(tm_obj, TRUE, FALSE, TRUE);
		}
	}

	if (obj->tag)
		tm_workspace_remove_object(obj->tag, TRUE, TRUE);

	obj->tag = tm_obj;
}