From: Philip Chimento Date: Sun, 27 Feb 2011 12:09:56 +0000 (+0100) Subject: Create configuration directory X-Git-Tag: v0.9~133 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=4ef3858a07012fedc96a1a3a8545545149406cd6;p=projects%2Fchimara%2Fchimara.git Create configuration directory On startup, the player application now creates a configuration directory, ~/.chimara. The preferences file is ~/.chimara/config, unless there is a file chimara-config in the current directory, in which case it will be overridden. --- diff --git a/player/main.c b/player/main.c index 70bad3b..8d797c3 100644 --- a/player/main.c +++ b/player/main.c @@ -38,6 +38,7 @@ #include #include +#include #include /* Use a custom GSettings backend for our preferences file */ @@ -231,11 +232,24 @@ main(int argc, char *argv[]) gdk_threads_init(); gtk_init(&argc, &argv); - /* Initialize settings file */ - gchar *keyfile = g_build_filename(g_get_home_dir(), ".chimara", NULL); + /* Create configuration dir ~/.chimara */ + gchar *configdir = g_build_filename(g_get_home_dir(), ".chimara", NULL); + if(!g_file_test(configdir, G_FILE_TEST_IS_DIR) + && g_mkdir(configdir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) + g_error(_("Cannot create configuration directory ~/.chimara")); + g_free(configdir); + + /* Initialize settings file; it can be overridden by a "chimara-config" file + in the current directory */ + gchar *keyfile; + if(g_file_test("chimara-config", G_FILE_TEST_IS_REGULAR)) + keyfile = g_strdup("chimara-config"); + else + keyfile = g_build_filename(g_get_home_dir(), ".chimara", "config", NULL); GSettingsBackend *backend = g_keyfile_settings_backend_new(keyfile, "/org/chimara-if/player/", NULL); prefs_settings = g_settings_new_with_backend("org.chimara-if.player.preferences", backend); state_settings = g_settings_new_with_backend("org.chimara-if.player.state", backend); + g_free(keyfile); create_window(); gtk_widget_show_all(window);