Mixer: Implement NSM dirtiness notification.
This commit is contained in:
parent
d67ee6605a
commit
676a98c17e
|
@ -382,6 +382,8 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
|
||||||
Fl::scheme( "plastic" );
|
Fl::scheme( "plastic" );
|
||||||
color_scheme( "dark" );
|
color_scheme( "dark" );
|
||||||
|
|
||||||
|
Loggable::dirty_callback( &Mixer::handle_dirty, this );
|
||||||
|
|
||||||
_rows = 1;
|
_rows = 1;
|
||||||
box( FL_NO_BOX );
|
box( FL_NO_BOX );
|
||||||
labelsize( 96 );
|
labelsize( 96 );
|
||||||
|
@ -668,6 +670,19 @@ Mixer::get_unique_track_name ( const char *name )
|
||||||
return strdup( pat );
|
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
|
void
|
||||||
Mixer::snapshot ( void )
|
Mixer::snapshot ( void )
|
||||||
|
|
|
@ -67,6 +67,8 @@ private:
|
||||||
|
|
||||||
void redraw_windows ( void );
|
void redraw_windows ( void );
|
||||||
|
|
||||||
|
static void handle_dirty ( int, void *v );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
int handle ( int m );
|
int handle ( int m );
|
||||||
|
|
|
@ -174,7 +174,7 @@ Project::save ( void )
|
||||||
|
|
||||||
int r = mixer->save();
|
int r = mixer->save();
|
||||||
|
|
||||||
Loggable::clear_dirty();
|
// Loggable::clear_dirty();
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
// return Loggable::save_unjournaled_state();
|
// return Loggable::save_unjournaled_state();
|
||||||
|
@ -282,7 +282,7 @@ Project::open ( const char *name )
|
||||||
|
|
||||||
// timeline->zoom_fit();
|
// timeline->zoom_fit();
|
||||||
|
|
||||||
Loggable::clear_dirty();
|
// Loggable::clear_dirty();
|
||||||
|
|
||||||
MESSAGE( "Loaded project \"%s\"", name );
|
MESSAGE( "Loaded project \"%s\"", name );
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ check_sigterm ( void * )
|
||||||
if ( got_sigterm )
|
if ( got_sigterm )
|
||||||
{
|
{
|
||||||
MESSAGE( "Got SIGTERM, quitting..." );
|
MESSAGE( "Got SIGTERM, quitting..." );
|
||||||
mixer->command_quit();
|
mixer->quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,9 @@ void *Loggable::_progress_callback_arg = NULL;
|
||||||
snapshot_func *Loggable::_snapshot_callback = NULL;
|
snapshot_func *Loggable::_snapshot_callback = NULL;
|
||||||
void *Loggable::_snapshot_callback_arg = NULL;
|
void *Loggable::_snapshot_callback_arg = NULL;
|
||||||
|
|
||||||
|
dirty_func *Loggable::_dirty_callback = NULL;
|
||||||
|
void *Loggable::_dirty_callback_arg = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loggable::~Loggable ( )
|
Loggable::~Loggable ( )
|
||||||
|
@ -213,6 +216,8 @@ Loggable::replay ( FILE *fp )
|
||||||
if ( _progress_callback )
|
if ( _progress_callback )
|
||||||
_progress_callback( 0, _progress_callback_arg );
|
_progress_callback( 0, _progress_callback_arg );
|
||||||
|
|
||||||
|
clear_dirty();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,6 +516,8 @@ Loggable::snapshot ( FILE *fp )
|
||||||
|
|
||||||
_fp = ofp;
|
_fp = ofp;
|
||||||
|
|
||||||
|
clear_dirty();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +719,7 @@ Loggable::log_end ( void )
|
||||||
|
|
||||||
log_print( _old_state, new_state );
|
log_print( _old_state, new_state );
|
||||||
|
|
||||||
++_dirty;
|
set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete new_state;
|
delete new_state;
|
||||||
|
@ -730,7 +737,7 @@ Loggable::log_end ( void )
|
||||||
void
|
void
|
||||||
Loggable::log_create ( void ) const
|
Loggable::log_create ( void ) const
|
||||||
{
|
{
|
||||||
++_dirty;
|
set_dirty();
|
||||||
|
|
||||||
if ( ! _fp )
|
if ( ! _fp )
|
||||||
/* replaying, don't bother */
|
/* replaying, don't bother */
|
||||||
|
@ -782,7 +789,7 @@ Loggable::log_destroy ( void ) const
|
||||||
/* the unjournaled state may have changed: make a note of it. */
|
/* the unjournaled state may have changed: make a note of it. */
|
||||||
record_unjournaled();
|
record_unjournaled();
|
||||||
|
|
||||||
++_dirty;
|
set_dirty();
|
||||||
|
|
||||||
if ( ! _fp )
|
if ( ! _fp )
|
||||||
/* tearing down... don't bother */
|
/* tearing down... don't bother */
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
typedef void (progress_func)( int, void * );
|
typedef void (progress_func)( int, void * );
|
||||||
typedef void (snapshot_func)( void * );
|
typedef void (snapshot_func)( void * );
|
||||||
|
typedef void (dirty_func)( int, void * );
|
||||||
|
|
||||||
class Log_Entry;
|
class Log_Entry;
|
||||||
class Loggable;
|
class Loggable;
|
||||||
|
@ -87,6 +88,9 @@ class Loggable
|
||||||
static snapshot_func *_snapshot_callback;
|
static snapshot_func *_snapshot_callback;
|
||||||
static void *_snapshot_callback_arg;
|
static void *_snapshot_callback_arg;
|
||||||
|
|
||||||
|
static dirty_func *_dirty_callback;
|
||||||
|
static void *_dirty_callback_arg;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static unsigned int _relative_id;
|
static unsigned int _relative_id;
|
||||||
|
@ -132,6 +136,10 @@ private:
|
||||||
|
|
||||||
static bool replay ( FILE *fp );
|
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:
|
public:
|
||||||
|
|
||||||
static bool replay ( const char *name );
|
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 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 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 );
|
static const char *escape ( const char *s );
|
||||||
|
|
||||||
unsigned int id ( void ) const { return _id; }
|
unsigned int id ( void ) const { return _id; }
|
||||||
|
@ -192,7 +202,6 @@ public:
|
||||||
static bool do_this ( const char *s, bool reverse );
|
static bool do_this ( const char *s, bool reverse );
|
||||||
|
|
||||||
static int dirty ( void ) { return _dirty; }
|
static int dirty ( void ) { return _dirty; }
|
||||||
static void clear_dirty ( void ) { _dirty = 0; }
|
|
||||||
|
|
||||||
void log_create ( void ) const;
|
void log_create ( void ) const;
|
||||||
|
|
||||||
|
|
|
@ -1608,6 +1608,9 @@ OSC_HANDLER( is_dirty )
|
||||||
|
|
||||||
Client *c = get_client_by_address( lo_message_get_source( msg ) );
|
Client *c = get_client_by_address( lo_message_get_source( msg ) );
|
||||||
|
|
||||||
|
if ( ! c )
|
||||||
|
return 0;
|
||||||
|
|
||||||
c->dirty = 1;
|
c->dirty = 1;
|
||||||
|
|
||||||
if ( gui_is_active )
|
if ( gui_is_active )
|
||||||
|
@ -1622,6 +1625,9 @@ OSC_HANDLER( is_clean )
|
||||||
|
|
||||||
Client *c = get_client_by_address( lo_message_get_source( msg ) );
|
Client *c = get_client_by_address( lo_message_get_source( msg ) );
|
||||||
|
|
||||||
|
if ( ! c )
|
||||||
|
return 0;
|
||||||
|
|
||||||
c->dirty = 0;
|
c->dirty = 0;
|
||||||
|
|
||||||
if ( gui_is_active )
|
if ( gui_is_active )
|
||||||
|
@ -1635,6 +1641,9 @@ OSC_HANDLER( message )
|
||||||
{
|
{
|
||||||
Client *c = get_client_by_address( lo_message_get_source( msg ) );
|
Client *c = get_client_by_address( lo_message_get_source( msg ) );
|
||||||
|
|
||||||
|
if ( ! c )
|
||||||
|
return 0;
|
||||||
|
|
||||||
if ( gui_is_active )
|
if ( gui_is_active )
|
||||||
osc_server->send( gui_addr, "/nsm/gui/client/message", c->client_id, argv[0]->i, &argv[1]->s );
|
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 ) );
|
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;
|
// const char *rpath = &argv[0]->s;
|
||||||
|
|
||||||
int err_code = argv[1]->i;
|
int err_code = argv[1]->i;
|
||||||
|
|
Loading…
Reference in New Issue