Browse Source

Improve LASH support.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
79b16b56c9
4 changed files with 105 additions and 34 deletions
  1. +59
    -3
      Timeline/LASH.C
  2. +17
    -2
      Timeline/Project.C
  3. +24
    -25
      Timeline/TLE.fl
  4. +5
    -4
      Timeline/main.C

+ 59
- 3
Timeline/LASH.C View File

@@ -19,10 +19,24 @@


/* actual implementation of our side of the LASH protocol */ /* 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 "LASH.H"
#include "Project.H"
#include "TLE.H" // all this just for quit()


#include "debug.h"
extern TLE *tle;


#include "debug.h"


LASH::LASH ( ) LASH::LASH ( )
{ {
@@ -32,12 +46,33 @@ LASH::~LASH ( )
{ {
} }



bool bool
LASH::handle_save_file ( const char *path ) LASH::handle_save_file ( const char *path )
{ {
MESSAGE( "LASH wants us to save \"%s\"", 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; return true;
} }


@@ -46,11 +81,32 @@ LASH::handle_restore_file ( const char *path )
{ {
MESSAGE( "LASH wants us to load \"%s\"", 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 void
LASH::handle_quit ( void ) LASH::handle_quit ( void )
{ {
MESSAGE( "LASH wants us to quit" ); MESSAGE( "LASH wants us to quit" );
tle->quit();
} }

+ 17
- 2
Timeline/Project.C View File

@@ -33,6 +33,10 @@ project state belongs to Timeline and other classes. */


#include "Timeline.H" // for sample_rate(); #include "Timeline.H" // for sample_rate();


#include "TLE.H" // all this just for load and save...

extern TLE *tle;

/* FIXME: wrong place for this */ /* FIXME: wrong place for this */
#define APP_TITLE "Non-DAW" #define APP_TITLE "Non-DAW"


@@ -45,9 +49,16 @@ bool Project::_is_open = false;
void void
Project::set_name ( const char *name ) Project::set_name ( const char *name )
{ {
char *s = rindex( name, '/' );
strcpy( Project::_name, name );

if ( Project::_name[ strlen( Project::_name ) - 1 ] == '/' )
Project::_name[ strlen( Project::_name ) - 1 ] = '\0';

char *s = rindex( Project::_name, '/' );


strcpy( Project::_name, s ? s + 1 : name );
s = s ? s + 1 : Project::_name;

memmove( Project::_name, s, strlen( s ) + 1 );


for ( s = Project::_name; *s; ++s ) for ( s = Project::_name; *s; ++s )
if ( *s == '_' || *s == '-' ) if ( *s == '_' || *s == '-' )
@@ -67,6 +78,8 @@ exists ( const char *name )
bool bool
Project::close ( void ) Project::close ( void )
{ {
tle->save_timeline_settings();

Loggable::close(); Loggable::close();


write_info(); write_info();
@@ -146,6 +159,8 @@ Project::open ( const char *name )


_is_open = true; _is_open = true;


tle->load_timeline_settings();

return true; return true;
} }




+ 24
- 25
Timeline/TLE.fl View File

@@ -165,9 +165,7 @@ main_window->redraw();}
} }
MenuItem {} { MenuItem {} {
label {&Open} 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(); Project::close();


@@ -176,13 +174,7 @@ if ( ! Project::open( name ) )
fl_alert( "Could not open \\"%s\\" as a Non-DAW project!", 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. // we are in a somewhar ambiguous state now with no project open.
}
else
{
load_timeline_settings();
}

update_menu();}
}}
xywh {10 10 40 25} xywh {10 10 40 25}
} }
MenuItem {} { MenuItem {} {
@@ -192,7 +184,7 @@ update_menu();}
if ( n != 2 ) if ( n != 2 )
return; return;
Loggable::compact();} selected
Loggable::compact();}
xywh {20 20 40 25} xywh {20 20 40 25}
} }
Submenu {} { Submenu {} {
@@ -210,15 +202,7 @@ Loggable::compact();} selected
} }
MenuItem {} { MenuItem {} {
label {&Quit} 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 xywh {40 40 40 25} shortcut 0x40071
} }
} }
@@ -592,7 +576,7 @@ delete win;}
code0 {timeline = o;} code0 {timeline = o;}
class Timeline class Timeline
} }
Fl_Box {} {
Fl_Box project_name {
label {<project name>} label {<project name>}
xywh {450 0 475 22} labeltype SHADOW_LABEL labelfont 2 xywh {450 0 475 22} labeltype SHADOW_LABEL labelfont 2
code0 {o->label( Project::name() );} code0 {o->label( Project::name() );}
@@ -634,7 +618,9 @@ else
transport->activate(); 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} 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 {} { Fl_Window {} {
label About open label About open
xywh {677 145 495 525} type Double visible
xywh {733 400 495 525} type Double visible
} { } {
Fl_Tabs {} {open Fl_Tabs {} {open
xywh {-4 122 507 419} xywh {-4 122 507 419}
@@ -726,7 +712,20 @@ with fast, light, reliable alternatives.}
code {if ( Project::open() ) code {if ( Project::open() )
{ {
((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Timeline" ), "options" ); ((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 { Fl_Window _window {
label {New Project} open 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 { Fl_File_Input _name {
label {Named:} label {Named:}


+ 5
- 4
Timeline/main.C View File

@@ -57,12 +57,13 @@ Engine *engine;
Timeline *timeline; Timeline *timeline;
Transport *transport; Transport *transport;
LASH *lash; LASH *lash;
TLE *tle;


/* TODO: put these in a header */ /* TODO: put these in a header */
#define USER_CONFIG_DIR ".non-daw/" #define USER_CONFIG_DIR ".non-daw/"


const char APP_NAME[] = "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"; const char COPYRIGHT[] = "Copyright (C) 2008 Jonathan Moore Liles";


#define PACKAGE "non" #define PACKAGE "non"
@@ -116,7 +117,7 @@ main ( int argc, char **argv )


printf( "%s %s -- %s\n", APP_TITLE, VERSION, COPYRIGHT ); printf( "%s %s -- %s\n", APP_TITLE, VERSION, COPYRIGHT );


TLE tle;
tle = new TLE;


MESSAGE( "Initializing JACK" ); MESSAGE( "Initializing JACK" );


@@ -142,8 +143,8 @@ main ( int argc, char **argv )
/* FIXME: open project in /tmp if none is given? */ /* FIXME: open project in /tmp if none is given? */


MESSAGE( "Starting GUI" ); MESSAGE( "Starting GUI" );
// tle.main_window->show( argc, argv );
tle.run();
tle->run();


MESSAGE( "Your fun is over" ); MESSAGE( "Your fun is over" );
} }

Loading…
Cancel
Save