From 7fa207d9ee351aeaff5567e51966e2b0cf03b380 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 20 May 2022 22:02:26 +0200 Subject: [PATCH] Add UI config-option for freesound download cache This also invalidates any prior libardour rc-config (which was not previously exposed as config). Note: old existing cache is not moved or invalidated when the path changes. --- gtk2_ardour/rc_option_editor.cc | 9 +++++++++ gtk2_ardour/sfdb_freesound_mootcher.cc | 2 +- gtk2_ardour/ui_config.cc | 9 +++++++++ gtk2_ardour/ui_config_vars.h | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index c209d41221..8e15288dea 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -2430,6 +2430,15 @@ RCOptionEditor::RCOptionEditor () sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_only_copy_imported_files) )); + + add_option (_("General"), + new DirectoryOption ( + X_("freesound-dir"), + _("Cache Folder for downloaded Freesound clips:"), + sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::get_freesound_dir), + sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_freesound_dir) + )); + add_option (_("General"), new OptionEditorHeading (_("Export"))); add_option (_("General"), diff --git a/gtk2_ardour/sfdb_freesound_mootcher.cc b/gtk2_ardour/sfdb_freesound_mootcher.cc index cf15f24d60..416e635cfc 100644 --- a/gtk2_ardour/sfdb_freesound_mootcher.cc +++ b/gtk2_ardour/sfdb_freesound_mootcher.cc @@ -106,7 +106,7 @@ Mootcher:: ~Mootcher() void Mootcher::ensureWorkingDir () { - std::string p = ARDOUR::Config->get_freesound_download_dir(); + std::string const& p = UIConfiguration::instance ().get_freesound_dir (); DEBUG_TRACE(PBD::DEBUG::Freesound, "ensureWorkingDir() - " + p + "\n"); if (!Glib::file_test (p, Glib::FILE_TEST_IS_DIR)) { diff --git a/gtk2_ardour/ui_config.cc b/gtk2_ardour/ui_config.cc index 3e613a8272..203fec1eb4 100644 --- a/gtk2_ardour/ui_config.cc +++ b/gtk2_ardour/ui_config.cc @@ -94,6 +94,15 @@ UIConfiguration::UIConfiguration () { load_state(); + /* Setup defaults */ + if (get_freesound_dir ().empty ()) { + std::string const& d (Glib::build_filename (ARDOUR::user_cache_directory (), "freesound")); + set_freesound_dir (d); + if (!Glib::file_test (d, Glib::FILE_TEST_EXISTS)) { + g_mkdir_with_parents (d.c_str (), 0755); + } + } + ColorsChanged.connect (boost::bind (&UIConfiguration::colors_changed, this)); ParameterChanged.connect (sigc::mem_fun (*this, &UIConfiguration::parameter_changed)); diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.h index c90467f07a..47380433eb 100644 --- a/gtk2_ardour/ui_config_vars.h +++ b/gtk2_ardour/ui_config_vars.h @@ -139,6 +139,7 @@ UI_CONFIG_VARIABLE (bool, one_plugin_window_only, "one-plugin-window-only", fals UI_CONFIG_VARIABLE (int, default_lower_midi_note, "default-lower-midi-note", 60) UI_CONFIG_VARIABLE (int, default_upper_midi_note, "default-upper-midi-note", 71) UI_CONFIG_VARIABLE (bool, ask_before_closing_last_window, "ask-before-closing-last-window", true) +UI_CONFIG_VARIABLE (std::string, freesound_dir, "freesound-dir", "") /* these are visibility-type selections in the New Track dialog that we should make persistent for the user's choices */ UI_CONFIG_VARIABLE (bool, show_on_cue_page, "show-on-cue-page", true)