diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2013-09-20 15:28:50 +0100 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2014-01-23 16:15:34 +0100 |
commit | cbe58cc402f3e4c7d235605d6f788794dde8e89c (patch) | |
tree | 1f8f4b2f7b2efe36c6b91c1682fd952c678ec153 | |
parent | 3e6a3e76ac0cec89f5ea4bdc7a7fabbf94e1f679 (diff) |
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
-rw-r--r-- | src/sj-main.c | 8 | ||||
-rw-r--r-- | src/sj-prefs.c | 16 | ||||
-rw-r--r-- | 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 55bbbb1..dc58cd1 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 eb22121..61c9a4c 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); |