-Updated file-chooser for session load
parent
7600c60f83
commit
35dde966ce
55
src/gui.cxx
55
src/gui.cxx
|
@ -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();
|
||||||
|
|
||||||
|
// Block until user picks something.
|
||||||
|
// (The other way to do this is to use a callback())
|
||||||
|
//
|
||||||
|
while(chooser.shown())
|
||||||
|
{ Fl::wait(); }
|
||||||
|
|
||||||
|
// User hit cancel?
|
||||||
|
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
|
// clear the current session: just do a state reset
|
||||||
EventStateReset e;
|
EventStateReset e;
|
||||||
writeToDspRingbuffer( &e );
|
writeToDspRingbuffer( &e );
|
||||||
|
|
||||||
int sess = gui->getDiskReader()->readSession( fnfc.filename() );
|
int sess = gui->getDiskReader()->readSession( tmp );
|
||||||
if ( sess != LUPPP_RETURN_OK )
|
if ( sess != LUPPP_RETURN_OK )
|
||||||
LUPPP_ERROR( "Error loading session" );
|
LUPPP_ERROR( "Error loading session" );
|
||||||
break;
|
|
||||||
}
|
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()
|
||||||
|
|
Loading…
Reference in New Issue