Commit 9bca9fc6d1b5e345c396f488738e6343c3355b73
1 parent
ee2c5a31
Exists in
master
and in
5 other branches
Corrigindo erro na seleção de arquivos em windows.
Showing
10 changed files
with
238 additions
and
88 deletions
Show diff stats
po/pt_BR.po
| ... | ... | @@ -5,7 +5,7 @@ msgid "" |
| 5 | 5 | msgstr "" |
| 6 | 6 | "Project-Id-Version: pw3270 5.0\n" |
| 7 | 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 | 9 | "PO-Revision-Date: 2016-05-31 11:16-0300\n" |
| 10 | 10 | "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n" |
| 11 | 11 | "Language-Team: Português <perry.werneck@gmail.com>\n" |
| ... | ... | @@ -151,6 +151,11 @@ msgstr "<%s> precisa do atributo %s" |
| 151 | 151 | msgid "<%s> should be on toplevel" |
| 152 | 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 | 159 | #: v3270/widget.c:238 |
| 155 | 160 | msgid "" |
| 156 | 161 | "<b>Identity not verified</b>\n" |
| ... | ... | @@ -443,6 +448,16 @@ msgstr "Não foi possível carregar %s" |
| 443 | 448 | msgid "Can't load file" |
| 444 | 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 | 461 | #: main.c:297 |
| 447 | 462 | msgid "Can't open file" |
| 448 | 463 | msgstr "Não foi possível abrir arquivo" |
| ... | ... | @@ -3169,14 +3184,6 @@ msgstr "translator-credits" |
| 3169 | 3184 | #~ msgstr "Invalid charset entry '%s' (#%d)" |
| 3170 | 3185 | |
| 3171 | 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 | 3187 | #~ msgid "Script" |
| 3181 | 3188 | #~ msgstr "Scripts" |
| 3182 | 3189 | ... | ... |
src/include/pw3270.h
| ... | ... | @@ -72,7 +72,7 @@ |
| 72 | 72 | LIB3270_EXPORT void pw3270_set_host_type(GtkWidget *widget, const gchar *name); |
| 73 | 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 | 77 | LIB3270_EXPORT gchar * pw3270_get_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *def); |
| 78 | 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 "C" { |
| 117 | 117 | { |
| 118 | 118 | /* |
| 119 | 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 | 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 | 565 | |
| 566 | 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 | 569 | dbus_g_method_return(context, |
| 569 | 570 | v3270_transfer_file( |
| 570 | 571 | v3270_get_default_widget(), |
| ... | ... | @@ -577,6 +578,7 @@ void pw3270_dbus_filetransfer(PW3270Dbus *object, const gchar *local, const gcha |
| 577 | 578 | secspace, |
| 578 | 579 | dft |
| 579 | 580 | )); |
| 581 | + */ | |
| 580 | 582 | return; |
| 581 | 583 | } |
| 582 | 584 | ... | ... |
src/plugins/rx3270/pluginmain.cc
| ... | ... | @@ -333,7 +333,7 @@ |
| 333 | 333 | { |
| 334 | 334 | RexxArrayObject rxArgs; |
| 335 | 335 | |
| 336 | - trace("%s start",__FUNCTION__); | |
| 336 | + trace("%s %s(%s)",__FUNCTION__,filename,args); | |
| 337 | 337 | |
| 338 | 338 | if(args) |
| 339 | 339 | { |
| ... | ... | @@ -354,7 +354,9 @@ |
| 354 | 354 | |
| 355 | 355 | v3270_set_script(widget,'R',TRUE); |
| 356 | 356 | script_name = g_path_get_basename(filename); |
| 357 | + trace("%s: Calling",filename); | |
| 357 | 358 | RexxObjectPtr result = threadContext->CallProgram(filename, rxArgs); |
| 359 | + trace("%s: Returns",filename); | |
| 358 | 360 | g_free(script_name); |
| 359 | 361 | script_name = NULL; |
| 360 | 362 | v3270_set_script(widget,'R',FALSE); |
| ... | ... | @@ -415,6 +417,7 @@ extern "C" |
| 415 | 417 | { |
| 416 | 418 | LIB3270_EXPORT void pw3270_action_rexx_activated(GtkAction *action, GtkWidget *widget) |
| 417 | 419 | { |
| 420 | + | |
| 418 | 421 | gchar *filename = (gchar *) g_object_get_data(G_OBJECT(action),"src"); |
| 419 | 422 | |
| 420 | 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 "C" |
| 441 | 444 | |
| 442 | 445 | pw3270_set_action_state(action,FALSE); |
| 443 | 446 | |
| 444 | - if(filename) | |
| 447 | + if(filename && *filename) | |
| 445 | 448 | { |
| 446 | 449 | // Has filename, call it directly |
| 447 | 450 | call_rexx_script(action,widget,filename); |
| 448 | 451 | } |
| 449 | 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 | 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 | 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 | 742 | string plugin::file_chooser_dialog(int action, const char *title, const char *extension, const char *filename) |
| 759 | 743 | { |
| 760 | 744 | string rc; |
| 745 | + | |
| 761 | 746 | gchar * ptr = pw3270_file_chooser((GtkFileChooserAction) action, script_name ? script_name : "rexx", title, filename, extension); |
| 762 | 747 | |
| 763 | 748 | if(ptr) | ... | ... |
src/plugins/rx3270/rexx_methods.cc
| ... | ... | @@ -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 | 601 | ret = ((session *) sessionPtr)->file_chooser_dialog(id, title, extension,filename); |
| 602 | + debug("%s(%s)","rx3270_method_get_filename",action_name); | |
| 601 | 603 | |
| 602 | 604 | return context->String(ret.c_str()); |
| 603 | 605 | } | ... | ... |
src/plugins/rx3270/rx3270.h
| ... | ... | @@ -34,12 +34,6 @@ |
| 34 | 34 | #include <lib3270/config.h> |
| 35 | 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 | 37 | #include <errno.h> |
| 44 | 38 | #include <stdio.h> |
| 45 | 39 | #include <lib3270.h> |
| ... | ... | @@ -58,11 +52,13 @@ |
| 58 | 52 | |
| 59 | 53 | #ifdef WIN32 |
| 60 | 54 | #define REXX_DEFAULT_CHARSET "CP1252" |
| 55 | + #define int8_t REXX_INT8_T | |
| 56 | + #define ssize_t REXX_SSIZE_T | |
| 61 | 57 | #else |
| 62 | 58 | #define REXX_DEFAULT_CHARSET "UTF-8" |
| 63 | 59 | #endif // WIN32 |
| 64 | 60 | |
| 65 | -// #include <exception> | |
| 61 | +#include <oorexxapi.h> | |
| 66 | 62 | |
| 67 | 63 | /*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/ |
| 68 | 64 | ... | ... |
src/pw3270/dialog.c
| ... | ... | @@ -33,6 +33,20 @@ |
| 33 | 33 | #include "globals.h" |
| 34 | 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 | 50 | #if defined(HAVE_LIBSSL) |
| 37 | 51 | #include <openssl/ssl.h> |
| 38 | 52 | #include <openssl/err.h> |
| ... | ... | @@ -520,8 +534,90 @@ |
| 520 | 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 | 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 | 621 | static const struct _btn |
| 526 | 622 | { |
| 527 | 623 | const gchar * button; |
| ... | ... | @@ -537,7 +633,6 @@ |
| 537 | 633 | GtkWidget * dialog; |
| 538 | 634 | gchar * ptr; |
| 539 | 635 | const gchar * button = GTK_STOCK_OK; |
| 540 | - gchar * filename = NULL; | |
| 541 | 636 | int f; |
| 542 | 637 | |
| 543 | 638 | for(f=0;f<G_N_ELEMENTS(btn);f++) |
| ... | ... | @@ -562,7 +657,7 @@ |
| 562 | 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 | 662 | gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),file); |
| 568 | 663 | } |
| ... | ... | @@ -579,11 +674,13 @@ |
| 579 | 674 | if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
| 580 | 675 | { |
| 581 | 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 | 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 | 685 | return filename; |
| 589 | 686 | } | ... | ... |
src/pw3270/plugin.c
| ... | ... | @@ -66,6 +66,7 @@ |
| 66 | 66 | #ifdef WIN32 |
| 67 | 67 | // http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx |
| 68 | 68 | errorMode = SetErrorMode(1); |
| 69 | + SetErrorMode(errorMode); | |
| 69 | 70 | #endif // WIN32 |
| 70 | 71 | |
| 71 | 72 | name = g_dir_read_name(dir); |
| ... | ... | @@ -82,7 +83,7 @@ |
| 82 | 83 | if(!handle) |
| 83 | 84 | { |
| 84 | 85 | g_message("Error \"%s\" loading %s",g_module_error(),filename); |
| 85 | -/* | |
| 86 | + | |
| 86 | 87 | gchar * text = g_strdup(g_module_error()); |
| 87 | 88 | gchar * name = g_path_get_basename(filename); |
| 88 | 89 | GtkWidget * popup = gtk_message_dialog_new_with_markup( |
| ... | ... | @@ -102,11 +103,10 @@ |
| 102 | 103 | |
| 103 | 104 | g_free(text); |
| 104 | 105 | g_free(name); |
| 105 | -*/ | |
| 106 | 106 | } |
| 107 | 107 | else |
| 108 | 108 | { |
| 109 | - int (*init)(); | |
| 109 | + int (*init)() = NULL; | |
| 110 | 110 | |
| 111 | 111 | if(g_module_symbol(handle, "pw3270_plugin_init", (gpointer) &init)) |
| 112 | 112 | { |
| ... | ... | @@ -242,7 +242,7 @@ |
| 242 | 242 | |
| 243 | 243 | for(f=0;f<nPlugin;f++) |
| 244 | 244 | { |
| 245 | - int (*stop)(GtkWidget *, GtkWidget *); | |
| 245 | + int (*stop)(GtkWidget *, GtkWidget *) = NULL; | |
| 246 | 246 | |
| 247 | 247 | if(g_module_symbol(hPlugin[f], "pw3270_plugin_stop", (gpointer) &stop)) |
| 248 | 248 | stop(widget,pw3270_get_terminal_widget(widget)); |
| ... | ... | @@ -260,7 +260,7 @@ |
| 260 | 260 | trace("Unloading %d plugin(s)",nPlugin); |
| 261 | 261 | for(f=0;f<nPlugin;f++) |
| 262 | 262 | { |
| 263 | - void (*deinit)(void); | |
| 263 | + void (*deinit)(void) = NULL; | |
| 264 | 264 | |
| 265 | 265 | if(g_module_symbol(hPlugin[f], "pw3270_plugin_deinit", (gpointer) &deinit)) |
| 266 | 266 | deinit(); |
| ... | ... | @@ -288,7 +288,7 @@ |
| 288 | 288 | |
| 289 | 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 | 293 | if(g_module_symbol(hPlugin[f], fname, (gpointer) &setup)) |
| 294 | 294 | { |
| ... | ... | @@ -305,7 +305,7 @@ |
| 305 | 305 | |
| 306 | 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 | 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 | 143 | return TRUE; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | +/* | |
| 146 | 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 | 230 | GtkWidget * dialog = gtk_file_chooser_dialog_new( title, |
| 151 | 231 | GTK_WINDOW(gtk_widget_get_toplevel(widget)), |
| 152 | 232 | GTK_FILE_CHOOSER_ACTION_OPEN, |
| ... | ... | @@ -164,28 +244,30 @@ LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group |
| 164 | 244 | |
| 165 | 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 | 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 | 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 | 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 | 268 | return filename; |
| 188 | 269 | } |
| 270 | +*/ | |
| 189 | 271 | |
| 190 | 272 | LIB3270_EXPORT gchar * pw3270_get_datadir(const gchar *first_element, ...) |
| 191 | 273 | { | ... | ... |