Browse Source

nsm-proxy: Rename 'Start' button to neutral 'Ok' if the program is already running to avoid double-start worries

tags/v1.5.0
Nils 4 years ago
parent
commit
1453324067
2 changed files with 22 additions and 4 deletions
  1. +20
    -2
      src/nsm-proxy-gui.cpp
  2. +2
    -2
      src/nsm-proxy.cpp

+ 20
- 2
src/nsm-proxy-gui.cpp View File

@@ -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();


+ 2
- 2
src/nsm-proxy.cpp View File

@@ -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 : "" );


}
};



Loading…
Cancel
Save