-Updated file-chooser for session load

main
Harry van Haaren 2013-11-16 02:44:49 +00:00
parent 7600c60f83
commit 35dde966ce
1 changed files with 47 additions and 20 deletions

View File

@ -114,29 +114,54 @@ static void gui_header_callback(Fl_Widget *w, void *data)
} }
else if ( strcmp(m->label(), "Load Session") == 0 ) else if ( strcmp(m->label(), "Load Session") == 0 )
{ {
Fl_Native_File_Chooser fnfc;
fnfc.title("Load Session");
fnfc.type(Fl_Native_File_Chooser::BROWSE_DIRECTORY);
fnfc.directory( getenv("HOME") );
switch ( fnfc.show() ) std::string tmp;
{ {
case -1: //printf("ERROR: %s\\n", fnfc.errmsg()); // Create the file chooser, and show it
break; // ERROR Fl_File_Chooser chooser(getenv("HOME"),
case 1: //printf("CANCEL\\n"); "*",
break; // CANCEL Fl_File_Chooser::DIRECTORY,
default: "Load Session");
LUPPP_NOTE( "Loading session from dir %s", fnfc.filename() ); chooser.show();
// clear the current session: just do a state reset // Block until user picks something.
EventStateReset e; // (The other way to do this is to use a callback())
writeToDspRingbuffer( &e ); //
while(chooser.shown())
int sess = gui->getDiskReader()->readSession( fnfc.filename() ); { Fl::wait(); }
if ( sess != LUPPP_RETURN_OK )
LUPPP_ERROR( "Error loading session" ); // User hit cancel?
break; if ( chooser.value() == NULL )
{ fprintf(stderr, "(User hit 'Cancel')\n"); return; }
// Print what the user picked
fprintf(stderr, "--------------------\n");
fprintf(stderr, "DIRECTORY: '%s'\n", chooser.directory());
fprintf(stderr, " VALUE: '%s'\n", chooser.value());
fprintf(stderr, " COUNT: %d files selected\n", chooser.count());
tmp = chooser.value();
chooser.hide();
/*
// try to make the Load window dissapear *now*
Fl::check();
Fl::flush();
Fl::wait(0);
*/
} }
LUPPP_NOTE( "Loading session from dir %s", tmp.c_str() );
// clear the current session: just do a state reset
EventStateReset e;
writeToDspRingbuffer( &e );
int sess = gui->getDiskReader()->readSession( tmp );
if ( sess != LUPPP_RETURN_OK )
LUPPP_ERROR( "Error loading session" );
return;
} }
else if ( strcmp(m->label(), "Save Session ") == 0 ) else if ( strcmp(m->label(), "Save Session ") == 0 )
{ {
@ -448,6 +473,8 @@ int Gui::quit()
// quit main window, causing program termination // quit main window, causing program termination
window.hide(); window.hide();
return 0;
} }
void Gui::askQuit() void Gui::askQuit()