Improve LASH support.

This commit is contained in:
Jonathan Moore Liles 2008-05-14 23:23:16 -05:00
parent 28bc3ff1c6
commit 79b16b56c9
4 changed files with 105 additions and 34 deletions

View File

@ -19,11 +19,25 @@
/* actual implementation of our side of the LASH protocol */
/* NOTES: The LASH API, as it stands, is basically retarded. It was
* designed by retards for retards. The way it handles project state
* and project directories shows a deep lack of insight into how real
* software works. Since LASH doesn't provide us with the information
* we need--when we need it--we just punt and only use LASH to save
* and load the path to the *real* project data. One of these days a
* motivated individual (probably me, unfortuately) is going to spend
* a cozy afternoon implementing a replacement for LASH--a load of
* shit which has been in the works for God know how many years and is
* still stinking up the place. */
#include "LASH.H"
#include "Project.H"
#include "TLE.H" // all this just for quit()
extern TLE *tle;
#include "debug.h"
LASH::LASH ( )
{
}
@ -32,12 +46,33 @@ LASH::~LASH ( )
{
}
bool
LASH::handle_save_file ( const char *path )
{
MESSAGE( "LASH wants us to save \"%s\"", path );
char *name;
asprintf( &name, "%s/project-path", path );
FILE *fp;
if ( ! ( fp = fopen( name, "w" ) ) )
{
free( name );
return false;
}
else
free( name );
char project_path[ 512 ];
fl_filename_absolute( project_path, sizeof( project_path ), "." );
fwrite( project_path, strlen( project_path ), 1, fp );
fclose( fp );
return true;
}
@ -46,11 +81,32 @@ LASH::handle_restore_file ( const char *path )
{
MESSAGE( "LASH wants us to load \"%s\"", path );
return true;
char *name;
asprintf( &name, "%s/project-path", path );
FILE *fp;
if ( ! ( fp = fopen( name, "r" ) ) )
{
free( name );
return false;
}
else
free( name );
char project_path[ 512 ];
fgets( project_path, sizeof( project_path ), fp );
fclose( fp );
return Project::open( project_path );
}
void
LASH::handle_quit ( void )
{
MESSAGE( "LASH wants us to quit" );
tle->quit();
}

View File

@ -33,6 +33,10 @@ project state belongs to Timeline and other classes. */
#include "Timeline.H" // for sample_rate();
#include "TLE.H" // all this just for load and save...
extern TLE *tle;
/* FIXME: wrong place for this */
#define APP_TITLE "Non-DAW"
@ -45,9 +49,16 @@ bool Project::_is_open = false;
void
Project::set_name ( const char *name )
{
char *s = rindex( name, '/' );
strcpy( Project::_name, name );
strcpy( Project::_name, s ? s + 1 : name );
if ( Project::_name[ strlen( Project::_name ) - 1 ] == '/' )
Project::_name[ strlen( Project::_name ) - 1 ] = '\0';
char *s = rindex( Project::_name, '/' );
s = s ? s + 1 : Project::_name;
memmove( Project::_name, s, strlen( s ) + 1 );
for ( s = Project::_name; *s; ++s )
if ( *s == '_' || *s == '-' )
@ -67,6 +78,8 @@ exists ( const char *name )
bool
Project::close ( void )
{
tle->save_timeline_settings();
Loggable::close();
write_info();
@ -146,6 +159,8 @@ Project::open ( const char *name )
_is_open = true;
tle->load_timeline_settings();
return true;
}

View File

@ -165,9 +165,7 @@ main_window->redraw();}
}
MenuItem {} {
label {&Open}
callback {save_timeline_settings();
const char *name = fl_dir_chooser( "Open Project", NULL, NULL );
callback {const char *name = fl_dir_chooser( "Open Project", NULL, NULL );
Project::close();
@ -176,13 +174,7 @@ if ( ! Project::open( name ) )
fl_alert( "Could not open \\"%s\\" as a Non-DAW project!", name );
// we are in a somewhar ambiguous state now with no project open.
}
else
{
load_timeline_settings();
}
update_menu();}
}}
xywh {10 10 40 25}
}
MenuItem {} {
@ -192,7 +184,7 @@ update_menu();}
if ( n != 2 )
return;
Loggable::compact();} selected
Loggable::compact();}
xywh {20 20 40 25}
}
Submenu {} {
@ -210,15 +202,7 @@ Loggable::compact();} selected
}
MenuItem {} {
label {&Quit}
callback {save();
save_timeline_settings();
Project::close();
printf( "dropped %d buffers\\n", engine->dropped() );
exit( 0 );}
callback {quit()}
xywh {40 40 40 25} shortcut 0x40071
}
}
@ -592,7 +576,7 @@ delete win;}
code0 {timeline = o;}
class Timeline
}
Fl_Box {} {
Fl_Box project_name {
label {<project name>}
xywh {450 0 475 22} labeltype SHADOW_LABEL labelfont 2
code0 {o->label( Project::name() );}
@ -634,7 +618,9 @@ else
transport->activate();
}
m->redraw();} {}
m->redraw();
project_name->redraw();} {selected
}
}
Function {update_progress( Fl_Progress *p, char *s, float v )} {open private return_type {static void}
} {
@ -673,7 +659,7 @@ xruns_output->value( engine->xruns() );} {}
} {
Fl_Window {} {
label About open
xywh {677 145 495 525} type Double visible
xywh {733 400 495 525} type Double visible
} {
Fl_Tabs {} {open
xywh {-4 122 507 419}
@ -726,7 +712,20 @@ with fast, light, reliable alternatives.}
code {if ( Project::open() )
{
((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Timeline" ), "options" );
}} {}
}
update_menu();
project_name->redraw();} {}
}
Function {quit()} {open
} {
code {Project::close();
save();
exit( 0 );} {}
}
}
@ -747,7 +746,7 @@ while ( _window->shown() )
} {
Fl_Window _window {
label {New Project} open
xywh {576 340 550 195} type Double modal visible
xywh {23 779 550 195} type Double modal visible
} {
Fl_File_Input _name {
label {Named:}

View File

@ -57,12 +57,13 @@ Engine *engine;
Timeline *timeline;
Transport *transport;
LASH *lash;
TLE *tle;
/* TODO: put these in a header */
#define USER_CONFIG_DIR ".non-daw/"
const char APP_NAME[] = "Non-DAW";
const char APP_TITLE[] = "The Non-DAW (Digital Audio Workstation)";
const char APP_TITLE[] = "The Non-DAW";
const char COPYRIGHT[] = "Copyright (C) 2008 Jonathan Moore Liles";
#define PACKAGE "non"
@ -116,7 +117,7 @@ main ( int argc, char **argv )
printf( "%s %s -- %s\n", APP_TITLE, VERSION, COPYRIGHT );
TLE tle;
tle = new TLE;
MESSAGE( "Initializing JACK" );
@ -142,8 +143,8 @@ main ( int argc, char **argv )
/* FIXME: open project in /tmp if none is given? */
MESSAGE( "Starting GUI" );
// tle.main_window->show( argc, argv );
tle.run();
tle->run();
MESSAGE( "Your fun is over" );
}