Mixer: Implement NSM dirtiness notification.

This commit is contained in:
Jonathan Moore Liles 2012-03-04 18:02:01 -08:00
parent d67ee6605a
commit 676a98c17e
7 changed files with 55 additions and 7 deletions

View File

@ -382,6 +382,8 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
Fl::scheme( "plastic" );
color_scheme( "dark" );
Loggable::dirty_callback( &Mixer::handle_dirty, this );
_rows = 1;
box( FL_NO_BOX );
labelsize( 96 );
@ -668,6 +670,19 @@ Mixer::get_unique_track_name ( const char *name )
return strdup( pat );
}
void
Mixer::handle_dirty ( int d, void *v )
{
//Mixer *m = (Mixer*)v;
if ( !nsm )
return;
if ( d == 1 )
nsm->is_dirty();
else if ( d == 0 )
nsm->is_clean();
}
void
Mixer::snapshot ( void )

View File

@ -67,6 +67,8 @@ private:
void redraw_windows ( void );
static void handle_dirty ( int, void *v );
protected:
int handle ( int m );

View File

@ -174,7 +174,7 @@ Project::save ( void )
int r = mixer->save();
Loggable::clear_dirty();
// Loggable::clear_dirty();
return r;
// return Loggable::save_unjournaled_state();
@ -282,7 +282,7 @@ Project::open ( const char *name )
// timeline->zoom_fit();
Loggable::clear_dirty();
// Loggable::clear_dirty();
MESSAGE( "Loaded project \"%s\"", name );

View File

@ -120,7 +120,7 @@ check_sigterm ( void * )
if ( got_sigterm )
{
MESSAGE( "Got SIGTERM, quitting..." );
mixer->command_quit();
mixer->quit();
}
}

View File

@ -59,6 +59,9 @@ void *Loggable::_progress_callback_arg = NULL;
snapshot_func *Loggable::_snapshot_callback = NULL;
void *Loggable::_snapshot_callback_arg = NULL;
dirty_func *Loggable::_dirty_callback = NULL;
void *Loggable::_dirty_callback_arg = NULL;
Loggable::~Loggable ( )
@ -213,6 +216,8 @@ Loggable::replay ( FILE *fp )
if ( _progress_callback )
_progress_callback( 0, _progress_callback_arg );
clear_dirty();
return true;
}
@ -511,6 +516,8 @@ Loggable::snapshot ( FILE *fp )
_fp = ofp;
clear_dirty();
return true;
}
@ -712,7 +719,7 @@ Loggable::log_end ( void )
log_print( _old_state, new_state );
++_dirty;
set_dirty();
}
delete new_state;
@ -730,7 +737,7 @@ Loggable::log_end ( void )
void
Loggable::log_create ( void ) const
{
++_dirty;
set_dirty();
if ( ! _fp )
/* replaying, don't bother */
@ -782,7 +789,7 @@ Loggable::log_destroy ( void ) const
/* the unjournaled state may have changed: make a note of it. */
record_unjournaled();
++_dirty;
set_dirty();
if ( ! _fp )
/* tearing down... don't bother */

View File

@ -35,6 +35,7 @@
typedef void (progress_func)( int, void * );
typedef void (snapshot_func)( void * );
typedef void (dirty_func)( int, void * );
class Log_Entry;
class Loggable;
@ -87,6 +88,9 @@ class Loggable
static snapshot_func *_snapshot_callback;
static void *_snapshot_callback_arg;
static dirty_func *_dirty_callback;
static void *_dirty_callback_arg;
private:
static unsigned int _relative_id;
@ -132,6 +136,10 @@ private:
static bool replay ( FILE *fp );
static void signal_dirty ( int v ) { if ( _dirty_callback ) _dirty_callback( v, _dirty_callback_arg ); }
static void set_dirty ( void ) { signal_dirty( ++_dirty ); }
static void clear_dirty ( void ) { signal_dirty( _dirty = 0 ); }
public:
static bool replay ( const char *name );
@ -141,6 +149,8 @@ public:
static void snapshot_callback ( snapshot_func *p, void *arg ) { _snapshot_callback = p; _snapshot_callback_arg = arg; }
static void progress_callback ( progress_func *p, void *arg ) { _progress_callback = p; _progress_callback_arg = arg;}
static void dirty_callback ( dirty_func *p, void *arg ) { _dirty_callback = p; _dirty_callback_arg = arg;}
static const char *escape ( const char *s );
unsigned int id ( void ) const { return _id; }
@ -192,7 +202,6 @@ public:
static bool do_this ( const char *s, bool reverse );
static int dirty ( void ) { return _dirty; }
static void clear_dirty ( void ) { _dirty = 0; }
void log_create ( void ) const;

View File

@ -1608,6 +1608,9 @@ OSC_HANDLER( is_dirty )
Client *c = get_client_by_address( lo_message_get_source( msg ) );
if ( ! c )
return 0;
c->dirty = 1;
if ( gui_is_active )
@ -1622,6 +1625,9 @@ OSC_HANDLER( is_clean )
Client *c = get_client_by_address( lo_message_get_source( msg ) );
if ( ! c )
return 0;
c->dirty = 0;
if ( gui_is_active )
@ -1635,6 +1641,9 @@ OSC_HANDLER( message )
{
Client *c = get_client_by_address( lo_message_get_source( msg ) );
if ( ! c )
return 0;
if ( gui_is_active )
osc_server->send( gui_addr, "/nsm/gui/client/message", c->client_id, argv[0]->i, &argv[1]->s );
@ -1650,6 +1659,12 @@ OSC_HANDLER( error )
{
Client *c = get_client_by_address( lo_message_get_source( msg ) );
if ( ! c )
{
WARNING( "Error from unknown client" );
return 0;
}
// const char *rpath = &argv[0]->s;
int err_code = argv[1]->i;