[sound-juicer/wip/gsettings] Add fallback file and path patterns
- From: Phillip Wood <pwood src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sound-juicer/wip/gsettings] Add fallback file and path patterns
- Date: Tue, 8 Oct 2013 09:19:43 +0000 (UTC)
commit 6d82aee3c900c9a89630a468966ddd46e508d9fc
Author: Phillip Wood <phillip wood dunelm org uk>
Date: Fri Sep 20 15:28:50 2013 +0100
Add fallback file and path patterns
If the file pattern is empty then all the ripped tracks are written to
".ogg". If the path pattern is empty then all ripped music ends up in
the same directory. The default patterns were removed in commit
49b5a5785 as they were not synchronized between sj-main.c and
sj-prefs.c. Adding two utility functions solves this problem.
https://bugzilla.gnome.org/show_bug.cgi?id=625897
src/sj-main.c | 8 ++++++++
src/sj-prefs.c | 16 ++++++++++++++--
src/sj-prefs.h | 2 ++
3 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/sj-main.c b/src/sj-main.c
index 2ecd1ec..eae6b34 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -1102,6 +1102,10 @@ static void path_pattern_changed_cb (GSettings *settings, gchar *key, gpointer u
g_assert (strcmp (key, SJ_SETTINGS_PATH_PATTERN) == 0);
g_free (path_pattern);
path_pattern = g_settings_get_string (settings, key);
+ if (sj_str_is_empty (path_pattern)) {
+ g_free (path_pattern);
+ path_pattern = g_strdup (sj_get_default_path_pattern ());
+ }
/* TODO: sanity check the pattern */
}
@@ -1113,6 +1117,10 @@ static void file_pattern_changed_cb (GSettings *settings, gchar *key, gpointer u
g_assert (strcmp (key, SJ_SETTINGS_FILE_PATTERN) == 0);
g_free (file_pattern);
file_pattern = g_settings_get_string (settings, key);
+ if (sj_str_is_empty (file_pattern)) {
+ g_free (file_pattern);
+ file_pattern = g_strdup (sj_get_default_file_pattern ());
+ }
/* TODO: sanity check the pattern */
}
diff --git a/src/sj-prefs.c b/src/sj-prefs.c
index bdc2333..2cba9da 100644
--- a/src/sj-prefs.c
+++ b/src/sj-prefs.c
@@ -82,6 +82,18 @@ static const FilePattern file_patterns[] = {
{NULL, NULL}
};
+const gchar*
+sj_get_default_file_pattern (void)
+{
+ return file_patterns[0].pattern;
+}
+
+const gchar*
+sj_get_default_path_pattern (void)
+{
+ return path_patterns[0].pattern;
+}
+
void prefs_profile_changed (GtkWidget *widget, gpointer user_data)
{
GtkTreeIter iter;
@@ -280,11 +292,11 @@ static void pattern_label_update (void)
/* TODO: sucky. Replace with get-gconf-key-with-default mojo */
file_pattern = g_settings_get_string (sj_settings, SJ_SETTINGS_FILE_PATTERN);
if (file_pattern == NULL) {
- file_pattern = g_strdup(file_patterns[0].pattern);
+ file_pattern = g_strdup (sj_get_default_file_pattern ());
}
path_pattern = g_settings_get_string (sj_settings, SJ_SETTINGS_PATH_PATTERN);
if (path_pattern == NULL) {
- path_pattern = g_strdup(path_patterns[0].pattern);
+ path_pattern = g_strdup (sj_get_default_path_pattern ());
}
file_value = filepath_parse_pattern (file_pattern, &sample_track);
diff --git a/src/sj-prefs.h b/src/sj-prefs.h
index 25a5066..fe8f1a2 100644
--- a/src/sj-prefs.h
+++ b/src/sj-prefs.h
@@ -28,6 +28,8 @@ void show_preferences_dialog (void);
gboolean cd_drive_exists (const char *device);
void show_help (GtkWindow *parent);
+const gchar* sj_get_default_file_pattern (void);
+const gchar* sj_get_default_path_pattern (void);
void prefs_profile_changed (GtkWidget *widget, gpointer user_data);
G_MODULE_EXPORT void prefs_base_folder_changed (GtkWidget *chooser, gpointer user_data);
void prefs_path_option_changed (GtkComboBox *combo, gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]