Commit c7a62db8b9b926fae91a7db0d8bafbbe2131bc77
1 parent
1211f8b2
Exists in
master
and in
5 other branches
Trabalhando no diálogo de transferência de arquivos
Showing
3 changed files
with
127 additions
and
13 deletions
Show diff stats
src/include/lib3270/filetransfer.h
| @@ -37,30 +37,48 @@ | @@ -37,30 +37,48 @@ | ||
| 37 | #include <sys/time.h> | 37 | #include <sys/time.h> |
| 38 | #include <lib3270/charset.h> | 38 | #include <lib3270/charset.h> |
| 39 | 39 | ||
| 40 | - #define LIB3270_FT_OPTION_SEND 0x0000 | ||
| 41 | 40 | ||
| 41 | +/* | ||
| 42 | #define LIB3270_FT_RECORD_FORMAT_DEFAULT 0x0000 | 42 | #define LIB3270_FT_RECORD_FORMAT_DEFAULT 0x0000 |
| 43 | #define LIB3270_FT_RECORD_FORMAT_FIXED 0x0100 | 43 | #define LIB3270_FT_RECORD_FORMAT_FIXED 0x0100 |
| 44 | #define LIB3270_FT_RECORD_FORMAT_VARIABLE 0x0200 | 44 | #define LIB3270_FT_RECORD_FORMAT_VARIABLE 0x0200 |
| 45 | #define LIB3270_FT_RECORD_FORMAT_UNDEFINED 0x0300 | 45 | #define LIB3270_FT_RECORD_FORMAT_UNDEFINED 0x0300 |
| 46 | #define LIB3270_FT_RECORD_FORMAT_MASK LIB3270_FT_RECORD_FORMAT_UNDEFINED | 46 | #define LIB3270_FT_RECORD_FORMAT_MASK LIB3270_FT_RECORD_FORMAT_UNDEFINED |
| 47 | +*/ | ||
| 47 | 48 | ||
| 49 | +/* | ||
| 48 | #define LIB3270_FT_ALLOCATION_UNITS_DEFAULT 0x0000 | 50 | #define LIB3270_FT_ALLOCATION_UNITS_DEFAULT 0x0000 |
| 49 | #define LIB3270_FT_ALLOCATION_UNITS_TRACKS 0x1000 | 51 | #define LIB3270_FT_ALLOCATION_UNITS_TRACKS 0x1000 |
| 50 | #define LIB3270_FT_ALLOCATION_UNITS_CYLINDERS 0x2000 | 52 | #define LIB3270_FT_ALLOCATION_UNITS_CYLINDERS 0x2000 |
| 51 | #define LIB3270_FT_ALLOCATION_UNITS_AVBLOCK 0x3000 | 53 | #define LIB3270_FT_ALLOCATION_UNITS_AVBLOCK 0x3000 |
| 52 | #define LIB3270_FT_ALLOCATION_UNITS_MASK LIB3270_FT_ALLOCATION_UNITS_AVBLOCK | 54 | #define LIB3270_FT_ALLOCATION_UNITS_MASK LIB3270_FT_ALLOCATION_UNITS_AVBLOCK |
| 55 | +*/ | ||
| 53 | 56 | ||
| 54 | - typedef enum _lib3270_FT_FLAG | 57 | + typedef enum _lib3270_FT_OPTION |
| 55 | { | 58 | { |
| 56 | - LIB3270_FT_OPTION_RECEIVE = 0x0001, | ||
| 57 | - LIB3270_FT_OPTION_ASCII = 0x0002, /**< Convert to ascii */ | ||
| 58 | - LIB3270_FT_OPTION_CRLF = 0x0004, /**< Add crlf to each line */ | ||
| 59 | - LIB3270_FT_OPTION_APPEND = 0x0008, | ||
| 60 | - LIB3270_FT_OPTION_REMAP = 0x0010 /**< Remap ASCII<->EBCDIC */ | 59 | + LIB3270_FT_OPTION_SEND = 0x0000, |
| 60 | + | ||
| 61 | + LIB3270_FT_OPTION_RECEIVE = 0x0001, | ||
| 62 | + LIB3270_FT_OPTION_ASCII = 0x0002, /**< Convert to ascii */ | ||
| 63 | + LIB3270_FT_OPTION_CRLF = 0x0004, /**< Add crlf to each line */ | ||
| 64 | + LIB3270_FT_OPTION_APPEND = 0x0008, | ||
| 65 | + LIB3270_FT_OPTION_REMAP = 0x0010, /**< Remap ASCII<->EBCDIC */ | ||
| 66 | + | ||
| 67 | + LIB3270_FT_RECORD_FORMAT_DEFAULT = 0x0000, | ||
| 68 | + LIB3270_FT_RECORD_FORMAT_FIXED = 0x0100, | ||
| 69 | + LIB3270_FT_RECORD_FORMAT_VARIABLE = 0x0200, | ||
| 70 | + LIB3270_FT_RECORD_FORMAT_UNDEFINED = 0x0300, | ||
| 71 | + | ||
| 72 | + LIB3270_FT_ALLOCATION_UNITS_DEFAULT = 0x0000, | ||
| 73 | + LIB3270_FT_ALLOCATION_UNITS_TRACKS = 0x1000, | ||
| 74 | + LIB3270_FT_ALLOCATION_UNITS_CYLINDERS = 0x2000, | ||
| 75 | + LIB3270_FT_ALLOCATION_UNITS_AVBLOCK = 0x3000 | ||
| 61 | 76 | ||
| 62 | } LIB3270_FT_OPTION; | 77 | } LIB3270_FT_OPTION; |
| 63 | 78 | ||
| 79 | + #define LIB3270_FT_ALLOCATION_UNITS_MASK LIB3270_FT_ALLOCATION_UNITS_AVBLOCK | ||
| 80 | + #define LIB3270_FT_RECORD_FORMAT_MASK LIB3270_FT_RECORD_FORMAT_UNDEFINED | ||
| 81 | + | ||
| 64 | typedef enum _lib3270_ft_state | 82 | typedef enum _lib3270_ft_state |
| 65 | { | 83 | { |
| 66 | LIB3270_FT_STATE_NONE, /**< No transfer in progress */ | 84 | LIB3270_FT_STATE_NONE, /**< No transfer in progress */ |
src/pw3270/ft/ftdialog.c
| @@ -135,6 +135,8 @@ static void toggle_option(GtkToggleButton *button, v3270FTD *dialog) | @@ -135,6 +135,8 @@ static void toggle_option(GtkToggleButton *button, v3270FTD *dialog) | ||
| 135 | else | 135 | else |
| 136 | dialog->options &= ~opt->flag; | 136 | dialog->options &= ~opt->flag; |
| 137 | 137 | ||
| 138 | +// g_message("Option \"%s\" is %s flag=%08lx",opt->label,gtk_toggle_button_get_active(button) ? "ON" : "OFF", (unsigned long) opt->flag); | ||
| 139 | + | ||
| 138 | } | 140 | } |
| 139 | 141 | ||
| 140 | static GtkWidget * ftoption_new(v3270FTD *dialog, const struct ftoptions *opt) | 142 | static GtkWidget * ftoption_new(v3270FTD *dialog, const struct ftoptions *opt) |
| @@ -192,6 +194,32 @@ static GtkWidget * ftvalue_new(v3270FTD *dialog, const struct ftvalues *val) | @@ -192,6 +194,32 @@ static GtkWidget * ftvalue_new(v3270FTD *dialog, const struct ftvalues *val) | ||
| 192 | 194 | ||
| 193 | } | 195 | } |
| 194 | 196 | ||
| 197 | +static GtkWidget * ftradio_new(v3270FTD *dialog, const gchar *title, const gchar *tooltip, const struct ftoptions *opt) | ||
| 198 | +{ | ||
| 199 | + GtkContainer * frame = GTK_CONTAINER(gtk_frame_new(title)); | ||
| 200 | + GtkBox * box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL,2)); | ||
| 201 | + GSList * lst = NULL; | ||
| 202 | + int f; | ||
| 203 | + | ||
| 204 | + for(f=0;opt[f].label;f++) | ||
| 205 | + { | ||
| 206 | + GtkWidget * button = gtk_radio_button_new_with_label(lst,gettext(opt[f].label)); | ||
| 207 | + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),dialog->options & opt[f].flag); | ||
| 208 | + if(opt[f].tooltip) | ||
| 209 | + gtk_widget_set_tooltip_text(button,gettext(opt[f].tooltip)); | ||
| 210 | + | ||
| 211 | + g_object_set_data(G_OBJECT(button),"cfg",(gpointer) &opt[f]); | ||
| 212 | + g_signal_connect(G_OBJECT(button),"toggled",G_CALLBACK(toggle_option),dialog); | ||
| 213 | + | ||
| 214 | + gtk_box_pack_start(box,button,FALSE,TRUE,2); | ||
| 215 | + lst = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + gtk_widget_set_tooltip_text(GTK_WIDGET(frame),tooltip); | ||
| 219 | + gtk_container_add(frame,GTK_WIDGET(box)); | ||
| 220 | + return GTK_WIDGET(frame); | ||
| 221 | +} | ||
| 222 | + | ||
| 195 | GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) | 223 | GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) |
| 196 | { | 224 | { |
| 197 | v3270FTD *dialog = g_object_new(GTK_TYPE_V3270FTD, NULL); | 225 | v3270FTD *dialog = g_object_new(GTK_TYPE_V3270FTD, NULL); |
| @@ -345,6 +373,76 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) | @@ -345,6 +373,76 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) | ||
| 345 | gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftoption_new(dialog,opt),FALSE,TRUE,2); | 373 | gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftoption_new(dialog,opt),FALSE,TRUE,2); |
| 346 | 374 | ||
| 347 | 375 | ||
| 376 | + // Create format box | ||
| 377 | + GtkBox * box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL,2)); | ||
| 378 | + | ||
| 379 | + // Create record format box | ||
| 380 | + static const struct ftoptions recfm[] = | ||
| 381 | + { | ||
| 382 | + { | ||
| 383 | + LIB3270_FT_RECORD_FORMAT_DEFAULT, | ||
| 384 | + N_("Default"), | ||
| 385 | + N_("Use host default record format.") | ||
| 386 | + }, | ||
| 387 | + { | ||
| 388 | + LIB3270_FT_RECORD_FORMAT_FIXED, | ||
| 389 | + N_("Fixed"), | ||
| 390 | + N_("Creates a file with fixed-length records.") | ||
| 391 | + }, | ||
| 392 | + { | ||
| 393 | + LIB3270_FT_RECORD_FORMAT_VARIABLE, | ||
| 394 | + N_("Variable"), | ||
| 395 | + N_("Creates a file with variable-length records.") | ||
| 396 | + }, | ||
| 397 | + { | ||
| 398 | + LIB3270_FT_RECORD_FORMAT_UNDEFINED, | ||
| 399 | + N_("Undefined"), | ||
| 400 | + N_("Creates a file with undefined-length records (TSO hosts only).") | ||
| 401 | + }, | ||
| 402 | + { | ||
| 403 | + 0, | ||
| 404 | + NULL, | ||
| 405 | + NULL | ||
| 406 | + } | ||
| 407 | + }; | ||
| 408 | + | ||
| 409 | + gtk_box_pack_start( box, | ||
| 410 | + ftradio_new(dialog,_("Record format"),_("Controls the record format of files created on the host."),recfm),FALSE,TRUE,2); | ||
| 411 | + | ||
| 412 | + | ||
| 413 | + // Create allocation unit box | ||
| 414 | + static const struct ftoptions units[] = | ||
| 415 | + { | ||
| 416 | + { | ||
| 417 | + LIB3270_FT_ALLOCATION_UNITS_DEFAULT, | ||
| 418 | + N_("Default"), | ||
| 419 | + NULL | ||
| 420 | + }, | ||
| 421 | + { | ||
| 422 | + LIB3270_FT_ALLOCATION_UNITS_TRACKS, | ||
| 423 | + N_("Tracks"), | ||
| 424 | + NULL | ||
| 425 | + }, | ||
| 426 | + { | ||
| 427 | + LIB3270_FT_ALLOCATION_UNITS_CYLINDERS, | ||
| 428 | + N_("Cylinders"), | ||
| 429 | + NULL | ||
| 430 | + }, | ||
| 431 | + { | ||
| 432 | + LIB3270_FT_ALLOCATION_UNITS_AVBLOCK, | ||
| 433 | + N_("Avblock"), | ||
| 434 | + NULL | ||
| 435 | + }, | ||
| 436 | + { | ||
| 437 | + 0, | ||
| 438 | + NULL, | ||
| 439 | + NULL | ||
| 440 | + } | ||
| 441 | + }; | ||
| 442 | + | ||
| 443 | + gtk_box_pack_start( box, | ||
| 444 | + ftradio_new(dialog,_("Space allocation units"),_("Specifies the units for the TSO host primary and secondary space options."),units),FALSE,TRUE,2); | ||
| 445 | + | ||
| 348 | // Create values box | 446 | // Create values box |
| 349 | static const struct ftvalues val[] = | 447 | static const struct ftvalues val[] = |
| 350 | { | 448 | { |
| @@ -358,7 +456,7 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) | @@ -358,7 +456,7 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) | ||
| 358 | { | 456 | { |
| 359 | VALUE_PRIMSPACE, | 457 | VALUE_PRIMSPACE, |
| 360 | N_( "Primary space:" ), | 458 | N_( "Primary space:" ), |
| 361 | - N_( "Primary allocation for a file created on a TSO host.\nThe units are given by the Allocation option." ) | 459 | + N_( "Primary allocation for a file created on a TSO host.\nThe units are given by the space allocation units option." ) |
| 362 | }, | 460 | }, |
| 363 | 461 | ||
| 364 | { | 462 | { |
| @@ -370,7 +468,7 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) | @@ -370,7 +468,7 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) | ||
| 370 | { | 468 | { |
| 371 | VALUE_SECSPACE, | 469 | VALUE_SECSPACE, |
| 372 | N_( "Secondary space:" ), | 470 | N_( "Secondary space:" ), |
| 373 | - N_( "Secondary allocation for a file created on a TSO host.\nThe units are given by the Allocation option." ) | 471 | + N_( "Secondary allocation for a file created on a TSO host.\nThe units are given by the space allocation units option." ) |
| 374 | }, | 472 | }, |
| 375 | 473 | ||
| 376 | { | 474 | { |
| @@ -386,13 +484,11 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) | @@ -386,13 +484,11 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) | ||
| 386 | } | 484 | } |
| 387 | }; | 485 | }; |
| 388 | 486 | ||
| 487 | + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(box),FALSE,TRUE,2); | ||
| 389 | gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftvalue_new(dialog,val),FALSE,TRUE,2); | 488 | gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftvalue_new(dialog,val),FALSE,TRUE,2); |
| 390 | 489 | ||
| 391 | } | 490 | } |
| 392 | 491 | ||
| 393 | - | ||
| 394 | - // File transfer options | ||
| 395 | - | ||
| 396 | return GTK_WIDGET(dialog); | 492 | return GTK_WIDGET(dialog); |
| 397 | } | 493 | } |
| 398 | 494 |
src/pw3270/ft/testprogram.c
| @@ -38,7 +38,7 @@ int main (int argc, char *argv[]) | @@ -38,7 +38,7 @@ int main (int argc, char *argv[]) | ||
| 38 | 38 | ||
| 39 | gtk_init (&argc, &argv); | 39 | gtk_init (&argc, &argv); |
| 40 | // win = v3270_dialog_ft_new(LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_ASCII); | 40 | // win = v3270_dialog_ft_new(LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_ASCII); |
| 41 | - win = v3270_dialog_ft_new(0); | 41 | + win = v3270_dialog_ft_new(LIB3270_FT_OPTION_SEND); |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | gtk_widget_show_all (win); | 44 | gtk_widget_show_all (win); |