SF.net SVN: geany: [661] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Tue Aug 1 21:07:53 UTC 2006
Revision: 661
Author: ntrel
Date: 2006-08-01 14:07:46 -0700 (Tue, 01 Aug 2006)
ViewCVS: http://svn.sourceforge.net/geany/?rev=661&view=rev
Log Message:
-----------
Add hidden option -g to generate filetype_extensions.conf
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/keyfile.c
trunk/src/keyfile.h
trunk/src/main.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-08-01 20:07:58 UTC (rev 660)
+++ trunk/ChangeLog 2006-08-01 21:07:46 UTC (rev 661)
@@ -23,6 +23,8 @@
Install a system filetype_extensions.conf which can be overridden.
* src/filetypes.c data/filetype_extensions.conf:
Add Make pattern to recognise makefile*.
+ * src/keyfile.c, src/keyfile.h, src/main.c:
+ Add hidden option -g to generate filetype_extensions.conf.
2006-07-31 Enrico Tröger <enrico.troeger at uvena.de>
Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c 2006-08-01 20:07:58 UTC (rev 660)
+++ trunk/src/keyfile.c 2006-08-01 21:07:46 UTC (rev 661)
@@ -39,7 +39,10 @@
static gint vpan_position;
-void configuration_save(void)
+static void generate_filetype_extensions(const gchar *output_dir);
+
+
+void configuration_save()
{
gint i = 0, j = 0, idx, max;
gboolean config_exists;
@@ -210,7 +213,7 @@
else \
value = default_value;
-gboolean configuration_load(void)
+gboolean configuration_load()
{
gboolean config_exists;
guint i, geo_len;
@@ -386,7 +389,7 @@
}
-gboolean configuration_open_files(void)
+gboolean configuration_open_files()
{
gint i;
guint x, pos, ft_id, y, len;
@@ -450,7 +453,7 @@
/* set some settings which are already read from the config file, but need other things, like the
* realisation of the main window */
-void configuration_apply_settings(void)
+void configuration_apply_settings()
{
if (scribble_text)
{ // update the scribble widget, because now it's realized
@@ -493,46 +496,64 @@
}
-#if 0
+/* Generate the config files in "data/" from defaults */
+void configuration_generate_data_files()
+{
+ gchar *cur_dir, *gen_dir;
+
+ cur_dir = g_get_current_dir();
+ gen_dir = g_strconcat(cur_dir, G_DIR_SEPARATOR_S, "data", NULL);
+ g_free(cur_dir);
+
+ if (! g_file_test(gen_dir, G_FILE_TEST_IS_DIR))
+ {
+ g_print("%s does not exist!\n", gen_dir);
+ return;
+ }
+ g_print("Generating system files in %s:\n", gen_dir);
+ generate_filetype_extensions(gen_dir);
+ g_free(gen_dir);
+}
+
+
/* This will write the default settings for the system filetype_extensions.conf */
static void generate_filetype_extensions(const gchar *output_dir)
{
guint i;
- gsize len = 0;
gchar *configfile = g_strconcat(output_dir, G_DIR_SEPARATOR_S, "filetype_extensions.conf", NULL);
- gchar *data, *comment;
+ gchar *data, *basename;
+ GKeyFile *config;
config = g_key_file_new();
- // add missing keys
+ // add filetype keys
for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
{
- if (! g_key_file_has_key(config, "Extensions", filetypes[i]->name, NULL))
- {
- g_key_file_set_string_list(config, "Extensions", filetypes[i]->name,
- (const gchar**) filetypes[i]->pattern, g_strv_length(filetypes[i]->pattern));
- }
+ g_key_file_set_string_list(config, "Extensions", filetypes[i]->name,
+ (const gchar**) filetypes[i]->pattern, g_strv_length(filetypes[i]->pattern));
}
- // 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\n"
- "Insert as many items as you want, seperate them with a \";\".\n"
- "See Geany's main documentation for details.", NULL);
- }
- g_free(comment);
+ // add comment
+ 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);
// write the file
+ g_print("%s: ", __func__);
data = g_key_file_to_data(config, NULL, NULL);
- utils_write_file(configfile, data);
+ basename = g_path_get_basename(configfile);
+
+ if (utils_write_file(configfile, data) == 0)
+ g_print("wrote file %s.\n", basename);
+ else
+ g_print("*** ERROR: error writing file %s\n", basename);
+ g_free(basename);
+
g_free(data);
g_key_file_free(config);
}
-#endif
-void configuration_read_filetype_extensions(void)
+void configuration_read_filetype_extensions()
{
guint i;
gsize len = 0;
Modified: trunk/src/keyfile.h
===================================================================
--- trunk/src/keyfile.h 2006-08-01 20:07:58 UTC (rev 660)
+++ trunk/src/keyfile.h 2006-08-01 21:07:46 UTC (rev 661)
@@ -24,16 +24,19 @@
#define GEANY_KEYFILE_H 1
-void configuration_save(void);
+void configuration_save();
-gboolean configuration_load(void);
+gboolean configuration_load();
-gboolean configuration_open_files(void);
+gboolean configuration_open_files();
-void configuration_read_filetype_extensions(void);
+void configuration_read_filetype_extensions();
/* set some settings which are already read from the config file, but need other things, like the
* realisation of the main window */
-void configuration_apply_settings(void);
+void configuration_apply_settings();
+/* Generate the config files in "data/" from defaults */
+void configuration_generate_data_files();
+
#endif
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2006-08-01 20:07:58 UTC (rev 660)
+++ trunk/src/main.c 2006-08-01 21:07:46 UTC (rev 661)
@@ -69,6 +69,8 @@
static gboolean no_vte = FALSE;
static gchar *lib_vte = NULL;
#endif
+static gboolean generate_datafiles = FALSE;
+
static GOptionEntry entries[] =
{
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &debug_mode, N_("runs in debug mode (means being verbose)"), NULL },
@@ -83,6 +85,7 @@
{ "vte-lib", 'l', 0, G_OPTION_ARG_FILENAME, &lib_vte, N_("filename of libvte.so"), NULL },
#endif
{ "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("show version and exit"), NULL },
+ { "generate-data-files", 'g', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &generate_datafiles, "", NULL },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
@@ -555,6 +558,11 @@
app->fifo_ioc = ioc;
#endif
filetypes_init_types();
+ if (generate_datafiles)
+ {
+ configuration_generate_data_files();
+ exit(0);
+ }
configuration_read_filetype_extensions();
gtk_window_set_icon(GTK_WINDOW(app->window), utils_new_pixbuf_from_inline(GEANY_IMAGE_LOGO, FALSE));
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