Mixer: Separate out public project commands.

pull/3/head
Jonathan Moore Liles 2010-01-31 14:42:14 -06:00
parent 8d9557f88c
commit cfd217e200
4 changed files with 75 additions and 4 deletions

View File

@ -115,15 +115,15 @@ void Mixer::cb_menu(Fl_Widget* o) {
}
else if (! strcmp( picked, "&Project/&Save" ) )
{
Project::save();
command_save();
}
else if (! strcmp( picked, "&Project/&Quit") )
{
quit();
command_quit();
}
else if ( !strcmp( picked, "&Mixer/&Add Strip" ) )
{
new_strip();
command_add_strip();
}
else if ( !strcmp( picked, "&Mixer/Add &N Strips" ) )
{
@ -132,7 +132,7 @@ void Mixer::cb_menu(Fl_Widget* o) {
if ( s )
{
for ( int i = atoi( s ); i > 0; i-- )
new_strip();
command_add_strip();
}
}
else if (! strcmp( picked, "&Mixer/&Rows/One") )
@ -487,3 +487,57 @@ Mixer::handle ( int m )
return 0;
}
/************/
/* Commands */
/************/
bool
Mixer::command_save ( void )
{
return Project::save();
}
bool
Mixer::command_load ( const char *path, const char *display_name )
{
if ( int err = Project::open( path ) )
{
// fl_alert( "Error opening project specified on commandline: %s", Project::errstr( err ) );
return false;
}
if ( display_name )
Project::name( display_name );
return true;
}
bool
Mixer::command_new ( const char *path, const char *display_name )
{
if ( ! Project::create( path, "" ) )
return false;
if ( display_name )
Project::name( display_name );
return true;
// fl_alert( "Error creating project!" );
}
void
Mixer::command_quit ( void )
{
quit();
}
/* */
void
Mixer::command_add_strip ( void )
{
new_strip();
}

View File

@ -83,6 +83,16 @@ public:
Mixer ( int X, int Y, int W, int H, const char *L );
virtual ~Mixer();
public:
bool command_save ( void );
bool command_load ( const char *path, const char *display_name = 0 );
bool command_new ( const char *path, const char *display_name = 0 );
void command_quit ( void );
void command_add_strip ( void );
};
extern Mixer* mixer;

View File

@ -84,6 +84,12 @@ Project::set_name ( const char *name )
*s = ' ';
}
void
Project::name ( const char *name )
{
strcpy( Project::_name, name );
}
bool
Project::write_info ( void )
{

View File

@ -50,6 +50,7 @@ public:
static const char *errstr ( int n ) { return _errstr[ ( 0 - n ) - 1 ]; }
static const char *name ( void ) { return Project::_name; }
static void name ( const char *v );
static void compact ( void );
static bool close ( void );
static bool save ( void );