Read custom system global tags files from $prefix/share/geany/tags.

Closes #2778923.



git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/unstable@3751 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2009-04-30 12:54:15 +00:00
parent 81b051866e
commit 236d99c763
2 changed files with 36 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2009-04-30 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/symbols.c:
Read custom system global tags files from $prefix/share/geany/tags.
Closes #2778923.
2009-04-27 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> 2009-04-27 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/callbacks.c, src/keyfile.c, src/main.c, src/ui_utils.c, * src/callbacks.c, src/keyfile.c, src/main.c, src/ui_utils.c,

View File

@ -87,8 +87,6 @@ static TagFileInfo tag_file_info[GTF_MAX] =
{FALSE, "python.tags"} {FALSE, "python.tags"}
}; };
static gchar *user_tags_dir;
static GPtrArray *top_level_iter_names = NULL; static GPtrArray *top_level_iter_names = NULL;
static struct static struct
@ -1419,23 +1417,42 @@ static GHashTable *get_tagfile_hash(const GSList *file_list)
} }
static void utils_slist_add_path(GSList *list, const gchar *path)
{
GSList *node;
for (node = list; node != NULL; node = g_slist_next(node))
{
setptr(node->data,
g_build_path(G_DIR_SEPARATOR_S, path, node->data, NULL));
}
}
static GHashTable *init_user_tags(void) static GHashTable *init_user_tags(void)
{ {
GSList *file_list; GSList *file_list = NULL, *list = NULL;
GHashTable *lang_hash; GHashTable *lang_hash;
const gchar *dir;
dir = utils_build_path(app->configdir, "tags", NULL);
/* create the user tags dir for next time if it doesn't exist */
if (! g_file_test(dir, G_FILE_TEST_IS_DIR))
{
utils_mkdir(dir, FALSE);
}
file_list = utils_get_file_list(dir, NULL, NULL);
utils_slist_add_path(file_list, dir);
dir = utils_build_path(app->datadir, "tags", NULL);
list = utils_get_file_list(dir, NULL, NULL);
utils_slist_add_path(list, dir);
file_list = g_slist_concat(file_list, list);
user_tags_dir = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "tags", NULL);
file_list = utils_get_file_list(user_tags_dir, NULL, NULL);
lang_hash = get_tagfile_hash(file_list); lang_hash = get_tagfile_hash(file_list);
/* don't need to delete list contents because they are now used for hash contents */ /* don't need to delete list contents because they are now used for hash contents */
g_slist_free(file_list); g_slist_free(file_list);
/* create the tags dir for next time if it doesn't exist */
if (! g_file_test(user_tags_dir, G_FILE_TEST_IS_DIR))
{
utils_mkdir(user_tags_dir, FALSE);
}
return lang_hash; return lang_hash;
} }
@ -1463,15 +1480,13 @@ static void load_user_tags(filetype_id ft_id)
for (node = fnames; node != NULL; node = g_list_next(node)) for (node = fnames; node != NULL; node = g_list_next(node))
{ {
const gint tm_lang = ft->lang; const gint tm_lang = ft->lang;
gchar *fname; const gchar *fname = node->data;
fname = g_strconcat(user_tags_dir, G_DIR_SEPARATOR_S, node->data, NULL);
if (tm_workspace_load_global_tags(fname, tm_lang)) if (tm_workspace_load_global_tags(fname, tm_lang))
{ {
geany_debug("Loaded %s (%s), total tags: %u.", fname, ft->name, geany_debug("Loaded %s (%s), total tags: %u.", fname, ft->name,
tm_get_workspace()->global_tags->len); tm_get_workspace()->global_tags->len);
} }
g_free(fname);
} }
g_list_foreach(fnames, (GFunc) g_free, NULL); g_list_foreach(fnames, (GFunc) g_free, NULL);
g_list_free(fnames); g_list_free(fnames);