Commit 9bca9fc6d1b5e345c396f488738e6343c3355b73

Authored by Perry Werneck
1 parent ee2c5a31

Corrigindo erro na seleção de arquivos em windows.

@@ -5,7 +5,7 @@ msgid "" @@ -5,7 +5,7 @@ msgid ""
5 msgstr "" 5 msgstr ""
6 "Project-Id-Version: pw3270 5.0\n" 6 "Project-Id-Version: pw3270 5.0\n"
7 "Report-Msgid-Bugs-To: \n" 7 "Report-Msgid-Bugs-To: \n"
8 -"POT-Creation-Date: 2016-10-20 08:58-0200\n" 8 +"POT-Creation-Date: 2016-10-24 14:58-0200\n"
9 "PO-Revision-Date: 2016-05-31 11:16-0300\n" 9 "PO-Revision-Date: 2016-05-31 11:16-0300\n"
10 "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n" 10 "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n"
11 "Language-Team: Português <perry.werneck@gmail.com>\n" 11 "Language-Team: Português <perry.werneck@gmail.com>\n"
@@ -151,6 +151,11 @@ msgstr &quot;&lt;%s&gt; precisa do atributo %s&quot; @@ -151,6 +151,11 @@ msgstr &quot;&lt;%s&gt; precisa do atributo %s&quot;
151 msgid "<%s> should be on toplevel" 151 msgid "<%s> should be on toplevel"
152 msgstr "<%s> deve estar no primeiro nível" 152 msgstr "<%s> deve estar no primeiro nível"
153 153
  154 +#: plugin.c:99
  155 +#, fuzzy, c-format
  156 +msgid "<b>%s</b>\n"
  157 +msgstr "%s<b>%s</b> para %s"
  158 +
154 #: v3270/widget.c:238 159 #: v3270/widget.c:238
155 msgid "" 160 msgid ""
156 "<b>Identity not verified</b>\n" 161 "<b>Identity not verified</b>\n"
@@ -443,6 +448,16 @@ msgstr &quot;Não foi possível carregar %s&quot; @@ -443,6 +448,16 @@ msgstr &quot;Não foi possível carregar %s&quot;
443 msgid "Can't load file" 448 msgid "Can't load file"
444 msgstr "Não foi possível carregar arquivo" 449 msgstr "Não foi possível carregar arquivo"
445 450
  451 +#: plugin.c:95
  452 +#, fuzzy
  453 +msgid "Can't load plugin"
  454 +msgstr "Não foi possível carregar arquivo"
  455 +
  456 +#: plugin.c:93
  457 +#, fuzzy, c-format
  458 +msgid "Can't load plugin %s"
  459 +msgstr "Não foi possível carregar %s"
  460 +
