Commit 8f241e95bb9c0a68f950370ea7b185c9ab9d1be9

Authored by perry.werneck@gmail.com
1 parent 714519b0

Incluindo popup com a saida dos programas rexx usando o formato do rexx v4

Showing 1 changed file with 51 additions and 3 deletions   Show diff stats
src/plugins/rx3270/pluginmain.cc
... ... @@ -48,6 +48,16 @@
48 48 #include <lib3270/actions.h>
49 49 #include <lib3270/log.h>
50 50  
  51 +/*--[ Rexx application data block ]--------------------------------------------------------------------------*/
  52 +
  53 + struct rexx_application_data
  54 + {
  55 + GtkAction * action;
  56 + GtkWidget * widget;
  57 + const gchar * filename;
  58 + };
  59 +
  60 +
51 61 /*--[ Plugin session object ]--------------------------------------------------------------------------------*/
52 62  
53 63 class plugin : public rx3270
... ... @@ -219,15 +229,53 @@
219 229 return lib3270_get_text(hSession,baddr,len);
220 230 }
221 231  
  232 + static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock)
  233 + {
  234 + trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction);
  235 +
  236 + if(subfunction == RXSIOSAY)
  237 + {
  238 + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(((struct rexx_application_data * )context->GetApplicationData())->widget)),
  239 + GTK_DIALOG_DESTROY_WITH_PARENT,
  240 + GTK_MESSAGE_INFO,
  241 + GTK_BUTTONS_OK_CANCEL,
  242 + "%s", (((RXSIOSAY_PARM *) parmBlock)->rxsio_string).strptr );
  243 +
  244 + gtk_window_set_title(GTK_WINDOW(dialog), _( "Script message" ) );
  245 +
  246 + if(gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL)
  247 + context->RaiseException0(Rexx_Error_Program_interrupted);
  248 +
  249 + gtk_widget_destroy(dialog);
  250 +
  251 + return RXEXIT_HANDLED;
  252 + }
  253 +
  254 + return RXEXIT_NOT_HANDLED;
  255 + }
  256 +
222 257 static void call_rexx_script(GtkAction *action, GtkWidget *widget, const gchar *filename)
223 258 {
224   - const gchar * args = (const gchar *) g_object_get_data(G_OBJECT(action),"args");
  259 + const gchar * args = (const gchar *) g_object_get_data(G_OBJECT(action),"args");
  260 +
  261 + struct rexx_application_data appdata = { action, widget, filename };
225 262  
226 263 RexxInstance * instance;
227 264 RexxThreadContext * threadContext;
228 265 RexxOption options[25];
  266 + RexxContextExit exits[2];
229 267  
230 268 memset(options,0,sizeof(options));
  269 + memset(exits,0,sizeof(exits));
  270 +
  271 + exits[0].sysexit_code = RXSIO;
  272 + exits[0].handler = Rexx_IO_exit;
  273 +
  274 + options[0].optionName = DIRECT_EXITS;
  275 + options[0].option = (void *) exits;
  276 +
  277 + options[1].optionName = APPLICATION_DATA;
  278 + options[1].option = (void *) &appdata;
231 279  
232 280 if(!RexxCreateInterpreter(&instance, &threadContext, options))
233 281 {
... ... @@ -278,9 +326,9 @@
278 326 GTK_DIALOG_DESTROY_WITH_PARENT,
279 327 GTK_MESSAGE_ERROR,
280 328 GTK_BUTTONS_CANCEL,
281   - "%s", _( "Script error" ));
  329 + "%s", _( "Rexx script failed" ));
282 330  
283   - gtk_window_set_title(GTK_WINDOW(dialog),_( "System busy" ));
  331 + gtk_window_set_title(GTK_WINDOW(dialog),_( "Rexx error" ));
284 332  
285 333 gtk_message_dialog_format_secondary_text(
286 334 GTK_MESSAGE_DIALOG(dialog),
... ...