diff --git a/src/nsm-proxy-gui.cpp b/src/nsm-proxy-gui.cpp index cc4a768..3a8a6f7 100644 --- a/src/nsm-proxy-gui.cpp +++ b/src/nsm-proxy-gui.cpp @@ -48,6 +48,8 @@ static char *client_error; int osc_update ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data ) { + //Updates are arriving one OSC message at a time. + printf( "Got update for %s\n", path ); Fl::lock(); @@ -56,8 +58,16 @@ osc_update ( const char *path, const char *types, lo_arg **argv, int argc, lo_me ui->label_input->value( &argv[0]->s ); else if (!strcmp( path, "/nsm/proxy/arguments" )) ui->arguments_input->value( &argv[0]->s ); - else if (!strcmp( path, "/nsm/proxy/executable" )) + else if (!strcmp( path, "/nsm/proxy/executable" )) { ui->executable_input->value( &argv[0]->s ); + if ( strcmp( &argv[0]->s , "") ) { + //We want to avoid that the button is always labeled 'Start', creating the + //false impression that a new sub-client instance is started each time you press it. + //If the string is empty there is no program running at the moment. + //This does not cover all cases but gets us there 90%, which is good enough for something cosmetic. + ui->start_button->label("Ok"); + } + } else if (!strcmp( path, "/nsm/proxy/config_file" )) ui->config_file_input->value( &argv[0]->s ); else if (!strcmp( path, "/nsm/proxy/save_signal" )) @@ -136,6 +146,9 @@ handle_kill ( Fl_Widget *o, void *v ) void handle_start ( Fl_Widget *o, void *v ) { + //Executed when Start Button is clicked. + //"/nsm/proxy/start" for the sub-client is always sent, no matter if the software already runs. + //nsm-proxy.cpp handles the redundancy. lo_send_from( nsmp_addr, losrv, LO_TT_IMMEDIATE, "/nsm/proxy/start", "sss", ui->executable_input->value(), ui->arguments_input->value(), @@ -232,6 +245,7 @@ check_error ( void *v ) { { Fl_Double_Window *o = new Fl_Double_Window(600,300+15,"Abnormal Termination"); + //Create a new floating Window that shows an error message. { Fl_Box *o = new Fl_Box(0+15,0+15,600-30,50); o->box(FL_BORDER_BOX); @@ -263,7 +277,9 @@ check_error ( void *v ) int main ( int argc, char **argv ) { - + //The NSM-Proxy GUI is a client that communicates with another binary, nsm-proxy via OSC. + //This GUI executable is actually closed and restarted each time you show/hide the GUI. + //In other words: it is not a persistent GUI state. //Command line parameters @@ -331,6 +347,8 @@ main ( int argc, char **argv ) lo_send_from( nsmp_addr, losrv, LO_TT_IMMEDIATE, "/nsm/proxy/update", "" ); + + w->show(); Fl::lock(); diff --git a/src/nsm-proxy.cpp b/src/nsm-proxy.cpp index 601cabd..65c1f65 100644 --- a/src/nsm-proxy.cpp +++ b/src/nsm-proxy.cpp @@ -210,6 +210,7 @@ public: bool dump ( const char *path ) { + //Dump current config to file. This happens quite often. char *fname; asprintf( &fname, "%s/%s", path, CONFIG_FILE_NAME ); @@ -301,6 +302,7 @@ public: void update ( lo_address to ) { + //Each send triggers one osc_update in the Proxy-GUI. MESSAGE( "Sending update" ); lo_send_from( to, losrv, LO_TT_IMMEDIATE, "/nsm/proxy/save_signal", "i", _save_signal ); @@ -310,8 +312,6 @@ public: lo_send_from( to, losrv, LO_TT_IMMEDIATE, "/nsm/proxy/config_file", "s", _config_file ? _config_file : "" ); lo_send_from( to, losrv, LO_TT_IMMEDIATE, "/nsm/proxy/stop_signal", "i", _stop_signal ); lo_send_from( to, losrv, LO_TT_IMMEDIATE, "/nsm/proxy/client_error", "s", _client_error ? _client_error : "" ); - - } };