446 #: main.c:297 461 #: main.c:297
447 msgid "Can't open file" 462 msgid "Can't open file"
448 msgstr "Não foi possível abrir arquivo" 463 msgstr "Não foi possível abrir arquivo"
@@ -3169,14 +3184,6 @@ msgstr &quot;translator-credits&quot; @@ -3169,14 +3184,6 @@ msgstr &quot;translator-credits&quot;
3169 #~ msgstr "Invalid charset entry '%s' (#%d)" 3184 #~ msgstr "Invalid charset entry '%s' (#%d)"
3170 3185
3171 #, fuzzy 3186 #, fuzzy
3172 -#~ msgid "Can't load plugin"  
3173 -#~ msgstr "Não foi possível carregar arquivo"  
3174 -  
3175 -#, fuzzy  
3176 -#~ msgid "Can't load plugin %s"  
3177 -#~ msgstr "Não foi possível carregar %s"  
3178 -  
3179 -#, fuzzy  
3180 #~ msgid "Script" 3187 #~ msgid "Script"
3181 #~ msgstr "Scripts" 3188 #~ msgstr "Scripts"
3182 3189
src/include/pw3270.h
@@ -72,7 +72,7 @@ @@ -72,7 +72,7 @@
72 LIB3270_EXPORT void pw3270_set_host_type(GtkWidget *widget, const gchar *name); 72 LIB3270_EXPORT void pw3270_set_host_type(GtkWidget *widget, const gchar *name);
73 LIB3270_EXPORT int pw3270_set_session_color_type(GtkWidget *widget, unsigned short color_type); 73 LIB3270_EXPORT int pw3270_set_session_color_type(GtkWidget *widget, unsigned short color_type);
74 74
75 - LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group, const gchar *key, GtkFileFilter **filter, const gchar *title); 75 +// LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group, const gchar *key, GtkFileFilter **filter, const gchar *title);
76 76
77 LIB3270_EXPORT gchar * pw3270_get_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *def); 77 LIB3270_EXPORT gchar * pw3270_get_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *def);
78 LIB3270_EXPORT void pw3270_set_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *val); 78 LIB3270_EXPORT void pw3270_set_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *val);
src/java/startstop.cc
@@ -117,28 +117,7 @@ extern &quot;C&quot; { @@ -117,28 +117,7 @@ extern &quot;C&quot; {
117 { 117 {
118 /* 118 /*
119 // No classname, ask user 119 // No classname, ask user
120 - static const struct _list  
121 - {  
122 - const gchar *name;  
123 - const gchar *pattern;  
124 - } list[] =  
125 - {  
126 - { N_( "Java class file" ), "*.class" }  
127 - };  
128 -  
129 - GtkFileFilter * filter[G_N_ELEMENTS(list)+1];  
130 - unsigned int f;  
131 -  
132 - memset(filter,0,sizeof(filter));  
133 -  
134 - for(f=0;f<G_N_ELEMENTS(list);f++)  
135 - {  
136 - filter[f] = gtk_file_filter_new();  
137 - gtk_file_filter_set_name(filter[f],gettext(list[f].name));  
138 - gtk_file_filter_add_pattern(filter[f],list[f].pattern);  
139 - }  
140 -  
141 - filename = pw3270_get_filename(widget,"java","script",filter,_( "Select script to run" )); 120 + filename = pw3270_file_chooser(GTK_FILE_CHOOSER_ACTION_OPEN, "java", _( "Select script to run" ), "", "class");
142 121
143 if(filename) 122 if(filename)
144 { 123 {
src/plugins/dbus3270/gobject.c
@@ -565,6 +565,7 @@ void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvoc @@ -565,6 +565,7 @@ void pw3270_dbus_asc2ebc(PW3270Dbus *object, const gchar *from, DBusGMethodInvoc
565 565
566 void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context) 566 void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gchar *remote, int flags, int lrecl, int blksize, int primspace, int secspace, int dft, DBusGMethodInvocation *context)
567 { 567 {
  568 + /*
568 dbus_g_method_return(context, 569 dbus_g_method_return(context,
569 v3270_transfer_file( 570 v3270_transfer_file(
570 v3270_get_default_widget(), 571 v3270_get_default_widget(),
@@ -577,6 +578,7 @@ void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gcha @@ -577,6 +578,7 @@ void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gcha
577 secspace, 578 secspace,
578 dft 579 dft
579 )); 580 ));
  581 + */
580 return; 582 return;
581 } 583 }
582 584
src/plugins/rx3270/pluginmain.cc
@@ -333,7 +333,7 @@ @@ -333,7 +333,7 @@
333 { 333 {
334 RexxArrayObject rxArgs; 334 RexxArrayObject rxArgs;
335 335
336 - trace("%s start",__FUNCTION__); 336 + trace("%s %s(%s)",__FUNCTION__,filename,args);
337 337
338 if(args) 338 if(args)
339 { 339 {
@@ -354,7 +354,9 @@ @@ -354,7 +354,9 @@
354 354
355 v3270_set_script(widget,'R',TRUE); 355 v3270_set_script(widget,'R',TRUE);
356 script_name = g_path_get_basename(filename); 356 script_name = g_path_get_basename(filename);
  357 + trace("%s: Calling",filename);
357 RexxObjectPtr result = threadContext->CallProgram(filename, rxArgs); 358 RexxObjectPtr result = threadContext->CallProgram(filename, rxArgs);
  359 + trace("%s: Returns",filename);
358 g_free(script_name); 360 g_free(script_name);
359 script_name = NULL; 361 script_name = NULL;
360 v3270_set_script(widget,'R',FALSE); 362 v3270_set_script(widget,'R',FALSE);
@@ -415,6 +417,7 @@ extern &quot;C&quot; @@ -415,6 +417,7 @@ extern &quot;C&quot;
415 { 417 {
416 LIB3270_EXPORT void pw3270_action_rexx_activated(GtkAction *action, GtkWidget *widget) 418 LIB3270_EXPORT void pw3270_action_rexx_activated(GtkAction *action, GtkWidget *widget)
417 { 419 {
  420 +
418 gchar *filename = (gchar *) g_object_get_data(G_OBJECT(action),"src"); 421 gchar *filename = (gchar *) g_object_get_data(G_OBJECT(action),"src");
419 422
420 lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p",gtk_action_get_name(action),widget); 423 lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p",gtk_action_get_name(action),widget);
@@ -441,41 +444,22 @@ extern &quot;C&quot; @@ -441,41 +444,22 @@ extern &quot;C&quot;
441 444
442 pw3270_set_action_state(action,FALSE); 445 pw3270_set_action_state(action,FALSE);
443 446
444 - if(filename) 447 + if(filename && *filename)
445 { 448 {
446 // Has filename, call it directly 449 // Has filename, call it directly
447 call_rexx_script(action,widget,filename); 450 call_rexx_script(action,widget,filename);
448 } 451 }
449 else 452 else
450 { 453 {
451 - // No filename, ask user  
452 - static const struct _list  
453 - {  
454 - const gchar *name;  
455 - const gchar *pattern;  
456 - } list[] =  
457 - {  
458 - { N_( "Rexx script file" ), "*.rex" },  
459 - { N_( "Rexx class file" ), "*.cls" }  
460 - };  
461 454
462 - GtkFileFilter * filter[G_N_ELEMENTS(list)+1];  
463 - unsigned int f;  
464 -  
465 - memset(filter,0,sizeof(filter));  
466 -  
467 - for(f=0;f<G_N_ELEMENTS(list);f++)  
468 - {  
469 - filter[f] = gtk_file_filter_new();  
470 - gtk_file_filter_set_name(filter[f],gettext(list[f].name));  
471 - gtk_file_filter_add_pattern(filter[f],list[f].pattern);  
472 - }  
473 -  
474 - filename = pw3270_get_filename(widget,"rexx","script",filter,_( "Select script to run" )); 455 + filename = pw3270_file_chooser(GTK_FILE_CHOOSER_ACTION_OPEN, "rexx", _( "Select script to run" ), NULL, "rex");
475 456
476 if(filename) 457 if(filename)
477 { 458 {
478 - call_rexx_script(action,widget,filename); 459 + if(*filename)
  460 + {
  461 + call_rexx_script(action,widget,filename);
  462 + }
479 g_free(filename); 463 g_free(filename);
480 } 464 }
481 465
@@ -758,6 +742,7 @@ int plugin::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *mess @@ -758,6 +742,7 @@ int plugin::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *mess
758 string plugin::file_chooser_dialog(int action, const char *title, const char *extension, const char *filename) 742 string plugin::file_chooser_dialog(int action, const char *title, const char *extension, const char *filename)
759 { 743 {
760 string rc; 744 string rc;
  745 +
761 gchar * ptr = pw3270_file_chooser((GtkFileChooserAction) action, script_name ? script_name : "rexx", title, filename, extension); 746 gchar * ptr = pw3270_file_chooser((GtkFileChooserAction) action, script_name ? script_name : "rexx", title, filename, extension);
762 747
763 if(ptr) 748 if(ptr)
src/plugins/rx3270/rexx_methods.cc
@@ -597,7 +597,9 @@ RexxMethod5(RexxStringObject, rx3270_method_get_filename, CSELF, sessionPtr, CST @@ -597,7 +597,9 @@ RexxMethod5(RexxStringObject, rx3270_method_get_filename, CSELF, sessionPtr, CST
597 } 597 }
598 } 598 }
599 599
  600 + debug("%s(%s)","rx3270_method_get_filename",action_name);
600 ret = ((session *) sessionPtr)->file_chooser_dialog(id, title, extension,filename); 601 ret = ((session *) sessionPtr)->file_chooser_dialog(id, title, extension,filename);
  602 + debug("%s(%s)","rx3270_method_get_filename",action_name);
601 603
602 return context->String(ret.c_str()); 604 return context->String(ret.c_str());
603 } 605 }
src/plugins/rx3270/rx3270.h
@@ -34,12 +34,6 @@ @@ -34,12 +34,6 @@
34 #include <lib3270/config.h> 34 #include <lib3270/config.h>
35 #include <stdint.h> 35 #include <stdint.h>
36 36
37 - #ifdef HAVE_OOREXXAPI_H  
38 - #include <oorexxapi.h>  
39 - #else  
40 - #error Only Rexx 4  
41 - #endif  
42 -  
43 #include <errno.h> 37 #include <errno.h>
44 #include <stdio.h> 38 #include <stdio.h>
45 #include <lib3270.h> 39 #include <lib3270.h>
@@ -58,11 +52,13 @@ @@ -58,11 +52,13 @@
58 52
59 #ifdef WIN32 53 #ifdef WIN32
60 #define REXX_DEFAULT_CHARSET "CP1252" 54 #define REXX_DEFAULT_CHARSET "CP1252"
  55 + #define int8_t REXX_INT8_T
  56 + #define ssize_t REXX_SSIZE_T
61 #else 57 #else
62 #define REXX_DEFAULT_CHARSET "UTF-8" 58 #define REXX_DEFAULT_CHARSET "UTF-8"
63 #endif // WIN32 59 #endif // WIN32
64 60
65 -// #include <exception> 61 +#include <oorexxapi.h>
66 62
67 /*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/ 63 /*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/
68 64
src/pw3270/dialog.c
@@ -33,6 +33,20 @@ @@ -33,6 +33,20 @@
33 #include "globals.h" 33 #include "globals.h"
34 #include <v3270.h> 34 #include <v3270.h>
35 35
  36 + #if defined WIN32
  37 + #include <gdk/gdkwin32.h>
  38 +
  39 + struct file {
  40 + OPENFILENAME ofn;
  41 + gboolean enabled;
  42 + char szName[260]; // buffer for file name
  43 + GtkFileChooserAction action;
  44 + BOOL ok;
  45 + };
  46 +
  47 +
  48 + #endif // WIN32
  49 +
36 #if defined(HAVE_LIBSSL) 50 #if defined(HAVE_LIBSSL)
37 #include <openssl/ssl.h> 51 #include <openssl/ssl.h>
38 #include <openssl/err.h> 52 #include <openssl/err.h>
@@ -520,8 +534,90 @@ @@ -520,8 +534,90 @@
520 g_free(info); 534 g_free(info);
521 } 535 }
522 536
  537 +#ifdef WIN32
  538 +static gpointer select_file(struct file *fl) {
  539 +
  540 +
  541 + switch(fl->action) {
  542 + case GTK_FILE_CHOOSER_ACTION_SAVE: // Receber arquivo
  543 + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646839(v=vs.85).aspx
  544 + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646829(v=vs.85).aspx#open_file
  545 + fl->ofn.Flags = OFN_OVERWRITEPROMPT | OFN_CREATEPROMPT | OFN_HIDEREADONLY;
  546 + fl->ok = GetSaveFileName(&fl->ofn);
  547 + break;
  548 +
  549 + case GTK_FILE_CHOOSER_ACTION_OPEN: // Enviar arquivo
  550 + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646928(v=vs.85).aspx
  551 + fl->ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
  552 + fl->ok = GetOpenFileName(&fl->ofn);
  553 + break;
  554 + }
  555 +
  556 + fl->enabled = FALSE;
  557 +
  558 + return 0;
  559 +}
  560 +#endif // _WIN32
  561 +
523 LIB3270_EXPORT gchar * pw3270_file_chooser(GtkFileChooserAction action, const gchar *name, const gchar *title, const gchar *file, const gchar *ext) 562 LIB3270_EXPORT gchar * pw3270_file_chooser(GtkFileChooserAction action, const gchar *name, const gchar *title, const gchar *file, const gchar *ext)
524 { 563 {
  564 + gchar * filename = NULL;
  565 +
  566 +#if defined(_WIN32)
  567 +
  568 + GThread * thd;
  569 + struct file fl;
  570 + GtkWidget * dialog = pw3270_get_toplevel();
  571 + GdkWindow * win = gtk_widget_get_window(GTK_WIDGET(dialog));
  572 +
  573 + gtk_widget_set_sensitive(GTK_WIDGET(dialog),FALSE);
  574 +
  575 + memset(&fl,0,sizeof(fl));
  576 + fl.ofn.lStructSize = sizeof(fl.ofn);
  577 + fl.action = action;
  578 + fl.ofn.hwndOwner = GDK_WINDOW_HWND(win);
  579 + fl.ofn.lpstrFile = fl.szName;
  580 + fl.ofn.lpstrTitle = title;
  581 +
  582 + // Set lpstrFile[0] to '\0' so that GetOpenFileName does not
  583 + // use the contents of szFile to initialize itself.
  584 + fl.ofn.lpstrFile[0] = '\0';
  585 + fl.ofn.nMaxFile = sizeof(fl.szName);
  586 +
  587 + fl.ofn.lpstrInitialDir = NULL;
  588 + fl.ofn.nMaxFileTitle = 0;
  589 +
  590 + // Guarda o valor atual
  591 + if(file && *file)
  592 + {
  593 + strncpy(fl.szName,file,fl.ofn.nMaxFile);
  594 + }
  595 + else
  596 + {
  597 + gchar *ptr = get_string_from_config("files",name,"");
  598 + if(*ptr)
  599 + strncpy(fl.szName,ptr,fl.ofn.nMaxFile);
  600 + else
  601 + fl.ofn.lpstrInitialDir = g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS);
  602 + g_free(ptr);
  603 + }
  604 +
  605 + thd = g_thread_new("GetFileName",(GThreadFunc) select_file, &fl);
  606 +
  607 + fl.enabled = TRUE;
  608 + while(fl.enabled) {
  609 + g_main_context_iteration(NULL,TRUE);
  610 + }
  611 +
  612 + g_thread_unref(thd);
  613 +
  614 + if(fl.ok) {
  615 + filename = g_strdup(fl.szName);
  616 + }
  617 +
  618 + gtk_widget_set_sensitive(GTK_WIDGET(dialog),TRUE);
  619 +
  620 +#else
525 static const struct _btn 621 static const struct _btn
526 { 622 {
527 const gchar * button; 623 const gchar * button;
@@ -537,7 +633,6 @@ @@ -537,7 +633,6 @@
537 GtkWidget * dialog; 633 GtkWidget * dialog;
538 gchar * ptr; 634 gchar * ptr;
539 const gchar * button = GTK_STOCK_OK; 635 const gchar * button = GTK_STOCK_OK;
540 - gchar * filename = NULL;  
541 int f; 636 int f;
542 637
543 for(f=0;f<G_N_ELEMENTS(btn);f++) 638 for(f=0;f<G_N_ELEMENTS(btn);f++)
@@ -562,7 +657,7 @@ @@ -562,7 +657,7 @@
562 g_signal_connect(GTK_FILE_CHOOSER(dialog), "confirm-overwrite", G_CALLBACK(confirm_overwrite), G_OBJECT(dialog)); 657 g_signal_connect(GTK_FILE_CHOOSER(dialog), "confirm-overwrite", G_CALLBACK(confirm_overwrite), G_OBJECT(dialog));
563 } 658 }
564 659
565 - if(file) 660 + if(file && *file)
566 { 661 {
567 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),file); 662 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),file);
568 } 663 }
@@ -579,11 +674,13 @@ @@ -579,11 +674,13 @@
579 if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) 674 if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
580 { 675 {
581 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); 676 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
582 - if(filename)  
583 - set_string_to_config("files",name,"%s",filename);  
584 } 677 }
585 678
586 gtk_widget_destroy(dialog); 679 gtk_widget_destroy(dialog);
  680 +#endif // WIN32
  681 +
  682 + if(filename && *filename)
  683 + set_string_to_config("files",name,"%s",filename);
587 684
588 return filename; 685 return filename;
589 } 686 }
src/pw3270/plugin.c
@@ -66,6 +66,7 @@ @@ -66,6 +66,7 @@
66 #ifdef WIN32 66 #ifdef WIN32
67 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx 67 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx
68 errorMode = SetErrorMode(1); 68 errorMode = SetErrorMode(1);
  69 + SetErrorMode(errorMode);
69 #endif // WIN32 70 #endif // WIN32
70 71
71 name = g_dir_read_name(dir); 72 name = g_dir_read_name(dir);
@@ -82,7 +83,7 @@ @@ -82,7 +83,7 @@
82 if(!handle) 83 if(!handle)
83 { 84 {
84 g_message("Error \"%s\" loading %s",g_module_error(),filename); 85 g_message("Error \"%s\" loading %s",g_module_error(),filename);
85 -/* 86 +
86 gchar * text = g_strdup(g_module_error()); 87 gchar * text = g_strdup(g_module_error());
87 gchar * name = g_path_get_basename(filename); 88 gchar * name = g_path_get_basename(filename);
88 GtkWidget * popup = gtk_message_dialog_new_with_markup( 89 GtkWidget * popup = gtk_message_dialog_new_with_markup(
@@ -102,11 +103,10 @@ @@ -102,11 +103,10 @@
102 103
103 g_free(text); 104 g_free(text);
104 g_free(name); 105 g_free(name);
105 -*/  
106 } 106 }
107 else 107 else
108 { 108 {
109 - int (*init)(); 109 + int (*init)() = NULL;
110 110
111 if(g_module_symbol(handle, "pw3270_plugin_init", (gpointer) &init)) 111 if(g_module_symbol(handle, "pw3270_plugin_init", (gpointer) &init))
112 { 112 {
@@ -242,7 +242,7 @@ @@ -242,7 +242,7 @@
242 242
243 for(f=0;f<nPlugin;f++) 243 for(f=0;f<nPlugin;f++)
244 { 244 {
245 - int (*stop)(GtkWidget *, GtkWidget *); 245 + int (*stop)(GtkWidget *, GtkWidget *) = NULL;
246 246
247 if(g_module_symbol(hPlugin[f], "pw3270_plugin_stop", (gpointer) &stop)) 247 if(g_module_symbol(hPlugin[f], "pw3270_plugin_stop", (gpointer) &stop))
248 stop(widget,pw3270_get_terminal_widget(widget)); 248 stop(widget,pw3270_get_terminal_widget(widget));
@@ -260,7 +260,7 @@ @@ -260,7 +260,7 @@
260 trace("Unloading %d plugin(s)",nPlugin); 260 trace("Unloading %d plugin(s)",nPlugin);
261 for(f=0;f<nPlugin;f++) 261 for(f=0;f<nPlugin;f++)
262 { 262 {
263 - void (*deinit)(void); 263 + void (*deinit)(void) = NULL;
264 264
265 if(g_module_symbol(hPlugin[f], "pw3270_plugin_deinit", (gpointer) &deinit)) 265 if(g_module_symbol(hPlugin[f], "pw3270_plugin_deinit", (gpointer) &deinit))
266 deinit(); 266 deinit();
@@ -288,7 +288,7 @@ @@ -288,7 +288,7 @@
288 288
289 for(f=0;f<nPlugin;f++) 289 for(f=0;f<nPlugin;f++)
290 { 290 {
291 - int (*setup)(GtkAction *action, GtkWidget *widget); 291 + int (*setup)(GtkAction *action, GtkWidget *widget) = NULL;
292 292
293 if(g_module_symbol(hPlugin[f], fname, (gpointer) &setup)) 293 if(g_module_symbol(hPlugin[f], fname, (gpointer) &setup))
294 { 294 {
@@ -305,7 +305,7 @@ @@ -305,7 +305,7 @@
305 305
306 for(f=0;f<nPlugin;f++) 306 for(f=0;f<nPlugin;f++)
307 { 307 {
308 - void (*call)(GtkAction *action, GtkWidget *widget); 308 + void (*call)(GtkAction *action, GtkWidget *widget) = NULL;
309 309
310 if(g_module_symbol(hPlugin[f], fname, (gpointer) &call)) 310 if(g_module_symbol(hPlugin[f], fname, (gpointer) &call))
311 { 311 {
src/pw3270/tools.c
@@ -143,10 +143,90 @@ LIB3270_EXPORT gboolean pw3270_set_toggle_by_name(GtkWidget *widget, const gchar @@ -143,10 +143,90 @@ LIB3270_EXPORT gboolean pw3270_set_toggle_by_name(GtkWidget *widget, const gchar
143 return TRUE; 143 return TRUE;
144 } 144 }
145 145
  146 +/*
146 LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group, const gchar *key, GtkFileFilter **filter, const gchar *title) 147 LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group, const gchar *key, GtkFileFilter **filter, const gchar *title)
147 { 148 {
148 - gchar * filename = NULL;  
149 - gchar * ptr; 149 +
  150 + gchar * filename = pw3270_get_string(widget,group,key,NULL);
  151 +
  152 +#if defined(_WIN32)
  153 +
  154 + GThread * thd;
  155 + struct file fl;
  156 + GtkWidget * dialog = gtk_widget_get_toplevel(widget);
  157 + GdkWindow * win = gtk_widget_get_window(GTK_WIDGET(dialog));
  158 +
  159 + gtk_widget_set_sensitive(GTK_WIDGET(dialog),FALSE);
  160 +
  161 + memset(&fl,0,sizeof(fl));
  162 + fl.ofn.lStructSize = sizeof(fl.ofn);
  163 + fl.ofn.hwndOwner = GDK_WINDOW_HWND(win);
  164 + fl.ofn.lpstrFile = fl.szName;
  165 +
  166 + fl.ofn.lpstrTitle = title;
  167 +
  168 + // Set lpstrFile[0] to '\0' so that GetOpenFileName does not
  169 + // use the contents of szFile to initialize itself.
  170 + fl.ofn.lpstrFile[0] = '\0';
  171 +
  172 + fl.ofn.nMaxFile = sizeof(fl.szName);
  173 +
  174 + // Monta lista de arquivos.
  175 +// va_list args;
  176 +// size_t ix = 0;
  177 +
  178 + fl.ofn.lpstrFilter = (char *) g_malloc0(4096);
  179 +
  180 + va_start (args, filter);
  181 + while(filter) {
  182 +
  183 + filter = gettext(filter);
  184 + size_t sz = strlen(filter)+1;
  185 +
  186 + if(ix+sz > 4095)
  187 + break;
  188 +
  189 + debug("%s",filter);
  190 +
  191 + memcpy(((char *) fl.ofn.lpstrFilter)+ix,filter,sz);
  192 + ix += sz;
  193 + filter = va_arg(args, const char *);
  194 + }
  195 + va_end (args);
  196 + debug("%s",fl.ofn.lpstrFilter);
  197 + fl.ofn.nFilterIndex = 1;
  198 +
  199 + fl.ofn.lpstrInitialDir = NULL;
  200 + fl.ofn.nMaxFileTitle = 0;
  201 +
  202 + // Guarda o valor atual
  203 + if(filename)
  204 + {
  205 + strncpy(fl.szName,filename,fl.ofn.nMaxFile);
  206 + g_free(filename);
  207 + filename = NULL;
  208 + }
  209 +
  210 + fl.action = GTK_FILE_CHOOSER_ACTION_OPEN;
  211 +
  212 + thd = g_thread_new("GetFileName",(GThreadFunc) select_file, &fl);
  213 +
  214 + fl.enabled = TRUE;
  215 + while(fl.enabled) {
  216 + g_main_context_iteration(NULL,TRUE);
  217 + }
  218 +
  219 + g_thread_unref(thd);
  220 +
  221 + if(fl.ok) {
  222 + filename = g_strdup(fl.szName);
  223 + }
  224 +
  225 + g_free( ((char *) fl.ofn.lpstrFilter) );
  226 + gtk_widget_set_sensitive(GTK_WIDGET(dialog),TRUE);
  227 +
  228 +#else
  229 +
150 GtkWidget * dialog = gtk_file_chooser_dialog_new( title, 230 GtkWidget * dialog = gtk_file_chooser_dialog_new( title,
151 GTK_WINDOW(gtk_widget_get_toplevel(widget)), 231 GTK_WINDOW(gtk_widget_get_toplevel(widget)),
152 GTK_FILE_CHOOSER_ACTION_OPEN, 232 GTK_FILE_CHOOSER_ACTION_OPEN,
@@ -164,28 +244,30 @@ LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group @@ -164,28 +244,30 @@ LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group
164 244
165 gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog),FALSE); 245 gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog),FALSE);
166 246
167 - ptr = pw3270_get_string(widget,group,key,NULL);  
168 - if(ptr) 247 + if(filename)
169 { 248 {
170 - gtk_file_chooser_set_uri(GTK_FILE_CHOOSER(dialog),ptr);  
171 - g_free(ptr); 249 + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),filename);
  250 + g_free(filename);
  251 + filename = NULL;
172 } 252 }
173 253
174 if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) 254 if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
175 { 255 {
176 - gchar *uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));  
177 -  
178 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); 256 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
179 -  
180 - pw3270_set_string(widget,group,key,uri);  
181 - g_free(uri);  
182 -  
183 } 257 }
184 258
185 gtk_widget_destroy(dialog); 259 gtk_widget_destroy(dialog);
186 260
  261 +#endif
  262 +
  263 + if(filename && *filename)
  264 + {
  265 + pw3270_set_string(widget,group,key,filename);
  266 + }
  267 +
187 return filename; 268 return filename;
188 } 269 }
  270 +*/
189 271
190 LIB3270_EXPORT gchar * pw3270_get_datadir(const gchar *first_element, ...) 272 LIB3270_EXPORT gchar * pw3270_get_datadir(const gchar *first_element, ...)
191 { 273 {