From b573200e8dba4633ed63030b9f9f2461e73b4740 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 17 Jun 2013 19:16:14 +0000 Subject: [PATCH] Corrigindo fontes editados em windows e desenho do spinner da OIA --- po/pt_BR.po | 8 ++++---- src/plugins/rx3270/pluginmain.cc | 445 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ src/pw3270/main.c | 2 ++ src/pw3270/v3270/oia.c | 26 +++++++++++++++----------- 4 files changed, 250 insertions(+), 231 deletions(-) diff --git a/po/pt_BR.po b/po/pt_BR.po index 9637a40..35d209e 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: pw3270 5.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-06-12 09:54-0300\n" +"POT-Creation-Date: 2013-06-17 11:06-0300\n" "PO-Revision-Date: 2013-05-08 14:30-0300\n" "Last-Translator: Perry Werneck \n" "Language-Team: Português <>\n" @@ -96,7 +96,7 @@ msgstr "- Emulador 3270 para GTK" msgid "16 colors" msgstr "16 cores" -#: screen.c:691 screen.c:721 screen.c:735 screen.c:854 +#: screen.c:691 screen.c:721 screen.c:735 screen.c:860 msgid "3270 Error" msgstr "Erro 3270" @@ -632,7 +632,7 @@ msgstr "Apagar até o final do campo" msgid "Erase to end of line" msgstr "Apagar até o final da linha" -#: print.c:238 v3270/widget.c:215 util.c:1009 +#: print.c:238 v3270/widget.c:215 util.c:1018 msgid "Error" msgstr "Erro" @@ -2070,7 +2070,7 @@ msgstr "Alvo inesperado \"%s\"" msgid "Unexpected type %d in typeahead queue" msgstr "Tipo inesperado %d na fila de teclado" -#: ctlr.c:583 +#: ctlr.c:588 #, c-format msgid "Unknown 3270 Data Stream command: 0x%X" msgstr "Unknown 3270 Data Stream command: 0x%X" diff --git a/src/plugins/rx3270/pluginmain.cc b/src/plugins/rx3270/pluginmain.cc index bede975..694eb39 100644 --- a/src/plugins/rx3270/pluginmain.cc +++ b/src/plugins/rx3270/pluginmain.cc @@ -48,6 +48,14 @@ #include #include +/*--[ Globals ]--------------------------------------------------------------------------------------*/ + +#if GTK_CHECK_VERSION(2,32,0) + static GMutex mutex; +#else + static GStaticMutex mutex = G_STATIC_MUTEX_INIT; +#endif // GTK_CHECK_VERSION + /*--[ Rexx application data block ]--------------------------------------------------------------------------*/ struct rexx_application_data @@ -58,6 +66,223 @@ }; +/*--[ Running rexx scripts ]---------------------------------------------------------------------------------*/ + + static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) + { + trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction); + + if(subfunction == RXSIOSAY) + { + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(((struct rexx_application_data * )context->GetApplicationData())->widget)), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK_CANCEL, + "%s", (((RXSIOSAY_PARM *) parmBlock)->rxsio_string).strptr ); + + gtk_window_set_title(GTK_WINDOW(dialog), _( "Script message" ) ); + + if(gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL) + context->RaiseException0(Rexx_Error_Program_interrupted); + + gtk_widget_destroy(dialog); + + return RXEXIT_HANDLED; + } + + return RXEXIT_NOT_HANDLED; + } + + static void call_rexx_script(GtkAction *action, GtkWidget *widget, const gchar *filename) + { + const gchar * args = (const gchar *) g_object_get_data(G_OBJECT(action),"args"); + + struct rexx_application_data appdata = { action, widget, filename }; + + RexxInstance * instance; + RexxThreadContext * threadContext; + RexxOption options[25]; + RexxContextExit exits[2]; + + memset(options,0,sizeof(options)); + memset(exits,0,sizeof(exits)); + + exits[0].sysexit_code = RXSIO; + exits[0].handler = Rexx_IO_exit; + + options[0].optionName = DIRECT_EXITS; + options[0].option = (void *) exits; + + options[1].optionName = APPLICATION_DATA; + options[1].option = (void *) &appdata; + + if(!RexxCreateInterpreter(&instance, &threadContext, options)) + { + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CANCEL, + _( "Can't start %s script" ), "rexx" ); + + gtk_window_set_title(GTK_WINDOW(dialog),_( "Rexx error" )); + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),_( "Can't create %s interpreter instance" ), "rexx"); + + gtk_dialog_run(GTK_DIALOG (dialog)); + gtk_widget_destroy(dialog); + } + else + { + RexxArrayObject rxArgs; + + trace("%s start",__FUNCTION__); + + if(args) + { + gchar **arg = g_strsplit(args,",",-1); + size_t sz = g_strv_length(arg); + + rxArgs = threadContext->NewArray(sz); + for(unsigned int i = 0; iArrayPut(rxArgs, threadContext->String(arg[i]), i + 1); + + g_strfreev(arg); + } + else + { + rxArgs = threadContext->NewArray(1); + threadContext->ArrayPut(rxArgs, threadContext->String(""),1); + } + + v3270_set_script(widget,'R',TRUE); + RexxObjectPtr result = threadContext->CallProgram(filename, rxArgs); + v3270_set_script(widget,'R',FALSE); + + if (threadContext->CheckCondition()) + { + RexxCondition condition; + + // retrieve the error information and get it into a decoded form + RexxDirectoryObject cond = threadContext->GetConditionInfo(); + threadContext->DecodeConditionInfo(cond, &condition); + // display the errors + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CANCEL, + _( "%s script failed" ), "Rexx" ); + + gtk_window_set_title(GTK_WINDOW(dialog),_( "Rexx error" )); + + gtk_message_dialog_format_secondary_text( + GTK_MESSAGE_DIALOG(dialog), + _( "%s error %d: %s\n%s" ), + "Rexx", + (int) condition.code, + threadContext->CString(condition.errortext), + threadContext->CString(condition.message) + + ); + + gtk_dialog_run(GTK_DIALOG (dialog)); + gtk_widget_destroy(dialog); + + } + else if (result != NULLOBJECT) + { + CSTRING resultString = threadContext->CString(result); + lib3270_write_log(NULL,"REXX","%s exits with rc=%s",filename,resultString); + } + + instance->Terminate(); + + trace("%s ends",__FUNCTION__); + } + + } + + +extern "C" +{ + LIB3270_EXPORT void pw3270_action_rexx_activated(GtkAction *action, GtkWidget *widget) + { + gchar *filename = (gchar *) g_object_get_data(G_OBJECT(action),"src"); + + lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p",gtk_action_get_name(action),widget); + +#if GTK_CHECK_VERSION(2,32,0) + if(!g_mutex_trylock(&mutex)) +#else + if(!g_static_mutex_trylock(&mutex)) +#endif // GTK_CHECK_VERSION + { + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CANCEL, + "%s", _( "Can't start script" )); + + gtk_window_set_title(GTK_WINDOW(dialog),_( "System busy" )); + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",_( "Please, try again in a few moments" )); + + gtk_dialog_run(GTK_DIALOG (dialog)); + gtk_widget_destroy(dialog); + return; + } + + gtk_action_set_sensitive(action,FALSE); + + if(filename) + { + // Has filename, call it directly + call_rexx_script(action,widget,filename); + } + else + { + // No filename, ask user + static const struct _list + { + const gchar *name; + const gchar *pattern; + } list[] = + { + { N_( "Rexx script file" ), "*.rex" }, + { N_( "Rexx class file" ), "*.cls" } + }; + + GtkFileFilter * filter[G_N_ELEMENTS(list)+1]; + unsigned int f; + + memset(filter,0,sizeof(filter)); + + for(f=0;fGetApplicationData())->widget)), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK_CANCEL, - "%s", (((RXSIOSAY_PARM *) parmBlock)->rxsio_string).strptr ); - - gtk_window_set_title(GTK_WINDOW(dialog), _( "Script message" ) ); - - if(gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL) - context->RaiseException0(Rexx_Error_Program_interrupted); - - gtk_widget_destroy(dialog); - - return RXEXIT_HANDLED; - } - - return RXEXIT_NOT_HANDLED; - } - - static void call_rexx_script(GtkAction *action, GtkWidget *widget, const gchar *filename) - { - const gchar * args = (const gchar *) g_object_get_data(G_OBJECT(action),"args"); - - struct rexx_application_data appdata = { action, widget, filename }; - - RexxInstance * instance; - RexxThreadContext * threadContext; - RexxOption options[25]; - RexxContextExit exits[2]; - - memset(options,0,sizeof(options)); - memset(exits,0,sizeof(exits)); - - exits[0].sysexit_code = RXSIO; - exits[0].handler = Rexx_IO_exit; - - options[0].optionName = DIRECT_EXITS; - options[0].option = (void *) exits; - - options[1].optionName = APPLICATION_DATA; - options[1].option = (void *) &appdata; - - if(!RexxCreateInterpreter(&instance, &threadContext, options)) - { - GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CANCEL, - _( "Can't start %s script" ), "rexx" ); - - gtk_window_set_title(GTK_WINDOW(dialog),_( "Rexx error" )); - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),_( "Can't create %s interpreter instance" ), "rexx"); - - gtk_dialog_run(GTK_DIALOG (dialog)); - gtk_widget_destroy(dialog); - } - else - { - RexxArrayObject rxArgs; - - trace("%s start",__FUNCTION__); - - if(args) - { - gchar **arg = g_strsplit(args,",",-1); - size_t sz = g_strv_length(arg); - - rxArgs = threadContext->NewArray(sz); - for(unsigned int i = 0; iArrayPut(rxArgs, threadContext->String(arg[i]), i + 1); - - g_strfreev(arg); - } - else - { - rxArgs = threadContext->NewArray(1); - threadContext->ArrayPut(rxArgs, threadContext->String(""),1); - } - - v3270_set_script(widget,'R',TRUE); - RexxObjectPtr result = threadContext->CallProgram(filename, rxArgs); - v3270_set_script(widget,'R',FALSE); - - if (threadContext->CheckCondition()) - { - RexxCondition condition; - - // retrieve the error information and get it into a decoded form - RexxDirectoryObject cond = threadContext->GetConditionInfo(); - threadContext->DecodeConditionInfo(cond, &condition); - // display the errors - GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CANCEL, - _( "%s script failed" ), "Rexx" ); - - gtk_window_set_title(GTK_WINDOW(dialog),_( "Rexx error" )); - - gtk_message_dialog_format_secondary_text( - GTK_MESSAGE_DIALOG(dialog), - _( "%s error %d: %s\n%s" ), - "Rexx", - (int) condition.code, - threadContext->CString(condition.errortext), - threadContext->CString(condition.message) - - ); - - gtk_dialog_run(GTK_DIALOG (dialog)); - gtk_widget_destroy(dialog); - - } - else if (result != NULLOBJECT) - { - CSTRING resultString = threadContext->CString(result); - lib3270_write_log(NULL,"REXX","%s exits with rc=%s",filename,resultString); - } - - instance->Terminate(); - - trace("%s ends",__FUNCTION__); - } - - } - - -extern "C" -{ - LIB3270_EXPORT void pw3270_action_rexx_activated(GtkAction *action, GtkWidget *widget) - { - gchar *filename = (gchar *) g_object_get_data(G_OBJECT(action),"src"); - - lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p",gtk_action_get_name(action),widget); - -#if GTK_CHECK_VERSION(2,32,0) - if(!g_mutex_trylock(&mutex)) #else if(!g_static_mutex_trylock(&mutex)) #endif // GTK_CHECK_VERSION - { - GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CANCEL, - "%s", _( "Can't start script" )); - - gtk_window_set_title(GTK_WINDOW(dialog),_( "System busy" )); - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",_( "Please, try again in a few moments" )); - - gtk_dialog_run(GTK_DIALOG (dialog)); - gtk_widget_destroy(dialog); - return; - } - - gtk_action_set_sensitive(action,FALSE); - - if(filename) - { - // Has filename, call it directly - call_rexx_script(action,widget,filename); - } - else - { - // No filename, ask user - static const struct _list - { - const gchar *name; - const gchar *pattern; - } list[] = - { - { N_( "Rexx script file" ), "*.rex" }, - { N_( "Rexx class file" ), "*.cls" } - }; - - GtkFileFilter * filter[G_N_ELEMENTS(list)+1]; - unsigned int f; - - memset(filter,0,sizeof(filter)); - - for(f=0;fterminal->oia_rect + V3270_OIA_SPINNER; + + rect = info->terminal->oia_rect + V3270_OIA_SPINNER; #ifdef DEBUG - cairo_set_source_rgb(cr,0.1,0.1,0.1); + cairo_set_source_rgb(cr,0.1,0.1,0.1); #else - gdk_cairo_set_source_rgba(cr,info->terminal->color+V3270_COLOR_OIA_BACKGROUND); + gdk_cairo_set_source_rgba(cr,info->terminal->color+V3270_COLOR_OIA_BACKGROUND); #endif - cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); - cairo_fill(cr); - gdk_cairo_set_source_rgba(cr,info->terminal->color+V3270_COLOR_OIA_FOREGROUND); + cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); + cairo_fill(cr); + + gdk_cairo_set_source_rgba(cr,info->terminal->color+V3270_COLOR_OIA_FOREGROUND); + + info->step = draw_spinner(cr, rect, info->terminal->color, info->step); + + gtk_widget_queue_draw_area(GTK_WIDGET(info->terminal),rect->x,rect->y,rect->width,rect->height); - info->step = draw_spinner(cr, rect, info->terminal->color, info->step); - gtk_widget_queue_draw_area(GTK_WIDGET(info->terminal),rect->x,rect->y,rect->width,rect->height); #endif // HAVE_LIBM cairo_destroy(cr); -- libgit2 0.21.2