SF.net SVN: geany: [659] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Tue Aug 1 16:12:53 UTC 2006
Revision: 659
Author: ntrel
Date: 2006-08-01 09:12:45 -0700 (Tue, 01 Aug 2006)
ViewCVS: http://svn.sourceforge.net/geany/?rev=659&view=rev
Log Message:
-----------
Install a system filetype_extensions.conf which can be overridden
Modified Paths:
--------------
trunk/ChangeLog
trunk/Makefile.am
trunk/src/keyfile.c
Added Paths:
-----------
trunk/data/filetype_extensions.conf
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-08-01 13:24:58 UTC (rev 658)
+++ trunk/ChangeLog 2006-08-01 16:12:45 UTC (rev 659)
@@ -19,6 +19,8 @@
Removed some unnecessary static variables.
* document.c, document.h, prefs.c:
Apply the tab width setting for new documents.
+ * src/keyfile.c, data/filetype_extensions.conf, Makefile.am:
+ Install a system filetype_extensions.conf which can be overridden.
2006-07-31 Enrico Tröger <enrico.troeger at uvena.de>
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2006-08-01 13:24:58 UTC (rev 658)
+++ trunk/Makefile.am 2006-08-01 16:12:45 UTC (rev 659)
@@ -10,17 +10,21 @@
tagmanager/makefile.win32 \
src/makefile.win32
+SYS_DATA_FILES = \
+ data/global.tags \
+ data/php.tags \
+ data/latex.tags \
+ data/html_entities.tags \
+ data/filetypes.* \
+ data/filetype_extensions.conf
+
EXTRA_DIST = \
autogen.sh \
geany.desktop.in \
geany.spec \
geany.glade \
geany.gladep \
- data/global.tags \
- data/php.tags \
- data/latex.tags \
- data/html_entities.tags \
- data/filetypes.* \
+ $(SYS_DATA_FILES) \
$(WIN32_BUILD_FILES)
uninstall-local:
Added: trunk/data/filetype_extensions.conf
===================================================================
--- trunk/data/filetype_extensions.conf (rev 0)
+++ trunk/data/filetype_extensions.conf 2006-08-01 16:12:45 UTC (rev 659)
@@ -0,0 +1,26 @@
+#Filetype extension configuration file for Geany
+#Insert as many items as you want, seperate them with a ";".
+#See Geany's main documentation for details.
+[Extensions]
+C=*.c;*.h;
+C++=*.cpp;*.cxx;*.c++;*.cc;*.h;*.hpp;*.hxx;*.h++;*.hh;*.C;
+D=*.d;*.di;
+Java=*.java;
+Pascal=*.pas;*.pp;*.inc;*.dpr;*.dpk;
+ASM=*.asm;
+CAML=*.ml;*.mli;
+Perl=*.pl;*.perl;*.pm;
+PHP=*.php;*.php3;*.php4;*.php5;*.html;*.htm;
+Python=*.py;*.pyw;
+Ruby=*.rb;*.rhtml;
+Tcl=*.tcl;*.tk;*.wish;
+Sh=*.sh;configure;configure.in;configure.in.in;configure.ac;*.ksh;*.zsh;
+Make=*.mak;*.mk;Makefile*;
+XML=*.xml;*.sgml;
+Docbook=*.docbook;
+CSS=*.css;
+SQL=*.sql;
+LaTeX=*.tex;*.sty;*.idx;
+O-Matrix=*.oms;
+Conf=*.conf;*.ini;config;*rc;*.cfg;
+None=*;
Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c 2006-08-01 13:24:58 UTC (rev 658)
+++ trunk/src/keyfile.c 2006-08-01 16:12:45 UTC (rev 659)
@@ -493,17 +493,16 @@
}
-void configuration_read_filetype_extensions(void)
+#if 0
+/* This will write the default settings for the system filetype_extensions.conf */
+static void generate_filetype_extensions(const gchar *output_dir)
{
- gboolean file_changed = FALSE;
guint i;
gsize len = 0;
- gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "filetype_extensions.conf", NULL);
- gchar **list, *data, *comment;
- GKeyFile *config = g_key_file_new();
+ gchar *configfile = g_strconcat(output_dir, G_DIR_SEPARATOR_S, "filetype_extensions.conf", NULL);
+ gchar *data, *comment;
- g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL);
-
+ config = g_key_file_new();
// add missing keys
for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
{
@@ -511,36 +510,58 @@
{
g_key_file_set_string_list(config, "Extensions", filetypes[i]->name,
(const gchar**) filetypes[i]->pattern, g_strv_length(filetypes[i]->pattern));
- file_changed = TRUE;
}
}
// add comment, if it doesn't exist
comment = g_key_file_get_comment(config, NULL, NULL, NULL);
if (!comment || strlen(comment) == 0)
{
- g_key_file_set_comment(config, "Extensions", NULL, "Filetype extension configuration file for Geany\nInsert as many items as you want, seperate them with a \";\".\nIf you want to get the default for a key, just delete it and\nthen it will be appended next time you start Geany.", NULL);
- file_changed = TRUE;
+ g_key_file_set_comment(config, "Extensions", NULL,
+ "Filetype extension configuration file for Geany\n"
+ "Insert as many items as you want, seperate them with a \";\".\n"
+ "See Geany's main documentation for details.", NULL);
}
g_free(comment);
- // write the file if there one or more keys are missing
- if (file_changed)
- {
- data = g_key_file_to_data(config, NULL, NULL);
- utils_write_file(configfile, data);
- g_free(data);
- }
+ // write the file
+ data = g_key_file_to_data(config, NULL, NULL);
+ utils_write_file(configfile, data);
+ g_free(data);
+ g_key_file_free(config);
+}
+#endif
- // finally read the keys
+
+void configuration_read_filetype_extensions(void)
+{
+ guint i;
+ gsize len = 0;
+ gchar *sysconfigfile = g_strconcat(app->datadir, G_DIR_SEPARATOR_S,
+ "filetype_extensions.conf", NULL);
+ gchar *userconfigfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S,
+ "filetype_extensions.conf", NULL);
+ gchar **list;
+ GKeyFile *sysconfig = g_key_file_new();
+ GKeyFile *userconfig = g_key_file_new();
+
+ g_key_file_load_from_file(sysconfig, sysconfigfile, G_KEY_FILE_NONE, NULL);
+ g_key_file_load_from_file(userconfig, userconfigfile, G_KEY_FILE_NONE, NULL);
+
+ // read the keys
for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
{
- list = g_key_file_get_string_list(config, "Extensions", filetypes[i]->name, &len, NULL);
+ gboolean userset =
+ g_key_file_has_key(userconfig, "Extensions", filetypes[i]->name, NULL);
+ list = g_key_file_get_string_list(
+ (userset) ? userconfig : sysconfig, "Extensions", filetypes[i]->name, &len, NULL);
if (list && len > 0)
{
g_strfreev(filetypes[i]->pattern);
filetypes[i]->pattern = list;
}
+ else g_strfreev(list);
}
- g_key_file_free(config);
+ g_key_file_free(sysconfig);
+ g_key_file_free(userconfig);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list