2 /*******************************************************************************/
3 /* Copyright (C) 2012 Jonathan Moore Liles */
5 /* This program is free software; you can redistribute it and/or modify it */
6 /* under the terms of the GNU General Public License as published by the */
7 /* Free Software Foundation; either version 2 of the License, or (at your */
8 /* option) any later version. */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
12 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
15 /* You should have received a copy of the GNU General Public License along */
16 /* with This program; see the file COPYING. If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /*******************************************************************************/
25 #include <sys/types.h>
32 #include "transport.H"
36 #define OSC_INTERVAL 0.2f
38 extern Transport transport;
39 extern char *instance_name;
41 extern NSM_Client *nsm;
45 NSM_Client::NSM_Client ( )
50 int command_open ( const char *name, const char *display_name, const char *client_id, char **out_msg );
51 int command_save ( char **out_msg );
55 NSM_Client::command_save ( char **out_msg )
57 if ( transport.rolling )
59 *out_msg = strdup( "Cannot save while transport is running." );
64 save_song( nsm->project_filename );
70 NSM_Client::command_open ( const char *name, const char *display_name, const char *client_id, char **out_msg )
72 if ( transport.rolling )
74 *out_msg = strdup( "Cannot open while transport is running." );
81 *out_msg = strdup( "Song has unsaved changes!" );
83 return ERR_UNSAVED_CHANGES;
87 free( instance_name );
89 instance_name = strdup( client_id );
91 if ( ! midi_is_active() )
104 asprintf( &new_filename, "%s.non", name );
108 if ( 0 == stat( new_filename, &st ) )
110 if ( ! load_song( new_filename ) )
112 *out_msg = strdup( "Could not open file" );
118 save_song( new_filename );
121 if ( nsm->project_filename )
122 free( nsm->project_filename );
124 nsm->project_filename = new_filename;
130 NSM_Client::command_active ( bool b )
134 ui->sm_indicator->value( 1 );
135 ui->sm_indicator->tooltip( session_manager_name() );
139 ui->sm_indicator->tooltip( NULL );
140 ui->sm_indicator->value( 0 );