#include "i18n.h"\r
\r
#include "ardour/audio_library.h"\r
+#include "ardour/rc_configuration.h"\r
\r
using namespace PBD;\r
\r
Mootcher::Mootcher()\r
: curl(curl_easy_init())\r
{\r
- std::string path;\r
- path = Glib::get_home_dir() + "/Freesound/";\r
- changeWorkingDir ( path.c_str() );\r
+ cancel_download_btn.set_label (_("Cancel"));\r
+ progress_hbox.pack_start (progress_bar, true, true);\r
+ progress_hbox.pack_end (cancel_download_btn, false, false);\r
+ progress_bar.show();\r
+ cancel_download_btn.show();\r
+ cancel_download_btn.signal_clicked().connect(sigc::mem_fun (*this, &Mootcher::cancelDownload));\r
};\r
//------------------------------------------------------------------------\r
Mootcher:: ~Mootcher()\r
}\r
\r
//------------------------------------------------------------------------\r
-void Mootcher::changeWorkingDir(const char *saveLocation)\r
-{\r
- basePath = saveLocation;\r
-#ifdef __WIN32__\r
- std::string replace = "/";\r
- size_t pos = basePath.find("\\");\r
- while( pos != std::string::npos ){\r
- basePath.replace(pos, 1, replace);\r
- pos = basePath.find("\\");\r
- }\r
-#endif\r
- //\r
- size_t pos2 = basePath.find_last_of("/");\r
- if(basePath.length() != (pos2+1)) basePath += "/";\r
-}\r
\r
void Mootcher::ensureWorkingDir ()\r
{\r
- std::string p = Glib::build_filename (basePath, "snd");\r
+ std::string p = ARDOUR::Config->get_freesound_download_dir();\r
\r
if (!Glib::file_test (p, Glib::FILE_TEST_IS_DIR)) {\r
if (g_mkdir_with_parents (p.c_str(), 0775) != 0) {\r
PBD::error << "Unable to create Mootcher working dir" << endmsg;\r
}\r
}\r
+ basePath = p;\r
+#ifdef __WIN32__\r
+ std::string replace = "/";\r
+ size_t pos = basePath.find("\\");\r
+ while( pos != std::string::npos ){\r
+ basePath.replace(pos, 1, replace);\r
+ pos = basePath.find("\\");\r
+ }\r
+#endif\r
}\r
\r
\r
// get the file name and size from xml file\r
if (name) {\r
\r
- audioFileName = basePath + "snd/" + ID + "-" + name->child("text")->content();\r
+ audioFileName = Glib::build_filename (basePath, ID + "-" + name->child("text")->content());\r
\r
//store all the tags in the database\r
XMLNode *tags = freesound->child("tags");\r
std::string Mootcher::getAudioFile(std::string originalFileName, std::string ID, std::string audioURL, SoundFileBrowser *caller)\r
{\r
ensureWorkingDir();\r
- std::string audioFileName = basePath + "snd/" + ID + "-" + originalFileName;\r
+ audioFileName = Glib::build_filename (basePath, ID + "-" + originalFileName);\r
\r
// check to see if audio file already exists\r
FILE *testFile = g_fopen(audioFileName.c_str(), "r");\r