Commit c03eb89e945b8e9a2ca1d94da4236e012f4f7977
1 parent
4ac39648
Exists in
master
and in
5 other branches
Melhorando diálogo de configuração de servidor
Showing
14 changed files
with
345 additions
and
231 deletions
Show diff stats
pw3270.cbp
... | ... | @@ -263,6 +263,9 @@ |
263 | 263 | <Option compilerVar="CC" /> |
264 | 264 | </Unit> |
265 | 265 | <Unit filename="src/pw3270/globals.h" /> |
266 | + <Unit filename="src/pw3270/hostdialog.c"> | |
267 | + <Option compilerVar="CC" /> | |
268 | + </Unit> | |
266 | 269 | <Unit filename="src/pw3270/macros.c"> |
267 | 270 | <Option compilerVar="CC" /> |
268 | 271 | </Unit> | ... | ... |
src/include/lib3270.h
... | ... | @@ -241,12 +241,14 @@ |
241 | 241 | */ |
242 | 242 | typedef enum lib3270_option |
243 | 243 | { |
244 | - LIB3270_OPTION_COLOR8 = 0x0001, /**< If active, pw3270 will respond to a Query(Color) with a list of 8 supported colors. */ | |
245 | - LIB3270_OPTION_KYBD_AS400 = 0x0002, /**< Prefix every PF with PA1 */ | |
246 | - LIB3270_OPTION_TSO = 0x0004, /**< Host is TSO? */ | |
244 | + LIB3270_OPTION_KYBD_AS400 = 0x0001, /**< Prefix every PF with PA1 */ | |
245 | + LIB3270_OPTION_TSO = 0x0002, /**< Host is TSO? */ | |
247 | 246 | |
248 | 247 | } LIB3270_OPTION; |
249 | 248 | |
249 | + | |
250 | +// LIB3270_OPTION_COLOR8 = 0x0001, /**< If active, pw3270 will respond to a Query(Color) with a list of 8 supported colors. */ | |
251 | + | |
250 | 252 | #define LIB3270_OPTION_DEFAULT 0 |
251 | 253 | #define LIB3270_OPTION_COUNT 3 |
252 | 254 | |
... | ... | @@ -979,6 +981,7 @@ |
979 | 981 | |
980 | 982 | LIB3270_EXPORT LIB3270_OPTION lib3270_get_options(H3270 *hSession); |
981 | 983 | LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt); |
984 | + LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned short colortype); | |
982 | 985 | |
983 | 986 | LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void); |
984 | 987 | ... | ... |
src/include/lib3270/session.h
src/include/pw3270.h
... | ... | @@ -66,6 +66,7 @@ |
66 | 66 | LIB3270_EXPORT const gchar * pw3270_get_session_name(GtkWidget *widget); |
67 | 67 | LIB3270_EXPORT void pw3270_set_session_name(GtkWidget *widget, const gchar *name); |
68 | 68 | LIB3270_EXPORT void pw3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options); |
69 | + LIB3270_EXPORT int pw3270_set_session_color_type(GtkWidget *widget, unsigned short color_type); | |
69 | 70 | |
70 | 71 | LIB3270_EXPORT gint pw3270_get_integer(GtkWidget *widget, const gchar *group, const gchar *key, gint def); |
71 | 72 | LIB3270_EXPORT void pw3270_set_integer(GtkWidget *widget, const gchar *group, const gchar *key, gint val); | ... | ... |
src/include/pw3270/v3270.h
... | ... | @@ -189,6 +189,7 @@ |
189 | 189 | LIB3270_EXPORT int v3270_set_script(GtkWidget *widget, const gchar id, gboolean on); |
190 | 190 | LIB3270_EXPORT void v3270_set_scaled_fonts(GtkWidget *widget, gboolean on); |
191 | 191 | LIB3270_EXPORT void v3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options); |
192 | + LIB3270_EXPORT int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype); | |
192 | 193 | LIB3270_EXPORT void v3270_set_host(GtkWidget *widget, const gchar *uri); |
193 | 194 | |
194 | 195 | // Keyboard & Mouse special actions | ... | ... |
src/lib3270/options.c
... | ... | @@ -39,13 +39,6 @@ |
39 | 39 | static const const LIB3270_OPTION_ENTRY options[LIB3270_OPTION_COUNT+1] = |
40 | 40 | { |
41 | 41 | { |
42 | - LIB3270_OPTION_COLOR8, | |
43 | - "color8", | |
44 | - N_( "_8 colors" ), | |
45 | - N_( "If active, pw3270 will respond to a Query(Color) with a list of 8 supported colors." ) | |
46 | - }, | |
47 | - | |
48 | - { | |
49 | 42 | LIB3270_OPTION_KYBD_AS400, |
50 | 43 | "as400", |
51 | 44 | N_( "Host is AS/400" ), |
... | ... | @@ -84,6 +77,37 @@ LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt) |
84 | 77 | hSession->options = opt; |
85 | 78 | } |
86 | 79 | |
80 | +LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, unsigned short colortype) | |
81 | +{ | |
82 | + CHECK_SESSION_HANDLE(hSession); | |
83 | + | |
84 | + switch(colortype) | |
85 | + { | |
86 | + case 0: | |
87 | + case 16: | |
88 | + hSession->colors = 16; | |
89 | + hSession->mono = 0; | |
90 | + break; | |
91 | + | |
92 | + case 8: | |
93 | + hSession->colors = 8; | |
94 | + hSession->mono = 0; | |
95 | + break; | |
96 | + | |
97 | + case 2: | |
98 | + hSession->colors = 16; | |
99 | + hSession->mono = 1; | |
100 | + break; | |
101 | + | |
102 | + default: | |
103 | + return EINVAL; | |
104 | + } | |
105 | + | |
106 | + | |
107 | + return 0; | |
108 | +} | |
109 | + | |
110 | + | |
87 | 111 | LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void) |
88 | 112 | { |
89 | 113 | return options; | ... | ... |
src/lib3270/sf.c
... | ... | @@ -820,13 +820,13 @@ static void do_qr_color(H3270 *hSession) |
820 | 820 | |
821 | 821 | trace_ds(hSession,"> QueryReply(Color)\n"); |
822 | 822 | |
823 | - color_max = (hSession->options & LIB3270_OPTION_COLOR8) ? 8: 16; /* report on 8 or 16 colors */ | |
823 | + color_max = (hSession->colors == 8) ? 8: 16; /* report on 8 or 16 colors */ | |
824 | 824 | |
825 | 825 | space3270out(hSession,4 + 2*15); |
826 | - *hSession->obptr++ = 0x00; /* no options */ | |
827 | - *hSession->obptr++ = color_max; /* report on 8 or 16 colors */ | |
828 | - *hSession->obptr++ = 0x00; /* default color: */ | |
829 | - *hSession->obptr++ = 0xf0 + COLOR_GREEN; /* green */ | |
826 | + *hSession->obptr++ = 0x00; /* no options */ | |
827 | + *hSession->obptr++ = color_max; /* report on 8 or 16 colors */ | |
828 | + *hSession->obptr++ = 0x00; /* default color: */ | |
829 | + *hSession->obptr++ = 0xf0 + COLOR_GREEN; /* green */ | |
830 | 830 | for (i = 0xf1; i < 0xf1 + color_max - 1; i++) |
831 | 831 | { |
832 | 832 | *hSession->obptr++ = i; | ... | ... |
src/pw3270/Makefile.in
... | ... | @@ -58,7 +58,7 @@ include uiparser/sources.mak |
58 | 58 | |
59 | 59 | APP_SOURCES= main.c @APP_GUI_SRC@ |
60 | 60 | |
61 | -LIB_SOURCES= window.c actions.c fonts.c dialog.c print.c colors.c \ | |
61 | +LIB_SOURCES= window.c actions.c fonts.c dialog.c hostdialog.c print.c colors.c \ | |
62 | 62 | filetransfer.c tools.c plugin.c macros.c\ |
63 | 63 | $(foreach SRC, $(UI_PARSER_SRC), uiparser/$(SRC)) \ |
64 | 64 | $(foreach SRC, $(V3270_SRC), v3270/$(SRC)) \ | ... | ... |
src/pw3270/actions.c
src/pw3270/dialog.c
... | ... | @@ -34,19 +34,6 @@ |
34 | 34 | |
35 | 35 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
36 | 36 | |
37 | - static const struct _host_type | |
38 | - { | |
39 | - const gchar * name; | |
40 | - const gchar * description; | |
41 | - LIB3270_OPTION option; | |
42 | - } host_type[] = | |
43 | - { | |
44 | - { "S390", N_( "IBM S/390" ), LIB3270_OPTION_TSO }, | |
45 | - { "AS400", N_( "IBM AS/400" ), LIB3270_OPTION_KYBD_AS400 }, | |
46 | - { "TSO", N_( "Other (TSO)" ), LIB3270_OPTION_TSO }, | |
47 | - { "VM/CMS", N_( "Other (VM/CMS)" ), 0 } | |
48 | - }; | |
49 | - | |
50 | 37 | static const struct _charset |
51 | 38 | { |
52 | 39 | const gchar *name; |
... | ... | @@ -317,193 +304,6 @@ |
317 | 304 | return 0; |
318 | 305 | } |
319 | 306 | |
320 | - | |
321 | - void hostname_action(GtkAction *action, GtkWidget *widget) | |
322 | - { | |
323 | -// const LIB3270_OPTION_ENTRY *options = lib3270_get_option_list(); | |
324 | - | |
325 | - const gchar * title = g_object_get_data(G_OBJECT(action),"title"); | |
326 | - const gchar * systype = g_object_get_data(G_OBJECT(action),"type"); | |
327 | - gchar * cfghost = get_string_from_config("host","uri",""); | |
328 | - gchar * hostname; | |
329 | - gchar * ptr; | |
330 | - gboolean again = TRUE; | |
331 | - GtkWidget * label; | |
332 | - GtkTable * table = GTK_TABLE(gtk_table_new(3,4,FALSE)); | |
333 | - GtkEntry * host = GTK_ENTRY(gtk_entry_new()); | |
334 | - GtkEntry * port = GTK_ENTRY(gtk_entry_new()); | |
335 | - GtkToggleButton * sslcheck = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic( _( "_Secure connection" ) )); | |
336 | -// GtkToggleButton * optcheck[LIB3270_OPTION_COUNT]; | |
337 | - GtkWidget * dialog = gtk_dialog_new_with_buttons( gettext(title ? title : N_( "Select hostname" )), | |
338 | - GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
339 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
340 | - GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT, | |
341 | - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, | |
342 | - NULL ); | |
343 | - | |
344 | - gtk_window_set_icon_name(GTK_WINDOW(dialog),GTK_STOCK_HOME); | |
345 | - gtk_entry_set_max_length(host,0xFF); | |
346 | - gtk_entry_set_width_chars(host,50); | |
347 | - | |
348 | - gtk_entry_set_max_length(port,6); | |
349 | - gtk_entry_set_width_chars(port,7); | |
350 | - | |
351 | - label = gtk_label_new_with_mnemonic( _("_Hostname:") ); | |
352 | - gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(host)); | |
353 | - gtk_table_attach(table,label,0,1,0,1,0,0,5,0); | |
354 | - gtk_table_attach(table,GTK_WIDGET(host), 1,2,0,1,GTK_EXPAND|GTK_FILL,0,0,0); | |
355 | - | |
356 | - label = gtk_label_new_with_mnemonic( _( "_Port:" ) ); | |
357 | - gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(port)); | |
358 | - gtk_table_attach(table, label, 2,3,0,1,0,0,5,0); | |
359 | - gtk_table_attach(table,GTK_WIDGET(port), 3,4,0,1,GTK_FILL,0,0,0); | |
360 | - | |
361 | - gtk_table_attach(table,GTK_WIDGET(sslcheck), 1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0); | |
362 | - | |
363 | - { | |
364 | - GtkWidget * expander = gtk_expander_new_with_mnemonic(_( "_Host options")); | |
365 | - GtkBox * container = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL,0)); | |
366 | - | |
367 | - // Host options | |
368 | - if(!systype) | |
369 | - { | |
370 | - // No system type defined, ask user | |
371 | - GtkTable * frame = GTK_TABLE(gtk_table_new(2,2,FALSE)); | |
372 | - GtkWidget * widget = gtk_combo_box_text_new(); | |
373 | - gchar * str = get_string_from_config("host","systype",host_type[0].name); | |
374 | - int f; | |
375 | - | |
376 | - label = gtk_label_new_with_mnemonic( _("System _Type:") ); | |
377 | - gtk_table_attach(frame,label,0,1,0,1,0,0,5,0); | |
378 | - | |
379 | - for(f=0;f<G_N_ELEMENTS(host_type);f++) | |
380 | - { | |
381 | - gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widget),host_type[f].name,gettext(host_type[f].description)); | |
382 | - if(!g_strcasecmp(host_type[f].name,str)) | |
383 | - gtk_combo_box_set_active(GTK_COMBO_BOX(widget),f); | |
384 | - } | |
385 | - | |
386 | - g_free(str); | |
387 | - | |
388 | - | |
389 | - gtk_table_attach(frame,widget,1,2,0,1,GTK_EXPAND|GTK_FILL,0,0,0); | |
390 | - gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(widget)); | |
391 | - | |
392 | - gtk_box_pack_start(container,GTK_WIDGET(frame),FALSE,TRUE,0); | |
393 | - } | |
394 | - | |
395 | -/* | |
396 | - GtkTable * frame = GTK_TABLE(gtk_table_new(2,2,FALSE)); | |
397 | - | |
398 | - for(f=0;f<LIB3270_OPTION_COUNT;f++) | |
399 | - { | |
400 | - optcheck[f] = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic( gettext( options[f].text ) )); | |
401 | - | |
402 | - if(options[f].tooltip) | |
403 | - gtk_widget_set_tooltip_markup(GTK_WIDGET(optcheck[f]),gettext(options[f].tooltip)); | |
404 | - | |
405 | - gtk_table_attach(frame,GTK_WIDGET(optcheck[f]),col,col+1,row,row+1,GTK_EXPAND|GTK_FILL,0,0,0); | |
406 | - gtk_toggle_button_set_active(optcheck[f],get_boolean_from_config("host", options[f].key, FALSE)); | |
407 | - | |
408 | - if(col++ > 1) | |
409 | - { | |
410 | - col = 0; | |
411 | - row++; | |
412 | - } | |
413 | - | |
414 | - } | |
415 | - | |
416 | - gtk_container_add(GTK_CONTAINER(container),GTK_WIDGET(frame)); | |
417 | - | |
418 | -*/ | |
419 | - gtk_container_add(GTK_CONTAINER(expander),GTK_WIDGET(container)); | |
420 | - gtk_table_attach(table,expander,1,2,2,3,GTK_EXPAND|GTK_FILL,0,0,0); | |
421 | - } | |
422 | - | |
423 | - | |
424 | - gtk_container_set_border_width(GTK_CONTAINER(table),5); | |
425 | - | |
426 | - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(table),FALSE,FALSE,2); | |
427 | - | |
428 | - hostname = cfghost; | |
429 | - | |
430 | -#ifdef HAVE_LIBSSL | |
431 | - if(!strncmp(hostname,"L:",2)) | |
432 | - { | |
433 | - gtk_toggle_button_set_active(sslcheck,TRUE); | |
434 | - hostname += 2; | |
435 | - } | |
436 | -#else | |
437 | - gtk_toggle_button_set_active(sslcheck,FALSE); | |
438 | - gtk_widget_set_sensitive(GTK_WIDGET(sslcheck),FALSE); | |
439 | - if(!strncmp(hostname,"L:",2)) | |
440 | - hostname += 2; | |
441 | -#endif | |
442 | - | |
443 | - ptr = strchr(hostname,':'); | |
444 | - if(ptr) | |
445 | - { | |
446 | - *(ptr++) = 0; | |
447 | - gtk_entry_set_text(port,ptr); | |
448 | - } | |
449 | - else | |
450 | - { | |
451 | - gtk_entry_set_text(port,"23"); | |
452 | - } | |
453 | - | |
454 | - gtk_entry_set_text(host,hostname); | |
455 | - | |
456 | - gtk_widget_show_all(GTK_WIDGET(table)); | |
457 | - | |
458 | - while(again) | |
459 | - { | |
460 | - gtk_widget_set_sensitive(dialog,TRUE); | |
461 | - switch(gtk_dialog_run(GTK_DIALOG(dialog))) | |
462 | - { | |
463 | - case GTK_RESPONSE_ACCEPT: | |
464 | - gtk_widget_set_sensitive(dialog,FALSE); | |
465 | - | |
466 | - hostname = g_strconcat( gtk_toggle_button_get_active(sslcheck) ? "L:" : "", | |
467 | - gtk_entry_get_text(host), | |
468 | - ":", | |
469 | - gtk_entry_get_text(port), | |
470 | - NULL | |
471 | - ); | |
472 | - | |
473 | - { | |
474 | -// int f; | |
475 | - LIB3270_OPTION opt = 0; | |
476 | - | |
477 | -/* | |
478 | - for(f=0;f<LIB3270_OPTION_COUNT;f++) | |
479 | - { | |
480 | - gboolean val = gtk_toggle_button_get_active(optcheck[f]); | |
481 | - if(val) | |
482 | - opt |= options[f].value; | |
483 | - set_boolean_to_config("host", options[f].key, val); | |
484 | - } | |
485 | -*/ | |
486 | - v3270_set_session_options(widget,opt); | |
487 | - | |
488 | - } | |
489 | - | |
490 | - if(!lib3270_connect(v3270_get_session(widget),hostname,1)) | |
491 | - again = FALSE; | |
492 | - | |
493 | - g_free(hostname); | |
494 | - break; | |
495 | - | |
496 | - case GTK_RESPONSE_REJECT: | |
497 | - again = FALSE; | |
498 | - break; | |
499 | - } | |
500 | - } | |
501 | - | |
502 | - gtk_widget_destroy(dialog); | |
503 | - | |
504 | - g_free(cfghost); | |
505 | - } | |
506 | - | |
507 | 307 | void save_all_action(GtkAction *action, GtkWidget *widget) |
508 | 308 | { |
509 | 309 | gchar *text = v3270_get_text(widget,0,-1); | ... | ... |
... | ... | @@ -0,0 +1,268 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como hostdialog.c e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | + #include "globals.h" | |
31 | + #include <pw3270/v3270.h> | |
32 | + | |
33 | +/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
34 | + | |
35 | + static const struct _host_type | |
36 | + { | |
37 | + const gchar * name; | |
38 | + const gchar * description; | |
39 | + LIB3270_OPTION option; | |
40 | + } host_type[] = | |
41 | + { | |
42 | + { "S390", N_( "IBM S/390" ), LIB3270_OPTION_TSO }, | |
43 | + { "AS400", N_( "IBM AS/400" ), LIB3270_OPTION_KYBD_AS400 }, | |
44 | + { "TSO", N_( "Other (TSO)" ), LIB3270_OPTION_TSO }, | |
45 | + { "VM/CMS", N_( "Other (VM/CMS)" ), 0 } | |
46 | + }; | |
47 | + | |
48 | + static const struct _colortable | |
49 | + { | |
50 | + unsigned short colors; | |
51 | + const gchar * description; | |
52 | + } colortable[] = | |
53 | + { | |
54 | + { 16, N_( "16 colors" ) }, | |
55 | + { 8, N_( "8 colors" ) }, | |
56 | + { 2, N_( "Monochrome" ) }, | |
57 | + }; | |
58 | + | |
59 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
60 | + | |
61 | + static void set_row(int row, GtkWidget *widget, GtkTable *container, const gchar *text) | |
62 | + { | |
63 | + GtkWidget *label = gtk_label_new_with_mnemonic(text); | |
64 | + | |
65 | + gtk_misc_set_alignment(GTK_MISC(label),0,0.5); | |
66 | + | |
67 | + gtk_table_attach(container,label,0,1,row,row+1,GTK_FILL,0,5,0); | |
68 | + gtk_table_attach(container,widget,1,2,row,row+1,GTK_FILL,0,0,0); | |
69 | + gtk_label_set_mnemonic_widget(GTK_LABEL(label),widget); | |
70 | + } | |
71 | + | |
72 | + void hostname_action(GtkAction *action, GtkWidget *widget) | |
73 | + { | |
74 | + const gchar * title = g_object_get_data(G_OBJECT(action),"title"); | |
75 | + gchar * cfghost = get_string_from_config("host","uri",""); | |
76 | + gchar * hostname; | |
77 | + gchar * ptr; | |
78 | + gboolean again = TRUE; | |
79 | + int iHostType = 0; | |
80 | + int iColorTable = 0; | |
81 | + GtkTable * table = GTK_TABLE(gtk_table_new(3,4,FALSE)); | |
82 | + GtkEntry * host = GTK_ENTRY(gtk_entry_new()); | |
83 | + GtkEntry * port = GTK_ENTRY(gtk_entry_new()); | |
84 | + GtkToggleButton * sslcheck = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic( _( "_Secure connection" ) )); | |
85 | + GtkWidget * dialog = gtk_dialog_new_with_buttons( | |
86 | + gettext(title ? title : N_( "Select hostname" )), | |
87 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
88 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
89 | + GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT, | |
90 | + GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, | |
91 | + NULL ); | |
92 | + | |
93 | + gtk_window_set_icon_name(GTK_WINDOW(dialog),GTK_STOCK_HOME); | |
94 | + gtk_entry_set_max_length(host,0xFF); | |
95 | + gtk_entry_set_width_chars(host,50); | |
96 | + | |
97 | + gtk_entry_set_max_length(port,6); | |
98 | + gtk_entry_set_width_chars(port,7); | |
99 | + | |
100 | + | |
101 | + { | |
102 | + GtkWidget * label; | |
103 | + | |
104 | + label = gtk_label_new_with_mnemonic( _("_Hostname:") ); | |
105 | + gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(host)); | |
106 | + gtk_table_attach(table,label,0,1,0,1,0,0,5,0); | |
107 | + gtk_table_attach(table,GTK_WIDGET(host), 1,2,0,1,GTK_EXPAND|GTK_FILL,0,0,0); | |
108 | + | |
109 | + label = gtk_label_new_with_mnemonic( _( "_Port:" ) ); | |
110 | + gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(port)); | |
111 | + gtk_table_attach(table, label, 2,3,0,1,0,0,5,0); | |
112 | + gtk_table_attach(table,GTK_WIDGET(port), 3,4,0,1,GTK_FILL,0,0,0); | |
113 | + | |
114 | + gtk_table_attach(table,GTK_WIDGET(sslcheck), 1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0); | |
115 | + } | |
116 | + | |
117 | + { | |
118 | + // Host options | |
119 | + const gchar * systype = g_object_get_data(G_OBJECT(action),"type"); | |
120 | + const gchar * colortype = g_object_get_data(G_OBJECT(action),"colors"); | |
121 | + | |
122 | + int row = 0; | |
123 | + GtkWidget * expander = gtk_expander_new_with_mnemonic(_( "_Host options")); | |
124 | + GtkTable * container = GTK_TABLE(gtk_table_new(3,2,FALSE)); | |
125 | + | |
126 | + if(!systype) | |
127 | + { | |
128 | + // No system type defined, ask user | |
129 | + gchar * str = get_string_from_config("host","systype",host_type[0].name); | |
130 | + GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT); | |
131 | + GtkWidget * widget = gtk_combo_box_new_with_model(model); | |
132 | + GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); | |
133 | + | |
134 | + int f; | |
135 | + | |
136 | + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE); | |
137 | + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 0, NULL); | |
138 | + | |
139 | + for(f=0;f<G_N_ELEMENTS(host_type);f++) | |
140 | + { | |
141 | + GtkTreeIter iter; | |
142 | + | |
143 | + gtk_list_store_append((GtkListStore *) model,&iter); | |
144 | + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(host_type[f].description), 1, f, -1); | |
145 | + | |
146 | + if(!g_ascii_strcasecmp(host_type[f].name,str)) | |
147 | + gtk_combo_box_set_active(GTK_COMBO_BOX(widget),f); | |
148 | + } | |
149 | + | |
150 | + g_free(str); | |
151 | + | |
152 | + set_row(row++,widget,container,_("System _type:")); | |
153 | + | |
154 | + } | |
155 | + else | |
156 | + { | |
157 | + #warning TODO: Configurar o tipo de host de acordo com systype | |
158 | + } | |
159 | + | |
160 | + if(!colortype) | |
161 | + { | |
162 | + // NO colortype defined, ask user | |
163 | + unsigned short colors = (unsigned short) get_integer_from_config("host","colortype",16); | |
164 | + GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT); | |
165 | + GtkWidget * widget = gtk_combo_box_new_with_model(model); | |
166 | + GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); | |
167 | + | |
168 | + int f; | |
169 | + | |
170 | + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE); | |
171 | + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 0, NULL); | |
172 | + | |
173 | + for(f=0;f<G_N_ELEMENTS(colortable);f++) | |
174 | + { | |
175 | + GtkTreeIter iter; | |
176 | + | |
177 | + gtk_list_store_append((GtkListStore *) model,&iter); | |
178 | + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(colortable[f].description), 1, (int) colortable[f].colors, -1); | |
179 | + | |
180 | + if(colortable[f].colors == colors) | |
181 | + gtk_combo_box_set_active(GTK_COMBO_BOX(widget),f); | |
182 | + } | |
183 | + | |
184 | + set_row(row++,widget,container,_("_Color table:")); | |
185 | + | |
186 | + } | |
187 | + else | |
188 | + { | |
189 | + #warning TODO: Configurar tabela de cores de acordo com systype | |
190 | + } | |
191 | + | |
192 | + gtk_container_add(GTK_CONTAINER(expander),GTK_WIDGET(container)); | |
193 | + gtk_table_attach(table,expander,1,2,2,3,GTK_EXPAND|GTK_FILL,0,0,0); | |
194 | + } | |
195 | + | |
196 | + gtk_container_set_border_width(GTK_CONTAINER(table),5); | |
197 | + | |
198 | + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(table),FALSE,FALSE,2); | |
199 | + | |
200 | + hostname = cfghost; | |
201 | + | |
202 | +#ifdef HAVE_LIBSSL | |
203 | + if(!strncmp(hostname,"L:",2)) | |
204 | + { | |
205 | + gtk_toggle_button_set_active(sslcheck,TRUE); | |
206 | + hostname += 2; | |
207 | + } | |
208 | +#else | |
209 | + gtk_toggle_button_set_active(sslcheck,FALSE); | |
210 | + gtk_widget_set_sensitive(GTK_WIDGET(sslcheck),FALSE); | |
211 | + if(!strncmp(hostname,"L:",2)) | |
212 | + hostname += 2; | |
213 | +#endif | |
214 | + | |
215 | + ptr = strchr(hostname,':'); | |
216 | + if(ptr) | |
217 | + { | |
218 | + *(ptr++) = 0; | |
219 | + gtk_entry_set_text(port,ptr); | |
220 | + } | |
221 | + else | |
222 | + { | |
223 | + gtk_entry_set_text(port,"23"); | |
224 | + } | |
225 | + | |
226 | + gtk_entry_set_text(host,hostname); | |
227 | + | |
228 | + gtk_widget_show_all(GTK_WIDGET(table)); | |
229 | + | |
230 | + while(again) | |
231 | + { | |
232 | + gtk_widget_set_sensitive(dialog,TRUE); | |
233 | + switch(gtk_dialog_run(GTK_DIALOG(dialog))) | |
234 | + { | |
235 | + case GTK_RESPONSE_ACCEPT: | |
236 | + gtk_widget_set_sensitive(dialog,FALSE); | |
237 | + | |
238 | + hostname = g_strconcat( gtk_toggle_button_get_active(sslcheck) ? "L:" : "", | |
239 | + gtk_entry_get_text(host), | |
240 | + ":", | |
241 | + gtk_entry_get_text(port), | |
242 | + NULL | |
243 | + ); | |
244 | + | |
245 | + gtk_widget_set_visible(dialog,FALSE); | |
246 | + | |
247 | + v3270_set_session_options(widget,host_type[iHostType].option); | |
248 | + v3270_set_session_color_type(widget,colortable[iColorTable].colors); | |
249 | + | |
250 | + if(!lib3270_connect(v3270_get_session(widget),hostname,1)) | |
251 | + again = FALSE; | |
252 | + else | |
253 | + gtk_widget_set_visible(dialog,TRUE); | |
254 | + | |
255 | + g_free(hostname); | |
256 | + break; | |
257 | + | |
258 | + case GTK_RESPONSE_REJECT: | |
259 | + again = FALSE; | |
260 | + break; | |
261 | + } | |
262 | + } | |
263 | + | |
264 | + gtk_widget_destroy(dialog); | |
265 | + | |
266 | + g_free(cfghost); | |
267 | + } | |
268 | + | ... | ... |
src/pw3270/main.c
... | ... | @@ -44,7 +44,7 @@ |
44 | 44 | |
45 | 45 | struct option |
46 | 46 | { |
47 | - LIB3270_OPTION host; | |
47 | + int colors; | |
48 | 48 | }; |
49 | 49 | |
50 | 50 | #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME) |
... | ... | @@ -169,21 +169,21 @@ static gboolean datadir(const gchar *option_name, const gchar *value, gpointer d |
169 | 169 | |
170 | 170 | static gboolean optcolors(const gchar *option_name, const gchar *value, gpointer data, GError **error) |
171 | 171 | { |
172 | - switch(atoi(value)) | |
173 | - { | |
174 | - case 8: | |
175 | - ((struct option *) data)->host |= LIB3270_OPTION_COLOR8; | |
176 | - break; | |
177 | - | |
178 | - case 16: | |
179 | - break; | |
172 | + static const unsigned char valid[] = { 2,8,16 }; | |
173 | + int f; | |
174 | + unsigned char optval = (unsigned char) atoi(value); | |
180 | 175 | |
181 | - default: | |
182 | - *error = g_error_new(ERROR_DOMAIN,EINVAL, _("Unexpected or invalid color value \"%s\""), value ); | |
183 | - return FALSE; | |
176 | + for(f=0;f<G_N_ELEMENTS(valid);f++) | |
177 | + { | |
178 | + if(optval == valid[f]) | |
179 | + { | |
180 | + ((struct option *) data)->colors = optval; | |
181 | + return TRUE; | |
182 | + } | |
184 | 183 | } |
185 | 184 | |
186 | - return TRUE; | |
185 | + *error = g_error_new(ERROR_DOMAIN,EINVAL, _("Unexpected or invalid color value \"%s\""), value ); | |
186 | + return FALSE; | |
187 | 187 | } |
188 | 188 | |
189 | 189 | int main(int argc, char *argv[]) |
... | ... | @@ -344,7 +344,8 @@ int main(int argc, char *argv[]) |
344 | 344 | |
345 | 345 | toplevel = pw3270_new(host); |
346 | 346 | pw3270_set_session_name(toplevel,session_name); |
347 | - pw3270_set_session_options(toplevel,cmdline_opt.host); | |
347 | + pw3270_set_session_color_type(toplevel,cmdline_opt.colors); | |
348 | + // pw3270_set_session_options(toplevel,cmdline_opt.host); | |
348 | 349 | |
349 | 350 | toplevel_setup(GTK_WINDOW(toplevel)); |
350 | 351 | ... | ... |
src/pw3270/v3270/widget.c
... | ... | @@ -1444,6 +1444,12 @@ void v3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options) |
1444 | 1444 | lib3270_set_options(GTK_V3270(widget)->host,options); |
1445 | 1445 | } |
1446 | 1446 | |
1447 | +int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype) | |
1448 | +{ | |
1449 | + g_return_val_if_fail(GTK_IS_V3270(widget),EFAULT); | |
1450 | + return lib3270_set_color_type(GTK_V3270(widget)->host,colortype); | |
1451 | +} | |
1452 | + | |
1447 | 1453 | gboolean v3270_is_connected(GtkWidget *widget) |
1448 | 1454 | { |
1449 | 1455 | g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); | ... | ... |
src/pw3270/window.c
... | ... | @@ -239,6 +239,12 @@ |
239 | 239 | v3270_set_session_options(GTK_PW3270(widget)->terminal,options); |
240 | 240 | } |
241 | 241 | |
242 | + LIB3270_EXPORT int pw3270_set_session_color_type(GtkWidget *widget, unsigned short colortype) | |
243 | + { | |
244 | + g_return_val_if_fail(GTK_IS_PW3270(widget),EFAULT); | |
245 | + return v3270_set_session_color_type(GTK_PW3270(widget)->terminal,colortype); | |
246 | + } | |
247 | + | |
242 | 248 | static void chktoplevel(GtkWidget *window, GtkWidget **widget) |
243 | 249 | { |
244 | 250 | if(*widget) | ... | ... |