Resolves #136: saveDirectory

This commit is Geralds work, as sent by pull-request
https://github.com/openAVproductions/openAV-Luppp/pull/136
It had to be rebased, so this is a new commit of his changes.
main
Harry van Haaren 2016-11-27 19:37:03 +00:00
parent c360dad709
commit 917e61a0ac
4 changed files with 31 additions and 4 deletions

View File

@ -102,6 +102,17 @@ int DiskReader::loadPreferences()
LUPPP_NOTE("No default controllers active.");
}
cJSON* projDir=cJSON_GetObjectItem(preferencesJson,"saveDirectory");
string dir=getenv("HOME");
if(projDir)
{
stringstream s;
s<<dir<<"/"<<projDir->valuestring;
dir=s.str();
}
gui->setProjectsDir(dir);
//Enable per track send and resturn jack ports?
cJSON* jackPerTrackOutput=cJSON_GetObjectItem(preferencesJson,"enablePerTrackOutput");
if(jackPerTrackOutput)

View File

@ -126,7 +126,7 @@ void DiskWriter::initialize(std::string path, std::string name )
if ( sessionDirError )
{
// handle by using different filename?
LUPPP_WARN("Error creating session directory");
LUPPP_WARN("Error creating session directory. Does the path: %s exist?",path.c_str());
}
stringstream audioDirStream;

View File

@ -145,7 +145,7 @@ static void gui_header_callback(Fl_Widget *w, void *data)
std::string tmp;
{
// Create the file chooser, and show it
Fl_File_Chooser chooser(getenv("HOME"),
Fl_File_Chooser chooser(gui->getProjectsDir().c_str(),
"*",
Fl_File_Chooser::DIRECTORY,
"Load Session");
@ -195,7 +195,7 @@ static void gui_header_callback(Fl_Widget *w, void *data)
const char* name = fl_input( "Save session as", gui->getDiskWriter()->getLastSaveName().c_str() );
if ( name )
{
gui->getDiskWriter()->initialize( getenv("HOME"), name );
gui->getDiskWriter()->initialize( gui->getProjectsDir().c_str(), name );
LUPPP_NOTE("%s %s","Saving session as ", name );
EventStateSave e;
writeToDspRingbuffer( &e );
@ -252,6 +252,16 @@ void Gui::selectLoadController(Fl_Widget* w, void*)
}
void Gui::setProjectsDir(string dir)
{
lupppProjectsDir=dir;
}
string Gui::getProjectsDir()
{
return lupppProjectsDir;
}
void Gui::selectSaveSample( int track, int scene )
{
EventStateSaveBuffer e;

View File

@ -96,7 +96,11 @@ class Gui
/// current special clip:
int specialTrack;
int specialScene;
/// The project directory is the default directoy which is shown upon load/save
void setProjectsDir(string dir);
string getProjectsDir();
// save a particular sample to path
std::string saveBufferPath;
@ -109,6 +113,8 @@ class Gui
OptionsWindow* optionWindow;
std::string lupppProjectsDir;
AudioEditor* audioEditor;
DiskReader* diskReader;