nsm-proxy: Add more instructions to GUI.

pull/3/head
Jonathan Moore Liles 2012-04-09 19:31:20 -07:00
parent b48ca7c44b
commit 468c969162
2 changed files with 43 additions and 18 deletions

View File

@ -7,40 +7,39 @@ class NSM_Proxy_UI {open
Function {make_window()} {open
} {
Fl_Window {} {
label {NSM Proxy} open selected
xywh {106 75 485 475} type Double visible
label {NSM Proxy} open
xywh {1011 106 490 665} type Double color 47 labelcolor 55 visible
} {
Fl_Box {} {
label {Command-line options are incompatible with robust session management, so the NSM protocol does not support them. This proxy exists to allow programs which require command-line options to be included in an NSM session. Be warned that referring to files outside of the session directory will impair your ability to reliably archive and transport sessions. Patching the program to use NSM natively will result in a better experience.
label {Command-line options are incompatible with robust session management for a variety of reasons, so the NSM server does not support them directly. This proxy exists to allow programs which require command-line options to be included in an NSM session. Be warned that referring to files outside of the session directory will impair your ability to reliably archive and transport sessions. Patching the program to use NSM natively will result in a better experience.
The program will be started with its current directory being a uniquely named directory under the current session directory. It is recommended that you only refer to files in the current directory.
The environment variables $NSM_CLIENT_ID and $NSM_SESSION_NAME will contain the unique client ID (suitable for use as e.g. a JACK client name) and the display name for the session, respectively.}
xywh {15 14 455 286} box ROUNDED_BOX color 64 labelcolor 55 align 128
} selected
xywh {15 11 460 233} box BORDER_BOX color 41 labelfont 8 labelcolor 55 align 128
}
Fl_File_Input executable_input {
label {Executable: }
xywh {115 316 350 33}
xywh {115 262 350 33}
}
Fl_Input arguments_input {
label {Arguments:}
xywh {115 358 350 28}
xywh {115 414 350 28}
}
Fl_Input label_input {
label {Label:}
xywh {115 396 350 28}
xywh {115 452 350 28}
}
Fl_Return_Button start_button {
label Start
xywh {375 435 88 25}
xywh {380 625 88 25}
}
Fl_Button kill_button {
label Kill
xywh {290 435 80 25} color 72
xywh {295 625 80 25} color 72 hide
}
Fl_Choice save_signal_choice {
label {Save Signal:} open
tooltip {Some programs may respond to a certain Unix signal by saving their state to the file specified on the command-line. Usually if this is the case, the signal will be SIGUSR1. However, if you pick the wrong one, the client will likely respond as if to KILL.} xywh {115 435 170 25} down_box BORDER_BOX
xywh {110 625 170 25} down_box BORDER_BOX
} {
MenuItem {} {
label None
@ -59,6 +58,14 @@ The environment variables $NSM_CLIENT_ID and $NSM_SESSION_NAME will contain the
xywh {30 30 40 24}
}
}
Fl_Box {} {
label {The environment variables $NSM_CLIENT_ID and $NSM_SESSION_NAME will contain the unique client ID (suitable for use as e.g. a JACK client name) and the display name for the session, respectively.}
xywh {15 312 460 87} box BORDER_BOX color 41 labelfont 8 labelcolor 55 align 128
}
Fl_Box {} {
label {Some (very few) programs may respond to a specific Unix signal by somehow saving their state. If 'Save Signal' is set to something other than 'None', then NSM Proxy will deliver the specified signal to the proxied process upon an NSM 'Save' event. Most programs will treat these signals just like SIGTERM and die. You have been warned.}
xywh {15 497 460 114} box BORDER_BOX color 41 labelfont 8 labelcolor 55 align 128
}
}
}
}

View File

@ -79,7 +79,7 @@ public:
::kill( _pid, SIGTERM );
}
void start ( const char *executable, const char *arguments )
bool start ( const char *executable, const char *arguments )
{
if ( _executable )
free( _executable );
@ -89,11 +89,15 @@ public:
_executable = strdup( executable );
_arguments = strdup( arguments );
start();
return start();
}
void start ( void )
bool start ( void )
{
if ( _pid )
/* already running */
return true;
int pid;
if ( ! (pid = fork()) )
{
@ -119,6 +123,7 @@ public:
_pid = pid;
return _pid > 0;
}
void save_signal ( int s )
@ -373,11 +378,19 @@ osc_show_gui ( const char *path, const char *types, lo_arg **argv, int argc, lo_
return 0;
}
void
hide_gui ( void )
{
if ( gui_pid )
{
kill( gui_pid, SIGTERM );
}
}
int
osc_hide_gui ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data )
{
if ( gui_pid )
kill( gui_pid, SIGTERM );
hide_gui();
lo_send_from( nsm_addr, losrv, LO_TT_IMMEDIATE, "/nsm/client/gui_is_hidden", "" );
@ -471,7 +484,10 @@ osc_save_signal ( const char *path, const char *types, lo_arg **argv, int argc,
int
osc_start ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data )
{
nsm_proxy->start( &argv[0]->s, &argv[1]->s );
if ( nsm_proxy->start( &argv[0]->s, &argv[1]->s ) );
{
hide_gui();
}
return 0;
}
@ -573,6 +589,8 @@ void handle_sigchld ( )
{
lo_send_from( nsm_addr, losrv, LO_TT_IMMEDIATE, "/nsm/client/gui_is_hidden", "" );
gui_pid = 0;
/* don't care... */
continue;
}