diff options
author | jstebbins <[email protected]> | 2008-09-25 14:38:21 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2008-09-25 14:38:21 +0000 |
commit | 0a66557bbd0c429e27463d8bb3fe1918e44b344b (patch) | |
tree | 51aa5dbf53bc24f60e021f311f96d9c1a845da97 /gtk/src/presets.c | |
parent | b6e78bffa6baa8adb7436a9e41a392c4544aacc3 (diff) |
LinGui: Store the activity log in the users config dir instead of PWD.
Display the location of the activity log in the activity window.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1761 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src/presets.c')
-rw-r--r-- | gtk/src/presets.c | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/gtk/src/presets.c b/gtk/src/presets.c index e3ec46591..2f7eaa88a 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -348,23 +348,40 @@ ghb_update_from_preset( } } -static void -store_plist(GValue *plist, const gchar *name) +gchar* +ghb_get_user_config_dir() { const gchar *dir; gchar *config; - FILE *file; dir = g_get_user_config_dir(); - config = g_strdup_printf ("%s/ghb", dir); - if (!g_file_test(config, G_FILE_TEST_IS_DIR)) + if (!g_file_test(dir, G_FILE_TEST_IS_DIR)) { - g_mkdir (config, 0755); + dir = g_get_home_dir(); + config = g_strdup_printf ("%s/.ghb", dir); + if (!g_file_test(config, G_FILE_TEST_IS_DIR)) + g_mkdir (config, 0755); } + else + { + config = g_strdup_printf ("%s/ghb", dir); + if (!g_file_test(config, G_FILE_TEST_IS_DIR)) + g_mkdir (config, 0755); + } + return config; +} + +static void +store_plist(GValue *plist, const gchar *name) +{ + gchar *config, *path; + FILE *file; + + config = ghb_get_user_config_dir(); + path = g_strdup_printf ("%s/%s", config, name); + file = g_fopen(path, "w"); g_free(config); - config = g_strdup_printf ("%s/ghb/%s", dir, name); - file = g_fopen(config, "w"); - g_free(config); + g_free(path); ghb_plist_write(file, plist); fclose(file); } @@ -372,32 +389,32 @@ store_plist(GValue *plist, const gchar *name) static GValue* load_plist(const gchar *name) { - const gchar *dir; - gchar *config; + gchar *config, *path; GValue *plist = NULL; - dir = g_get_user_config_dir(); - config = g_strdup_printf ("%s/ghb/%s", dir, name); - if (g_file_test(config, G_FILE_TEST_IS_REGULAR)) + config = ghb_get_user_config_dir(); + path = g_strdup_printf ("%s/%s", config, name); + if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) { - plist = ghb_plist_parse_file(config); + plist = ghb_plist_parse_file(path); } g_free(config); + g_free(path); return plist; } static void remove_plist(const gchar *name) { - const gchar *dir; - gchar *config; + gchar *config, *path; - dir = g_get_user_config_dir(); - config = g_strdup_printf ("%s/ghb/%s", dir, name); - if (g_file_test(config, G_FILE_TEST_IS_REGULAR)) + config = ghb_get_user_config_dir(); + path = g_strdup_printf ("%s/%s", config, name); + if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) { - g_unlink(config); + g_unlink(path); } + g_free(path); g_free(config); } |