diff --git a/src/include/lib3270/filetransfer.h b/src/include/lib3270/filetransfer.h index fa5746b..21b103e 100644 --- a/src/include/lib3270/filetransfer.h +++ b/src/include/lib3270/filetransfer.h @@ -37,30 +37,48 @@ #include #include - #define LIB3270_FT_OPTION_SEND 0x0000 +/* #define LIB3270_FT_RECORD_FORMAT_DEFAULT 0x0000 #define LIB3270_FT_RECORD_FORMAT_FIXED 0x0100 #define LIB3270_FT_RECORD_FORMAT_VARIABLE 0x0200 #define LIB3270_FT_RECORD_FORMAT_UNDEFINED 0x0300 #define LIB3270_FT_RECORD_FORMAT_MASK LIB3270_FT_RECORD_FORMAT_UNDEFINED +*/ +/* #define LIB3270_FT_ALLOCATION_UNITS_DEFAULT 0x0000 #define LIB3270_FT_ALLOCATION_UNITS_TRACKS 0x1000 #define LIB3270_FT_ALLOCATION_UNITS_CYLINDERS 0x2000 #define LIB3270_FT_ALLOCATION_UNITS_AVBLOCK 0x3000 #define LIB3270_FT_ALLOCATION_UNITS_MASK LIB3270_FT_ALLOCATION_UNITS_AVBLOCK +*/ - typedef enum _lib3270_FT_FLAG + typedef enum _lib3270_FT_OPTION { - LIB3270_FT_OPTION_RECEIVE = 0x0001, - LIB3270_FT_OPTION_ASCII = 0x0002, /**< Convert to ascii */ - LIB3270_FT_OPTION_CRLF = 0x0004, /**< Add crlf to each line */ - LIB3270_FT_OPTION_APPEND = 0x0008, - LIB3270_FT_OPTION_REMAP = 0x0010 /**< Remap ASCII<->EBCDIC */ + LIB3270_FT_OPTION_SEND = 0x0000, + + LIB3270_FT_OPTION_RECEIVE = 0x0001, + LIB3270_FT_OPTION_ASCII = 0x0002, /**< Convert to ascii */ + LIB3270_FT_OPTION_CRLF = 0x0004, /**< Add crlf to each line */ + LIB3270_FT_OPTION_APPEND = 0x0008, + LIB3270_FT_OPTION_REMAP = 0x0010, /**< Remap ASCII<->EBCDIC */ + + LIB3270_FT_RECORD_FORMAT_DEFAULT = 0x0000, + LIB3270_FT_RECORD_FORMAT_FIXED = 0x0100, + LIB3270_FT_RECORD_FORMAT_VARIABLE = 0x0200, + LIB3270_FT_RECORD_FORMAT_UNDEFINED = 0x0300, + + LIB3270_FT_ALLOCATION_UNITS_DEFAULT = 0x0000, + LIB3270_FT_ALLOCATION_UNITS_TRACKS = 0x1000, + LIB3270_FT_ALLOCATION_UNITS_CYLINDERS = 0x2000, + LIB3270_FT_ALLOCATION_UNITS_AVBLOCK = 0x3000 } LIB3270_FT_OPTION; + #define LIB3270_FT_ALLOCATION_UNITS_MASK LIB3270_FT_ALLOCATION_UNITS_AVBLOCK + #define LIB3270_FT_RECORD_FORMAT_MASK LIB3270_FT_RECORD_FORMAT_UNDEFINED + typedef enum _lib3270_ft_state { LIB3270_FT_STATE_NONE, /**< No transfer in progress */ diff --git a/src/pw3270/ft/ftdialog.c b/src/pw3270/ft/ftdialog.c index a924509..d47054f 100644 --- a/src/pw3270/ft/ftdialog.c +++ b/src/pw3270/ft/ftdialog.c @@ -135,6 +135,8 @@ static void toggle_option(GtkToggleButton *button, v3270FTD *dialog) else dialog->options &= ~opt->flag; +// g_message("Option \"%s\" is %s flag=%08lx",opt->label,gtk_toggle_button_get_active(button) ? "ON" : "OFF", (unsigned long) opt->flag); + } static GtkWidget * ftoption_new(v3270FTD *dialog, const struct ftoptions *opt) @@ -192,6 +194,32 @@ static GtkWidget * ftvalue_new(v3270FTD *dialog, const struct ftvalues *val) } +static GtkWidget * ftradio_new(v3270FTD *dialog, const gchar *title, const gchar *tooltip, const struct ftoptions *opt) +{ + GtkContainer * frame = GTK_CONTAINER(gtk_frame_new(title)); + GtkBox * box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL,2)); + GSList * lst = NULL; + int f; + + for(f=0;opt[f].label;f++) + { + GtkWidget * button = gtk_radio_button_new_with_label(lst,gettext(opt[f].label)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),dialog->options & opt[f].flag); + if(opt[f].tooltip) + gtk_widget_set_tooltip_text(button,gettext(opt[f].tooltip)); + + g_object_set_data(G_OBJECT(button),"cfg",(gpointer) &opt[f]); + g_signal_connect(G_OBJECT(button),"toggled",G_CALLBACK(toggle_option),dialog); + + gtk_box_pack_start(box,button,FALSE,TRUE,2); + lst = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); + } + + gtk_widget_set_tooltip_text(GTK_WIDGET(frame),tooltip); + gtk_container_add(frame,GTK_WIDGET(box)); + return GTK_WIDGET(frame); +} + GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) { v3270FTD *dialog = g_object_new(GTK_TYPE_V3270FTD, NULL); @@ -345,6 +373,76 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftoption_new(dialog,opt),FALSE,TRUE,2); + // Create format box + GtkBox * box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL,2)); + + // Create record format box + static const struct ftoptions recfm[] = + { + { + LIB3270_FT_RECORD_FORMAT_DEFAULT, + N_("Default"), + N_("Use host default record format.") + }, + { + LIB3270_FT_RECORD_FORMAT_FIXED, + N_("Fixed"), + N_("Creates a file with fixed-length records.") + }, + { + LIB3270_FT_RECORD_FORMAT_VARIABLE, + N_("Variable"), + N_("Creates a file with variable-length records.") + }, + { + LIB3270_FT_RECORD_FORMAT_UNDEFINED, + N_("Undefined"), + N_("Creates a file with undefined-length records (TSO hosts only).") + }, + { + 0, + NULL, + NULL + } + }; + + gtk_box_pack_start( box, + ftradio_new(dialog,_("Record format"),_("Controls the record format of files created on the host."),recfm),FALSE,TRUE,2); + + + // Create allocation unit box + static const struct ftoptions units[] = + { + { + LIB3270_FT_ALLOCATION_UNITS_DEFAULT, + N_("Default"), + NULL + }, + { + LIB3270_FT_ALLOCATION_UNITS_TRACKS, + N_("Tracks"), + NULL + }, + { + LIB3270_FT_ALLOCATION_UNITS_CYLINDERS, + N_("Cylinders"), + NULL + }, + { + LIB3270_FT_ALLOCATION_UNITS_AVBLOCK, + N_("Avblock"), + NULL + }, + { + 0, + NULL, + NULL + } + }; + + gtk_box_pack_start( box, + ftradio_new(dialog,_("Space allocation units"),_("Specifies the units for the TSO host primary and secondary space options."),units),FALSE,TRUE,2); + // Create values box static const struct ftvalues val[] = { @@ -358,7 +456,7 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) { VALUE_PRIMSPACE, N_( "Primary space:" ), - N_( "Primary allocation for a file created on a TSO host.\nThe units are given by the Allocation option." ) + N_( "Primary allocation for a file created on a TSO host.\nThe units are given by the space allocation units option." ) }, { @@ -370,7 +468,7 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) { VALUE_SECSPACE, N_( "Secondary space:" ), - N_( "Secondary allocation for a file created on a TSO host.\nThe units are given by the Allocation option." ) + N_( "Secondary allocation for a file created on a TSO host.\nThe units are given by the space allocation units option." ) }, { @@ -386,13 +484,11 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) } }; + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(box),FALSE,TRUE,2); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftvalue_new(dialog,val),FALSE,TRUE,2); } - - // File transfer options - return GTK_WIDGET(dialog); } diff --git a/src/pw3270/ft/testprogram.c b/src/pw3270/ft/testprogram.c index 0acd160..af3e686 100644 --- a/src/pw3270/ft/testprogram.c +++ b/src/pw3270/ft/testprogram.c @@ -38,7 +38,7 @@ int main (int argc, char *argv[]) gtk_init (&argc, &argv); // win = v3270_dialog_ft_new(LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_ASCII); - win = v3270_dialog_ft_new(0); + win = v3270_dialog_ft_new(LIB3270_FT_OPTION_SEND); gtk_widget_show_all (win); -- libgit2 0.21.2