NSM: Add stop/kill button for each client to GUI.

pull/3/head
Jonathan Moore Liles 2012-04-09 19:32:00 -07:00
parent 468c969162
commit 1d8d8b0548
2 changed files with 52 additions and 0 deletions

View File

@ -1789,6 +1789,31 @@ OSC_HANDLER( reply )
/* GUI operations */
/******************/
OSC_HANDLER( stop )
{
Client *c = get_client_by_id( &client, &argv[0]->s );
if ( c )
{
if ( c->pid != 0 )
{
kill( c->pid, SIGTERM );
if ( gui_is_active )
osc_server->send( gui_addr, "/reply", "Client stopped." );
}
}
else
{
if ( gui_is_active )
osc_server->send( gui_addr, "/error", -10, "No such client." );
}
return 0;
}
OSC_HANDLER( remove )
{
Client *c = get_client_by_id( &client, &argv[0]->s );
@ -2041,6 +2066,7 @@ int main(int argc, char *argv[])
/* */
osc_server->add_method( "/nsm/gui/gui_announce", "", OSC_NAME( gui_announce ), NULL, "" );
osc_server->add_method( "/nsm/gui/client/stop", "s", OSC_NAME( stop ), NULL, "client_id" );
osc_server->add_method( "/nsm/gui/client/remove", "s", OSC_NAME( remove ), NULL, "client_id" );
osc_server->add_method( "/nsm/gui/client/resume", "s", OSC_NAME( resume ), NULL, "client_id" );
osc_server->add_method( "/nsm/gui/client/save", "s", OSC_NAME( client_save ), NULL, "client_id" );

View File

@ -92,6 +92,7 @@ class NSM_Client : public Fl_Group
Fl_Light_Button *_gui;
Fl_Button *_remove_button;
Fl_Button *_restart_button;
Fl_Button *_kill_button;
void
set_label ( void )
@ -180,11 +181,17 @@ public:
{
_remove_button->show();
_restart_button->show();
_kill_button->hide();
_gui->deactivate();
_dirty->deactivate();
color( fl_darker( FL_RED ) );
redraw();
}
else
{
_gui->activate();
_dirty->activate();
_kill_button->show();
_restart_button->hide();
_remove_button->hide();
}
@ -272,6 +279,14 @@ public:
osc->send( (*d)->addr, "/nsm/gui/client/resume", _client_id );
}
}
else if ( o == _kill_button )
{
MESSAGE( "Sending stop" );
foreach_daemon ( d )
{
osc->send( (*d)->addr, "/nsm/gui/client/stop", _client_id );
}
}
}
@ -341,6 +356,17 @@ public:
o->callback( cb_button, this );
}
xx -= 25 + ss;
{ Fl_Button *o = _kill_button = new Fl_Button( xx, yy, 25, hh, "@square" );
o->labelsize( 9 );
o->box( FL_UP_BOX );
o->type(0);
o->color( FL_RED );
o->value( 0 );
o->tooltip( "Stop" );
o->callback( cb_button, this );
}
xx -= 25 + ss;