diff --git a/po/pt_BR.po b/po/pt_BR.po index e1a58d2..ab6926c 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: 2016-10-20 08:58-0200\n" +"POT-Creation-Date: 2016-10-24 14:58-0200\n" "PO-Revision-Date: 2016-05-31 11:16-0300\n" "Last-Translator: Perry Werneck \n" "Language-Team: Português \n" @@ -151,6 +151,11 @@ msgstr "<%s> precisa do atributo %s" msgid "<%s> should be on toplevel" msgstr "<%s> deve estar no primeiro nível" +#: plugin.c:99 +#, fuzzy, c-format +msgid "%s\n" +msgstr "%s%s para %s" + #: v3270/widget.c:238 msgid "" "Identity not verified\n" @@ -443,6 +448,16 @@ msgstr "Não foi possível carregar %s" msgid "Can't load file" msgstr "Não foi possível carregar arquivo" +#: plugin.c:95 +#, fuzzy +msgid "Can't load plugin" +msgstr "Não foi possível carregar arquivo" + +#: plugin.c:93 +#, fuzzy, c-format +msgid "Can't load plugin %s" +msgstr "Não foi possível carregar %s" + #: main.c:297 msgid "Can't open file" msgstr "Não foi possível abrir arquivo" @@ -3169,14 +3184,6 @@ msgstr "translator-credits" #~ msgstr "Invalid charset entry '%s' (#%d)" #, fuzzy -#~ msgid "Can't load plugin" -#~ msgstr "Não foi possível carregar arquivo" - -#, fuzzy -#~ msgid "Can't load plugin %s" -#~ msgstr "Não foi possível carregar %s" - -#, fuzzy #~ msgid "Script" #~ msgstr "Scripts" diff --git a/src/include/pw3270.h b/src/include/pw3270.h index 9400486..84069f6 100644 --- a/src/include/pw3270.h +++ b/src/include/pw3270.h @@ -72,7 +72,7 @@ LIB3270_EXPORT void pw3270_set_host_type(GtkWidget *widget, const gchar *name); LIB3270_EXPORT int pw3270_set_session_color_type(GtkWidget *widget, unsigned short color_type); - LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group, const gchar *key, GtkFileFilter **filter, const gchar *title); +// LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group, const gchar *key, GtkFileFilter **filter, const gchar *title); LIB3270_EXPORT gchar * pw3270_get_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *def); LIB3270_EXPORT void pw3270_set_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *val); diff --git a/src/java/startstop.cc b/src/java/startstop.cc index 3f5ba85..67a75c6 100644 --- a/src/java/startstop.cc +++ b/src/java/startstop.cc @@ -117,28 +117,7 @@ extern "C" { { /* // No classname, ask user - static const struct _list - { - const gchar *name; - const gchar *pattern; - } list[] = - { - { N_( "Java class file" ), "*.class" } - }; - - GtkFileFilter * filter[G_N_ELEMENTS(list)+1]; - unsigned int f; - - memset(filter,0,sizeof(filter)); - - for(f=0;fCallProgram(filename, rxArgs); + trace("%s: Returns",filename); g_free(script_name); script_name = NULL; v3270_set_script(widget,'R',FALSE); @@ -415,6 +417,7 @@ 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); @@ -441,41 +444,22 @@ extern "C" pw3270_set_action_state(action,FALSE); - if(filename) + if(filename && *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;ffile_chooser_dialog(id, title, extension,filename); + debug("%s(%s)","rx3270_method_get_filename",action_name); return context->String(ret.c_str()); } diff --git a/src/plugins/rx3270/rx3270.h b/src/plugins/rx3270/rx3270.h index c61d73c..0972e6e 100644 --- a/src/plugins/rx3270/rx3270.h +++ b/src/plugins/rx3270/rx3270.h @@ -34,12 +34,6 @@ #include #include - #ifdef HAVE_OOREXXAPI_H - #include - #else - #error Only Rexx 4 - #endif - #include #include #include @@ -58,11 +52,13 @@ #ifdef WIN32 #define REXX_DEFAULT_CHARSET "CP1252" + #define int8_t REXX_INT8_T + #define ssize_t REXX_SSIZE_T #else #define REXX_DEFAULT_CHARSET "UTF-8" #endif // WIN32 -// #include +#include /*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/ diff --git a/src/pw3270/dialog.c b/src/pw3270/dialog.c index 211fd39..df1a171 100644 --- a/src/pw3270/dialog.c +++ b/src/pw3270/dialog.c @@ -33,6 +33,20 @@ #include "globals.h" #include + #if defined WIN32 + #include + + struct file { + OPENFILENAME ofn; + gboolean enabled; + char szName[260]; // buffer for file name + GtkFileChooserAction action; + BOOL ok; + }; + + + #endif // WIN32 + #if defined(HAVE_LIBSSL) #include #include @@ -520,8 +534,90 @@ g_free(info); } +#ifdef WIN32 +static gpointer select_file(struct file *fl) { + + + switch(fl->action) { + case GTK_FILE_CHOOSER_ACTION_SAVE: // Receber arquivo + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646839(v=vs.85).aspx + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646829(v=vs.85).aspx#open_file + fl->ofn.Flags = OFN_OVERWRITEPROMPT | OFN_CREATEPROMPT | OFN_HIDEREADONLY; + fl->ok = GetSaveFileName(&fl->ofn); + break; + + case GTK_FILE_CHOOSER_ACTION_OPEN: // Enviar arquivo + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646928(v=vs.85).aspx + fl->ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + fl->ok = GetOpenFileName(&fl->ofn); + break; + } + + fl->enabled = FALSE; + + return 0; +} +#endif // _WIN32 + LIB3270_EXPORT gchar * pw3270_file_chooser(GtkFileChooserAction action, const gchar *name, const gchar *title, const gchar *file, const gchar *ext) { + gchar * filename = NULL; + +#if defined(_WIN32) + + GThread * thd; + struct file fl; + GtkWidget * dialog = pw3270_get_toplevel(); + GdkWindow * win = gtk_widget_get_window(GTK_WIDGET(dialog)); + + gtk_widget_set_sensitive(GTK_WIDGET(dialog),FALSE); + + memset(&fl,0,sizeof(fl)); + fl.ofn.lStructSize = sizeof(fl.ofn); + fl.action = action; + fl.ofn.hwndOwner = GDK_WINDOW_HWND(win); + fl.ofn.lpstrFile = fl.szName; + fl.ofn.lpstrTitle = title; + + // Set lpstrFile[0] to '\0' so that GetOpenFileName does not + // use the contents of szFile to initialize itself. + fl.ofn.lpstrFile[0] = '\0'; + fl.ofn.nMaxFile = sizeof(fl.szName); + + fl.ofn.lpstrInitialDir = NULL; + fl.ofn.nMaxFileTitle = 0; + + // Guarda o valor atual + if(file && *file) + { + strncpy(fl.szName,file,fl.ofn.nMaxFile); + } + else + { + gchar *ptr = get_string_from_config("files",name,""); + if(*ptr) + strncpy(fl.szName,ptr,fl.ofn.nMaxFile); + else + fl.ofn.lpstrInitialDir = g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS); + g_free(ptr); + } + + thd = g_thread_new("GetFileName",(GThreadFunc) select_file, &fl); + + fl.enabled = TRUE; + while(fl.enabled) { + g_main_context_iteration(NULL,TRUE); + } + + g_thread_unref(thd); + + if(fl.ok) { + filename = g_strdup(fl.szName); + } + + gtk_widget_set_sensitive(GTK_WIDGET(dialog),TRUE); + +#else static const struct _btn { const gchar * button; @@ -537,7 +633,6 @@ GtkWidget * dialog; gchar * ptr; const gchar * button = GTK_STOCK_OK; - gchar * filename = NULL; int f; for(f=0;f 4095) + break; + + debug("%s",filter); + + memcpy(((char *) fl.ofn.lpstrFilter)+ix,filter,sz); + ix += sz; + filter = va_arg(args, const char *); + } + va_end (args); + debug("%s",fl.ofn.lpstrFilter); + fl.ofn.nFilterIndex = 1; + + fl.ofn.lpstrInitialDir = NULL; + fl.ofn.nMaxFileTitle = 0; + + // Guarda o valor atual + if(filename) + { + strncpy(fl.szName,filename,fl.ofn.nMaxFile); + g_free(filename); + filename = NULL; + } + + fl.action = GTK_FILE_CHOOSER_ACTION_OPEN; + + thd = g_thread_new("GetFileName",(GThreadFunc) select_file, &fl); + + fl.enabled = TRUE; + while(fl.enabled) { + g_main_context_iteration(NULL,TRUE); + } + + g_thread_unref(thd); + + if(fl.ok) { + filename = g_strdup(fl.szName); + } + + g_free( ((char *) fl.ofn.lpstrFilter) ); + gtk_widget_set_sensitive(GTK_WIDGET(dialog),TRUE); + +#else + GtkWidget * dialog = gtk_file_chooser_dialog_new( title, GTK_WINDOW(gtk_widget_get_toplevel(widget)), GTK_FILE_CHOOSER_ACTION_OPEN, @@ -164,28 +244,30 @@ LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog),FALSE); - ptr = pw3270_get_string(widget,group,key,NULL); - if(ptr) + if(filename) { - gtk_file_chooser_set_uri(GTK_FILE_CHOOSER(dialog),ptr); - g_free(ptr); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),filename); + g_free(filename); + filename = NULL; } if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - gchar *uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); - filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); - - pw3270_set_string(widget,group,key,uri); - g_free(uri); - } gtk_widget_destroy(dialog); +#endif + + if(filename && *filename) + { + pw3270_set_string(widget,group,key,filename); + } + return filename; } +*/ LIB3270_EXPORT gchar * pw3270_get_datadir(const gchar *first_element, ...) { -- libgit2 0.21.2