summaryrefslogtreecommitdiffstats
path: root/gtk/src/settings.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2008-08-24 02:10:15 +0000
committerjstebbins <[email protected]>2008-08-24 02:10:15 +0000
commit4cf0fa742fbb476ccd92372c72db6c245c11e497 (patch)
treed87a750769bec507031986faf37342585531bab7 /gtk/src/settings.c
parentddacbf46e7ad7fafacc35eeb6d2dfb5fbb698913 (diff)
LinGui: bundle the standard presets in the exe. eliminates installing
a separate file. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1651 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src/settings.c')
-rw-r--r--gtk/src/settings.c110
1 files changed, 34 insertions, 76 deletions
diff --git a/gtk/src/settings.c b/gtk/src/settings.c
index f42f9f14f..989d1d3db 100644
--- a/gtk/src/settings.c
+++ b/gtk/src/settings.c
@@ -862,6 +862,9 @@ dump_settings(GHashTable *settings)
const gchar defaultSettings[] =
#include "internal_defaults.h"
;
+const gchar standardPresets[] =
+#include "standard_presets.h"
+;
typedef struct
{
@@ -1478,68 +1481,43 @@ ghb_prefs_load(signal_user_data_t *ud)
void
ghb_presets_reload(signal_user_data_t *ud)
{
- gchar *config;
GKeyFile *keyFile;
+ gboolean res;
g_debug("ghb_presets_reload()\n");
keyFile = g_key_file_new();
+ g_key_file_load_from_data( keyFile, standardPresets,
+ sizeof(standardPresets), G_KEY_FILE_NONE, NULL);
+
+ gchar **groups, **keys;
+ gchar *value;
+ gint ii, jj;
- config = g_strdup_printf ("./standard_presets");
- if (!g_file_test(config, G_FILE_TEST_IS_REGULAR))
+ // Merge the keyfile contents into our presets
+ groups = g_key_file_get_groups(keyFile, NULL);
+ // First remove any existing groups with the same names
+ for (ii = 0; groups[ii] != NULL; ii++)
{
- g_free(config);
-
- const gchar* const *dirs;
- gint ii;
- dirs = g_get_system_data_dirs();
- if (dirs != NULL)
- {
- for (ii = 0; dirs[ii] != NULL; ii++)
- {
- config = g_strdup_printf("%s/ghb/standard_presets", dirs[ii]);
- if (g_file_test(config, G_FILE_TEST_IS_REGULAR))
- {
- break;
- }
- g_free(config);
- config = NULL;
- }
- }
+ g_key_file_remove_group(presetsKeyFile, groups[ii], NULL);
}
- if (config != NULL)
+ for (ii = 0; groups[ii] != NULL; ii++)
{
- gchar **groups, **keys;
- gchar *value;
- gint ii, jj;
-
- g_key_file_load_from_file( keyFile, config,
- G_KEY_FILE_KEEP_COMMENTS, NULL);
- // Merge the keyfile contents into our presets
- groups = g_key_file_get_groups(keyFile, NULL);
- // First remove any existing groups with the same names
- for (ii = 0; groups[ii] != NULL; ii++)
- {
- g_key_file_remove_group(presetsKeyFile, groups[ii], NULL);
- }
- for (ii = 0; groups[ii] != NULL; ii++)
+ keys = g_key_file_get_keys(keyFile, groups[ii], NULL, NULL);
+ for (jj = 0; keys[jj] != NULL; jj++)
{
- keys = g_key_file_get_keys(keyFile, groups[ii], NULL, NULL);
- for (jj = 0; keys[jj] != NULL; jj++)
+ GError *err = NULL;
+ value = g_key_file_get_string(
+ keyFile, groups[ii], keys[jj], &err);
+ if (value && !err)
{
- GError *err = NULL;
- value = g_key_file_get_string(
- keyFile, groups[ii], keys[jj], &err);
- if (value && !err)
- {
- g_key_file_set_string(
- presetsKeyFile, groups[ii], keys[jj], value);
- }
- if (value) g_free(value);
+ g_key_file_set_string(
+ presetsKeyFile, groups[ii], keys[jj], value);
}
- g_strfreev(keys);
+ if (value) g_free(value);
}
- g_strfreev(groups);
+ g_strfreev(keys);
}
+ g_strfreev(groups);
g_key_file_free(keyFile);
build_presets_list(ud->settings);
}
@@ -1555,37 +1533,17 @@ ghb_presets_load(signal_user_data_t *ud)
dir = g_get_user_config_dir();
config = g_strdup_printf ("%s/ghb/presets", dir);
- if (!g_file_test(config, G_FILE_TEST_IS_REGULAR))
- {
- g_free(config);
- config = g_strdup_printf ("./standard_presets");
- if (!g_file_test(config, G_FILE_TEST_IS_REGULAR))
- {
- g_free(config);
-
- const gchar* const *dirs;
- gint ii;
- dirs = g_get_system_data_dirs();
- if (dirs != NULL)
- {
- for (ii = 0; dirs[ii] != NULL; ii++)
- {
- config = g_strdup_printf("%s/ghb/standard_presets", dirs[ii]);
- if (g_file_test(config, G_FILE_TEST_IS_REGULAR))
- {
- break;
- }
- g_free(config);
- config = NULL;
- }
- }
- }
- }
- if (config != NULL)
+ if (g_file_test(config, G_FILE_TEST_IS_REGULAR))
{
g_key_file_load_from_file( presetsKeyFile, config,
G_KEY_FILE_KEEP_COMMENTS, NULL);
}
+ else
+ {
+ g_key_file_load_from_data( presetsKeyFile, standardPresets,
+ sizeof(standardPresets), G_KEY_FILE_NONE, NULL);
+ }
+ g_free(config);
build_presets_list(ud->settings);
}