Commit 7bce141e42c047273e3bcba48867b93c43f016c8
1 parent
3a062041
Exists in
master
and in
5 other branches
Implementando dialogo para obter nome de arquivo no plugin rexx
Showing
5 changed files
with
150 additions
and
149 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: 2013-06-17 11:06-0300\n" | |
8 | +"POT-Creation-Date: 2013-06-18 07:49-0300\n" | |
9 | 9 | "PO-Revision-Date: 2013-05-08 14:30-0300\n" |
10 | 10 | "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n" |
11 | 11 | "Language-Team: Português <>\n" |
... | ... | @@ -88,7 +88,7 @@ msgstr "%s: Familia %d é inválida" |
88 | 88 | msgid "%s:%d" |
89 | 89 | msgstr "%s:%d" |
90 | 90 | |
91 | -#: main.c:339 | |
91 | +#: main.c:341 | |
92 | 92 | msgid "- 3270 Emulator for Gtk" |
93 | 93 | msgstr "- Emulador 3270 para GTK" |
94 | 94 | |
... | ... | @@ -169,7 +169,7 @@ msgstr "" |
169 | 169 | msgid "<b>SSL state is undefined</b>Unexpected SSL status %ld" |
170 | 170 | msgstr "<b>Estado do SSL é indefinido</b>Estado SSL inesperado %ld" |
171 | 171 | |
172 | -#: main.c:359 | |
172 | +#: main.c:361 | |
173 | 173 | msgid "" |
174 | 174 | "<b>Valid options:</b>\n" |
175 | 175 | "\n" |
... | ... | @@ -222,7 +222,7 @@ msgid "An error occurred trying to allocate memory. This should never happen." |
222 | 222 | msgstr "" |
223 | 223 | "Ocorreu um erro ao tentar alocar memória. Isso nunca deveria acontecer." |
224 | 224 | |
225 | -#: main.c:319 main.c:321 | |
225 | +#: main.c:321 main.c:323 | |
226 | 226 | msgid "Application name" |
227 | 227 | msgstr "Nome da aplicação" |
228 | 228 | |
... | ... | @@ -731,7 +731,7 @@ msgstr "Tela cheia" |
731 | 731 | msgid "Function bar" |
732 | 732 | msgstr "Barra de funções" |
733 | 733 | |
734 | -#: main.c:93 main.c:406 | |
734 | +#: main.c:93 main.c:408 | |
735 | 735 | msgid "GTK Version mismatch" |
736 | 736 | msgstr "Divergência de versão GTK" |
737 | 737 | |
... | ... | @@ -800,11 +800,11 @@ msgstr "Servidor rejeitou o tipo de dispositivo ou requisição" |
800 | 800 | msgid "Host rejected resource(s)" |
801 | 801 | msgstr "Servidor rejeitou recurso(s)" |
802 | 802 | |
803 | -#: main.c:327 | |
803 | +#: main.c:329 | |
804 | 804 | msgid "Host system type" |
805 | 805 | msgstr "Tipo do sistema no servidor" |
806 | 806 | |
807 | -#: main.c:325 | |
807 | +#: main.c:327 | |
808 | 808 | msgid "Host to connect" |
809 | 809 | msgstr "Servidor a conectar" |
810 | 810 | |
... | ... | @@ -900,7 +900,7 @@ msgstr "LRECL:" |
900 | 900 | msgid "Lateral keypad" |
901 | 901 | msgstr "Barra lateral" |
902 | 902 | |
903 | -#: main.c:334 | |
903 | +#: main.c:336 | |
904 | 904 | #, fuzzy |
905 | 905 | msgid "Log to file" |
906 | 906 | msgstr "Salvar cópia para arquivo" |
... | ... | @@ -1139,7 +1139,7 @@ msgstr "PF8" |
1139 | 1139 | msgid "PF9" |
1140 | 1140 | msgstr "PF9" |
1141 | 1141 | |
1142 | -#: main.c:357 | |
1142 | +#: main.c:359 | |
1143 | 1143 | msgid "Parse error" |
1144 | 1144 | msgstr "Erro de interpretação" |
1145 | 1145 | |
... | ... | @@ -1176,7 +1176,7 @@ msgstr "Colar com margem esquerda" |
1176 | 1176 | msgid "Path length constraint exceeded" |
1177 | 1177 | msgstr "Path length constraint exceeded" |
1178 | 1178 | |
1179 | -#: main.c:322 | |
1179 | +#: main.c:324 | |
1180 | 1180 | msgid "Path to application data files" |
1181 | 1181 | msgstr "Caminho para os arquivos de dados da aplicação" |
1182 | 1182 | |
... | ... | @@ -1593,7 +1593,7 @@ msgstr "Enviar arquivo" |
1593 | 1593 | msgid "Send file to host" |
1594 | 1594 | msgstr "Enviar arquivo para o servidor" |
1595 | 1595 | |
1596 | -#: main.c:332 | |
1596 | +#: main.c:334 | |
1597 | 1597 | msgid "Send messages to syslog" |
1598 | 1598 | msgstr "Enviar mensagens para o log do sistema" |
1599 | 1599 | |
... | ... | @@ -1601,7 +1601,7 @@ msgstr "Enviar mensagens para o log do sistema" |
1601 | 1601 | msgid "Send/Receive" |
1602 | 1602 | msgstr "Enviar/Receber" |
1603 | 1603 | |
1604 | -#: main.c:324 | |
1604 | +#: main.c:326 | |
1605 | 1605 | msgid "Session name" |
1606 | 1606 | msgstr "Nome da sessão" |
1607 | 1607 | |
... | ... | @@ -1609,15 +1609,15 @@ msgstr "Nome da sessão" |
1609 | 1609 | msgid "Set hostname" |
1610 | 1610 | msgstr "Selecione servidor" |
1611 | 1611 | |
1612 | -#: main.c:326 | |
1612 | +#: main.c:328 | |
1613 | 1613 | msgid "Set reported colors (8/16)" |
1614 | 1614 | msgstr "Define número de cores informadas (8/16)" |
1615 | 1615 | |
1616 | -#: main.c:329 | |
1616 | +#: main.c:331 | |
1617 | 1617 | msgid "Set toggles OFF" |
1618 | 1618 | msgstr "Desativa toggles" |
1619 | 1619 | |
1620 | -#: main.c:328 | |
1620 | +#: main.c:330 | |
1621 | 1621 | msgid "Set toggles ON" |
1622 | 1622 | msgstr "Ativa toggles" |
1623 | 1623 | |
... | ... | @@ -1901,7 +1901,7 @@ msgstr "" |
1901 | 1901 | "programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple " |
1902 | 1902 | "Place, Suite 330, Boston, MA, 02111-1307, USA" |
1903 | 1903 | |
1904 | -#: main.c:402 | |
1904 | +#: main.c:404 | |
1905 | 1905 | #, c-format |
1906 | 1906 | msgid "This program requires GTK version %d.%d.%d" |
1907 | 1907 | msgstr "Este programa precisa do GTK versão %d.%d.%d" | ... | ... |
src/include/pw3270.h
... | ... | @@ -85,6 +85,8 @@ |
85 | 85 | |
86 | 86 | LIB3270_EXPORT gchar * pw3270_get_datadir(const gchar *first_element, ...); |
87 | 87 | |
88 | + LIB3270_EXPORT gchar * pw3270_file_chooser(GtkFileChooserAction action, const gchar *name, const gchar *title, const gchar *file, const gchar *ext); | |
89 | + | |
88 | 90 | typedef enum pw3270_src |
89 | 91 | { |
90 | 92 | PW3270_SRC_ALL, /**< Screen contents */ | ... | ... |
src/plugins/rx3270/pluginmain.cc
... | ... | @@ -51,11 +51,13 @@ |
51 | 51 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
52 | 52 | |
53 | 53 | #if GTK_CHECK_VERSION(2,32,0) |
54 | - static GMutex mutex; | |
54 | + static GMutex mutex; | |
55 | 55 | #else |
56 | 56 | static GStaticMutex mutex = G_STATIC_MUTEX_INIT; |
57 | 57 | #endif // GTK_CHECK_VERSION |
58 | 58 | |
59 | + static gchar * script_name = NULL; | |
60 | + | |
59 | 61 | /*--[ Rexx application data block ]--------------------------------------------------------------------------*/ |
60 | 62 | |
61 | 63 | struct rexx_application_data |
... | ... | @@ -65,6 +67,65 @@ |
65 | 67 | const gchar * filename; |
66 | 68 | }; |
67 | 69 | |
70 | +/*--[ Plugin session object ]--------------------------------------------------------------------------------*/ | |
71 | + | |
72 | + class plugin : public rx3270 | |
73 | + { | |
74 | + public: | |
75 | + plugin(H3270 *hSession); | |
76 | + virtual ~plugin(); | |
77 | + | |
78 | + void free(void *ptr); | |
79 | + | |
80 | + char * get_version(void); | |
81 | + LIB3270_CSTATE get_cstate(void); | |
82 | + int disconnect(void); | |
83 | + int connect(const char *uri, bool wait = true); | |
84 | + bool is_connected(void); | |
85 | + bool is_ready(void); | |
86 | + | |
87 | + void logva(const char *fmt, va_list args); | |
88 | + | |
89 | + int iterate(bool wait); | |
90 | + int wait(int seconds); | |
91 | + int wait_for_ready(int seconds); | |
92 | + | |
93 | + char * get_text(int baddr, size_t len); | |
94 | + char * get_text_at(int row, int col, size_t sz); | |
95 | + int cmp_text_at(int row, int col, const char *text); | |
96 | + int set_text_at(int row, int col, const char *str); | |
97 | + | |
98 | + int set_cursor_position(int row, int col); | |
99 | + int set_cursor_addr(int addr); | |
100 | + int get_cursor_addr(void); | |
101 | + int emulate_input(const char *str); | |
102 | + | |
103 | + int set_toggle(LIB3270_TOGGLE ix, bool value); | |
104 | + | |
105 | + int enter(void); | |
106 | + int pfkey(int key); | |
107 | + int pakey(int key); | |
108 | + | |
109 | + int get_field_start(int baddr = -1); | |
110 | + int get_field_len(int baddr = -1); | |
111 | + int get_next_unprotected(int baddr = -1); | |
112 | + | |
113 | + int set_copy(const char *text); | |
114 | + char * get_copy(void); | |
115 | + | |
116 | + char * get_clipboard(void); | |
117 | + int set_clipboard(const char *text); | |
118 | + | |
119 | + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); | |
120 | + char * file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename); | |
121 | + | |
122 | + protected: | |
123 | + | |
124 | + private: | |
125 | + H3270 * hSession; | |
126 | + | |
127 | + }; | |
128 | + | |
68 | 129 | |
69 | 130 | /*--[ Running rexx scripts ]---------------------------------------------------------------------------------*/ |
70 | 131 | |
... | ... | @@ -166,7 +227,10 @@ |
166 | 227 | } |
167 | 228 | |
168 | 229 | v3270_set_script(widget,'R',TRUE); |
230 | + script_name = g_path_get_basename(filename); | |
169 | 231 | RexxObjectPtr result = threadContext->CallProgram(filename, rxArgs); |
232 | + g_free(script_name); | |
233 | + script_name = NULL; | |
170 | 234 | v3270_set_script(widget,'R',FALSE); |
171 | 235 | |
172 | 236 | if (threadContext->CheckCondition()) |
... | ... | @@ -297,64 +361,6 @@ extern "C" |
297 | 361 | |
298 | 362 | } |
299 | 363 | |
300 | -/*--[ Plugin session object ]--------------------------------------------------------------------------------*/ | |
301 | - | |
302 | - class plugin : public rx3270 | |
303 | - { | |
304 | - public: | |
305 | - plugin(H3270 *hSession); | |
306 | - virtual ~plugin(); | |
307 | - | |
308 | - void free(void *ptr); | |
309 | - | |
310 | - char * get_version(void); | |
311 | - LIB3270_CSTATE get_cstate(void); | |
312 | - int disconnect(void); | |
313 | - int connect(const char *uri, bool wait = true); | |
314 | - bool is_connected(void); | |
315 | - bool is_ready(void); | |
316 | - | |
317 | - void logva(const char *fmt, va_list args); | |
318 | - | |
319 | - int iterate(bool wait); | |
320 | - int wait(int seconds); | |
321 | - int wait_for_ready(int seconds); | |
322 | - | |
323 | - char * get_text(int baddr, size_t len); | |
324 | - char * get_text_at(int row, int col, size_t sz); | |
325 | - int cmp_text_at(int row, int col, const char *text); | |
326 | - int set_text_at(int row, int col, const char *str); | |
327 | - | |
328 | - int set_cursor_position(int row, int col); | |
329 | - int set_cursor_addr(int addr); | |
330 | - int get_cursor_addr(void); | |
331 | - int emulate_input(const char *str); | |
332 | - | |
333 | - int set_toggle(LIB3270_TOGGLE ix, bool value); | |
334 | - | |
335 | - int enter(void); | |
336 | - int pfkey(int key); | |
337 | - int pakey(int key); | |
338 | - | |
339 | - int get_field_start(int baddr = -1); | |
340 | - int get_field_len(int baddr = -1); | |
341 | - int get_next_unprotected(int baddr = -1); | |
342 | - | |
343 | - int set_copy(const char *text); | |
344 | - char * get_copy(void); | |
345 | - | |
346 | - char * get_clipboard(void); | |
347 | - int set_clipboard(const char *text); | |
348 | - | |
349 | - int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); | |
350 | - | |
351 | - protected: | |
352 | - | |
353 | - private: | |
354 | - H3270 * hSession; | |
355 | - | |
356 | - }; | |
357 | - | |
358 | 364 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
359 | 365 | |
360 | 366 | static rx3270 * factory(const char *name) |
... | ... | @@ -560,3 +566,7 @@ int plugin::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *mess |
560 | 566 | return 0; |
561 | 567 | } |
562 | 568 | |
569 | +char * plugin::file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename) | |
570 | +{ | |
571 | + return pw3270_file_chooser(action, script_name ? script_name : "rexx", title, filename, extension); | |
572 | +} | ... | ... |
src/plugins/rx3270/rexx_methods.cc
src/pw3270/dialog.c
... | ... | @@ -214,9 +214,9 @@ |
214 | 214 | |
215 | 215 | } |
216 | 216 | |
217 | - static GtkFileChooserConfirmation confirm_overwrite(GtkFileChooser *chooser, GtkAction *action) | |
217 | + static GtkFileChooserConfirmation confirm_overwrite(GtkFileChooser *chooser, GObject *action) | |
218 | 218 | { |
219 | - const gchar * attr = g_object_get_data(G_OBJECT(action),"overwrite"); | |
219 | + const gchar * attr = g_object_get_data(action,"overwrite"); | |
220 | 220 | GtkFileChooserConfirmation ret = GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME; |
221 | 221 | GtkWidget * dialog; |
222 | 222 | |
... | ... | @@ -269,7 +269,7 @@ |
269 | 269 | NULL ); |
270 | 270 | |
271 | 271 | gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); |
272 | - g_signal_connect(GTK_FILE_CHOOSER(dialog), "confirm-overwrite", G_CALLBACK(confirm_overwrite), action); | |
272 | + g_signal_connect(GTK_FILE_CHOOSER(dialog), "confirm-overwrite", G_CALLBACK(confirm_overwrite), G_OBJECT(action)); | |
273 | 273 | |
274 | 274 | add_option_menus(dialog, action, &encattr); |
275 | 275 | |
... | ... | @@ -520,82 +520,70 @@ |
520 | 520 | g_free(info); |
521 | 521 | } |
522 | 522 | |
523 | -/* | |
524 | - G_GNUC_INTERNAL void run_security_dialog(GtkWidget *widget) | |
523 | + LIB3270_EXPORT gchar * pw3270_file_chooser(GtkFileChooserAction action, const gchar *name, const gchar *title, const gchar *file, const gchar *ext) | |
525 | 524 | { |
526 | - GtkWidget * dialog; | |
527 | - H3270 * hSession = pw3270_get_session(widget); | |
528 | - | |
529 | - trace("%s(%p)",__FUNCTION__,widget); | |
530 | - | |
531 | -#ifdef HAVE_LIBSSL | |
532 | - if(lib3270_get_secure(hSession) == LIB3270_SSL_UNSECURE) | |
533 | -#endif // HAVE_LIBSSL | |
534 | - { | |
535 | - // Connection is insecure, show simple dialog with host and info | |
536 | - | |
537 | - dialog = gtk_message_dialog_new( | |
538 | - GTK_WINDOW(widget), | |
539 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
540 | - GTK_MESSAGE_INFO, | |
541 | - GTK_BUTTONS_CLOSE, | |
542 | - pw3270_get_host(widget) | |
543 | - ); | |
544 | - | |
545 | - gtk_message_dialog_format_secondary_markup( | |
546 | - GTK_MESSAGE_DIALOG(dialog), | |
547 | - "%s", _( "<b>Identity not verified</b>\nThe connection is insecure" )); | |
548 | - | |
549 | - } | |
550 | -#ifdef HAVE_LIBSSL | |
551 | - else | |
552 | - { | |
553 | - long id = lib3270_get_SSL_verify_result(hSession); | |
554 | - const gchar * title = N_( "Unexpected SSL error"); | |
555 | - const gchar * text = NULL; | |
556 | - const gchar * icon = GTK_STOCK_DIALOG_ERROR; | |
557 | - int f; | |
558 | - | |
559 | - for(f=0;f<G_N_ELEMENTS(sslerror);f++) | |
560 | - { | |
561 | - if(sslerror[f].id == id) | |
562 | - { | |
563 | - title = sslerror[f].title; | |
564 | - icon = sslerror[f].icon; | |
565 | - text = sslerror[f].text; | |
566 | - break; | |
567 | - } | |
568 | - } | |
569 | - | |
570 | - dialog = gtk_message_dialog_new( | |
571 | - GTK_WINDOW(widget), | |
572 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
573 | - GTK_MESSAGE_OTHER, | |
574 | - GTK_BUTTONS_CLOSE, | |
575 | - "%s",gettext(title) | |
576 | - ); | |
525 | + static const struct _btn | |
526 | + { | |
527 | + const gchar * button; | |
528 | + GtkFileChooserAction action; | |
529 | + } btn[] = | |
530 | + { | |
531 | + { GTK_STOCK_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN }, | |
532 | + { GTK_STOCK_SAVE, GTK_FILE_CHOOSER_ACTION_SAVE }, | |
533 | + { GTK_STOCK_OK, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER }, | |
534 | + { GTK_STOCK_OK, GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER } | |
535 | + }; | |
536 | + | |
537 | + GtkWidget * dialog; | |
538 | + gchar * ptr; | |
539 | + const gchar * button = GTK_STOCK_OK; | |
540 | + gchar * filename = NULL; | |
541 | + int f; | |
542 | + | |
543 | + for(f=0;f<G_N_ELEMENTS(btn);f++) | |
544 | + { | |
545 | + if(action == btn[f].action) | |
546 | + { | |
547 | + button = btn[f].button; | |
548 | + break; | |
549 | + } | |
550 | + } | |
577 | 551 | |
578 | - gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog),gtk_image_new_from_stock(icon,GTK_ICON_SIZE_DIALOG)); | |
552 | + dialog = gtk_file_chooser_dialog_new( title, | |
553 | + GTK_WINDOW(pw3270_get_toplevel()), | |
554 | + action, | |
555 | + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
556 | + button, GTK_RESPONSE_ACCEPT, | |
557 | + NULL ); | |
579 | 558 | |
580 | - if(text) | |
581 | - { | |
582 | - gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),text); | |
583 | - } | |
584 | - else | |
585 | - { | |
586 | - gchar *str = g_strdup_printf("Unexpected SSL error <b>%ld</b>",id); | |
587 | - gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),text); | |
588 | - g_free(str); | |
589 | - } | |
559 | + if(action == GTK_FILE_CHOOSER_ACTION_SAVE) | |
560 | + { | |
561 | + gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); | |
562 | + g_signal_connect(GTK_FILE_CHOOSER(dialog), "confirm-overwrite", G_CALLBACK(confirm_overwrite), G_OBJECT(dialog)); | |
563 | + } | |
590 | 564 | |
591 | - } | |
592 | -#endif // HAVE_LIBSSL | |
565 | + if(file) | |
566 | + { | |
567 | + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),file); | |
568 | + } | |
569 | + else | |
570 | + { | |
571 | + ptr = get_string_from_config("files",name,""); | |
572 | + if(*ptr) | |
573 | + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),ptr); | |
574 | + else | |
575 | + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS)); | |
576 | + g_free(ptr); | |
577 | + } | |
593 | 578 | |
594 | - gtk_window_set_title(GTK_WINDOW(dialog),_("About security")); | |
579 | + if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
580 | + { | |
581 | + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
582 | + if(filename) | |
583 | + set_string_to_config("files",name,"%s",filename); | |
584 | + } | |
595 | 585 | |
596 | - gtk_widget_show_all(GTK_WIDGET(dialog)); | |
597 | - gtk_dialog_run(GTK_DIALOG(dialog)); | |
598 | - gtk_widget_destroy(GTK_WIDGET(dialog)); | |
586 | + gtk_widget_destroy(dialog); | |
599 | 587 | |
588 | + return filename; | |
600 | 589 | } |
601 | -*/ | ... | ... |