Commit 0c06052f3c10589b288c136f256e3f0de7c961e7
1 parent
8a5df265
Exists in
master
and in
5 other branches
Implementando options na caixa de diálogo de host
Showing
7 changed files
with
92 additions
and
12 deletions
Show diff stats
src/include/lib3270.h
| ... | ... | @@ -236,6 +236,17 @@ |
| 236 | 236 | |
| 237 | 237 | |
| 238 | 238 | /** |
| 239 | + * Connect options | |
| 240 | + * | |
| 241 | + */ | |
| 242 | + typedef enum lib3270_option | |
| 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_AS400 = 0x0002, /**< Host is AS400? */ | |
| 246 | + | |
| 247 | + } LIB3270_OPTION; | |
| 248 | + | |
| 249 | + /** | |
| 239 | 250 | * SSL state |
| 240 | 251 | * |
| 241 | 252 | */ |
| ... | ... | @@ -954,6 +965,10 @@ |
| 954 | 965 | LIB3270_EXPORT void lib3270_set_trace_handler( void (*handler)(H3270 *session, const char *fmt, va_list args) ); |
| 955 | 966 | LIB3270_EXPORT void lib3270_write_dstrace(H3270 *session, const char *fmt, ...) LIB3270_GNUC_FORMAT(2,3); |
| 956 | 967 | |
| 968 | + LIB3270_EXPORT LIB3270_OPTION lib3270_get_options(H3270 *hSession); | |
| 969 | + LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt); | |
| 970 | + | |
| 971 | + | |
| 957 | 972 | #ifdef __cplusplus |
| 958 | 973 | } |
| 959 | 974 | #endif | ... | ... |
src/include/lib3270/session.h
| ... | ... | @@ -83,6 +83,8 @@ |
| 83 | 83 | LIB3270_CSTATE cstate; /**< Connection state */ |
| 84 | 84 | |
| 85 | 85 | // flags |
| 86 | + LIB3270_OPTION options; /**< Session options */ | |
| 87 | + | |
| 86 | 88 | int bgthread : 1; /**< Running on a background thread ? */ |
| 87 | 89 | int selected : 1; /**< Has selected region? */ |
| 88 | 90 | int rectsel : 1; /**< Selected region is a rectangle ? */ |
| ... | ... | @@ -96,7 +98,7 @@ |
| 96 | 98 | int oerr_lock : 1; |
| 97 | 99 | int unlock_delay : 1; |
| 98 | 100 | int auto_reconnect_inprogress : 1; |
| 99 | - int color8 : 1; | |
| 101 | +// int color8 : 1; | |
| 100 | 102 | int apl_mode : 1; |
| 101 | 103 | int icrnl : 1; |
| 102 | 104 | int inlcr : 1; | ... | ... |
src/lib3270/api.h
| ... | ... | @@ -299,7 +299,8 @@ |
| 299 | 299 | |
| 300 | 300 | #define CHAR_ATTR_UNCONVERTED LIB3270_ATTR_CG |
| 301 | 301 | |
| 302 | - struct lib3270_option | |
| 302 | +/* | |
| 303 | + struct _lib3270_option | |
| 303 | 304 | { |
| 304 | 305 | const char *name; |
| 305 | 306 | enum |
| ... | ... | @@ -320,7 +321,8 @@ |
| 320 | 321 | |
| 321 | 322 | #define new_3270_session(m) lib3270_session_new(m) |
| 322 | 323 | |
| 323 | - LOCAL_EXTERN const struct lib3270_option * get_3270_option_table(int sz); | |
| 324 | + LOCAL_EXTERN const struct _lib3270_option * get_3270_option_table(int sz); | |
| 325 | +*/ | |
| 324 | 326 | |
| 325 | 327 | |
| 326 | 328 | /* Set/Get screen contents */ | ... | ... |
src/lib3270/host.c
src/lib3270/session.c
| ... | ... | @@ -453,3 +453,15 @@ LIB3270_EXPORT void * lib3270_get_widget(H3270 *h) |
| 453 | 453 | CHECK_SESSION_HANDLE(h); |
| 454 | 454 | return h->widget; |
| 455 | 455 | } |
| 456 | + | |
| 457 | +LIB3270_EXPORT LIB3270_OPTION lib3270_get_options(H3270 *hSession) | |
| 458 | +{ | |
| 459 | + CHECK_SESSION_HANDLE(hSession); | |
| 460 | + return hSession->options; | |
| 461 | +} | |
| 462 | + | |
| 463 | +LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt) | |
| 464 | +{ | |
| 465 | + CHECK_SESSION_HANDLE(hSession); | |
| 466 | + hSession->options = opt; | |
| 467 | +} | ... | ... |
src/lib3270/sf.c
| ... | ... | @@ -820,7 +820,7 @@ static void do_qr_color(H3270 *hSession) |
| 820 | 820 | |
| 821 | 821 | trace_ds(hSession,"> QueryReply(Color)\n"); |
| 822 | 822 | |
| 823 | - color_max = hSession->color8 ? 8: 16; /* report on 8 or 16 colors */ | |
| 823 | + color_max = (hSession->options & LIB3270_OPTION_COLOR8) ? 8: 16; /* report on 8 or 16 colors */ | |
| 824 | 824 | |
| 825 | 825 | space3270out(hSession,4 + 2*15); |
| 826 | 826 | *hSession->obptr++ = 0x00; /* no options */ | ... | ... |
src/pw3270/dialog.c
| ... | ... | @@ -288,6 +288,26 @@ |
| 288 | 288 | |
| 289 | 289 | void hostname_action(GtkAction *action, GtkWidget *widget) |
| 290 | 290 | { |
| 291 | + static const struct _option | |
| 292 | + { | |
| 293 | + LIB3270_OPTION value; | |
| 294 | + const gchar * text; | |
| 295 | + const gchar * tooltip; | |
| 296 | + } option[] = | |
| 297 | + { | |
| 298 | + { | |
| 299 | + LIB3270_OPTION_COLOR8, | |
| 300 | + N_( "_8 colors" ), | |
| 301 | + N_( "If active, pw3270 will respond to a Query(Color) with a list of 8 supported colors." ) | |
| 302 | + }, | |
| 303 | + | |
| 304 | + { | |
| 305 | + LIB3270_OPTION_AS400, | |
| 306 | + N_( "Host is AS_400" ), | |
| 307 | + NULL | |
| 308 | + }, | |
| 309 | + }; | |
| 310 | + | |
| 291 | 311 | const gchar * title = g_object_get_data(G_OBJECT(action),"title"); |
| 292 | 312 | gchar * cfghost = get_string_from_config("host","uri",""); |
| 293 | 313 | gchar * hostname; |
| ... | ... | @@ -297,7 +317,8 @@ |
| 297 | 317 | GtkTable * table = GTK_TABLE(gtk_table_new(2,4,FALSE)); |
| 298 | 318 | GtkEntry * host = GTK_ENTRY(gtk_entry_new()); |
| 299 | 319 | GtkEntry * port = GTK_ENTRY(gtk_entry_new()); |
| 300 | - GtkToggleButton * checkbox = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic( _( "_Secure connection" ) )); | |
| 320 | + GtkToggleButton * sslcheck = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic( _( "_Secure connection" ) )); | |
| 321 | + GtkToggleButton * optcheck[G_N_ELEMENTS(option)]; | |
| 301 | 322 | GtkWidget * dialog = gtk_dialog_new_with_buttons( gettext(title ? title : N_( "Select hostname" )), |
| 302 | 323 | GTK_WINDOW(gtk_widget_get_toplevel(widget)), |
| 303 | 324 | GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, |
| ... | ... | @@ -312,7 +333,6 @@ |
| 312 | 333 | gtk_entry_set_max_length(port,6); |
| 313 | 334 | gtk_entry_set_width_chars(port,7); |
| 314 | 335 | |
| 315 | - | |
| 316 | 336 | label = gtk_label_new_with_mnemonic( _("_Hostname:") ); |
| 317 | 337 | gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(host)); |
| 318 | 338 | gtk_table_attach(table,label,0,1,0,1,0,0,5,0); |
| ... | ... | @@ -323,7 +343,36 @@ |
| 323 | 343 | gtk_table_attach(table, label, 2,3,0,1,0,0,5,0); |
| 324 | 344 | gtk_table_attach(table,GTK_WIDGET(port), 3,4,0,1,GTK_FILL,0,0,0); |
| 325 | 345 | |
| 326 | - gtk_table_attach(table,GTK_WIDGET(checkbox), 1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0); | |
| 346 | + { | |
| 347 | + int f; | |
| 348 | + int col = 1; | |
| 349 | + int row = 0; | |
| 350 | + LIB3270_OPTION optval = lib3270_get_options(v3270_get_session(widget)); | |
| 351 | + | |
| 352 | + GtkTable * frame = GTK_TABLE(gtk_table_new(2,2,FALSE)); | |
| 353 | + gtk_table_attach(frame,GTK_WIDGET(sslcheck), 0,1,0,1,GTK_EXPAND|GTK_FILL,0,0,0); | |
| 354 | + | |
| 355 | + for(f=0;f<G_N_ELEMENTS(option);f++) | |
| 356 | + { | |
| 357 | + optcheck[f] = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic( gettext( option[f].text ) )); | |
| 358 | + | |
| 359 | + if(option[f].tooltip) | |
| 360 | + gtk_widget_set_tooltip_markup(GTK_WIDGET(optcheck[f]),gettext(option[f].tooltip)); | |
| 361 | + | |
| 362 | + gtk_table_attach(frame,GTK_WIDGET(optcheck[f]),col,col+1,row,row+1,GTK_EXPAND|GTK_FILL,0,0,0); | |
| 363 | + gtk_toggle_button_set_active(optcheck[f],optval & option[f].value ? TRUE : FALSE); | |
| 364 | + | |
| 365 | + if(++col > 1); | |
| 366 | + { | |
| 367 | + col = 0; | |
| 368 | + row++; | |
| 369 | + } | |
| 370 | + | |
| 371 | + } | |
| 372 | + | |
| 373 | + gtk_table_attach(table,GTK_WIDGET(frame),1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0); | |
| 374 | + } | |
| 375 | + | |
| 327 | 376 | |
| 328 | 377 | gtk_container_set_border_width(GTK_CONTAINER(table),5); |
| 329 | 378 | |
| ... | ... | @@ -334,12 +383,12 @@ |
| 334 | 383 | #ifdef HAVE_LIBSSL |
| 335 | 384 | if(!strncmp(hostname,"L:",2)) |
| 336 | 385 | { |
| 337 | - gtk_toggle_button_set_active(checkbox,TRUE); | |
| 386 | + gtk_toggle_button_set_active(sslcheck,TRUE); | |
| 338 | 387 | hostname += 2; |
| 339 | 388 | } |
| 340 | 389 | #else |
| 341 | - gtk_toggle_button_set_active(checkbox,FALSE); | |
| 342 | - gtk_widget_set_sensitive(GTK_WIDGET(checkbox),FALSE); | |
| 390 | + gtk_toggle_button_set_active(sslcheck,FALSE); | |
| 391 | + gtk_widget_set_sensitive(GTK_WIDGET(sslcheck),FALSE); | |
| 343 | 392 | if(!strncmp(hostname,"L:",2)) |
| 344 | 393 | hostname += 2; |
| 345 | 394 | #endif |
| ... | ... | @@ -367,7 +416,7 @@ |
| 367 | 416 | case GTK_RESPONSE_ACCEPT: |
| 368 | 417 | gtk_widget_set_sensitive(dialog,FALSE); |
| 369 | 418 | |
| 370 | - hostname = g_strconcat( gtk_toggle_button_get_active(checkbox) ? "L:" : "", | |
| 419 | + hostname = g_strconcat( gtk_toggle_button_get_active(sslcheck) ? "L:" : "", | |
| 371 | 420 | gtk_entry_get_text(host), |
| 372 | 421 | ":", |
| 373 | 422 | gtk_entry_get_text(port), | ... | ... |