Commit bc73eec41438ecc817f51841b5102fda90f5f41e

Authored by perry.werneck@gmail.com
1 parent be192203

Implementando nova caixa de diálogo para transferência de arquivos

src/pw3270/ft/ftdialog.c
... ... @@ -100,6 +100,49 @@ static void browse_file(GtkButton *button,v3270FTD *parent)
100 100  
101 101 }
102 102  
  103 + struct ftoptions
  104 + {
  105 + LIB3270_FT_OPTION flag;
  106 + const gchar * label;
  107 + const gchar * tooltip;
  108 + };
  109 +
  110 +
  111 +static void toggle_option(GtkToggleButton *button, v3270FTD *dialog)
  112 +{
  113 + const struct ftoptions *opt = (const struct ftoptions *) g_object_get_data(G_OBJECT(button),"cfg");
  114 +
  115 + if(gtk_toggle_button_get_active(button))
  116 + dialog->options |= opt->flag;
  117 + else
  118 + dialog->options &= ~opt->flag;
  119 +
  120 +}
  121 +
  122 +static GtkWidget * ftoption_new(v3270FTD *dialog, const struct ftoptions *opt)
  123 +{
  124 + GtkGrid * grid = GTK_GRID(gtk_grid_new());
  125 + int f;
  126 +
  127 + gtk_grid_set_row_homogeneous(grid,TRUE);
  128 + gtk_grid_set_column_homogeneous(grid,TRUE);
  129 + gtk_grid_set_column_spacing(grid,5);
  130 + gtk_grid_set_row_spacing(grid,5);
  131 +
  132 + for(f=0;opt[f].label;f++)
  133 + {
  134 + GtkWidget * button = gtk_check_button_new_with_mnemonic(gettext(opt[f].label));
  135 + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),dialog->options & opt[f].flag);
  136 + gtk_widget_set_tooltip_text(GTK_WIDGET(button),gettext(opt[f].tooltip));
  137 + gtk_widget_set_hexpand(button,TRUE);
  138 + gtk_grid_attach(grid,button,f&1,f/2,1,1);
  139 + g_object_set_data(G_OBJECT(button),"cfg",(gpointer) &opt[f]);
  140 + g_signal_connect(G_OBJECT(button),"toggled",G_CALLBACK(toggle_option),dialog);
  141 + }
  142 +
  143 + return GTK_WIDGET(grid);
  144 +}
  145 +
103 146 GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options)
104 147 {
105 148 v3270FTD *dialog = g_object_new(GTK_TYPE_V3270FTD, NULL);
... ... @@ -135,9 +178,40 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options)
135 178 gtk_widget_set_tooltip_text(GTK_WIDGET(browse),_("Select file"));
136 179 g_signal_connect(G_OBJECT(browse),"clicked",G_CALLBACK(browse_file),dialog);
137 180  
  181 + GtkWidget * ftOptions;
  182 +
138 183 if(options & LIB3270_FT_OPTION_RECEIVE)
139 184 {
140 185 // It's receiving file first host filename, then local filename
  186 + static const struct ftoptions opt[] =
  187 + {
  188 + {
  189 + LIB3270_FT_OPTION_ASCII,
  190 + N_( "_Text file" ),
  191 + N_( "Mark this box if it's a text file.")
  192 + },
  193 + {
  194 + LIB3270_FT_OPTION_CRLF,
  195 + N_( "Add/Remove _CR at end of line" ),
  196 + N_( "If check the file will receive a CR/LF at the end of every line.")
  197 + },
  198 + {
  199 + LIB3270_FT_OPTION_APPEND,
  200 + N_( "_Append" ),
  201 + N_( "If check the data will be appended to the current file, if uncheck the file will be replaced.")
  202 + },
  203 + {
  204 + LIB3270_FT_OPTION_REMAP,
  205 + N_("_Remap ASCII Characters"),
  206 + N_("Check to translate file contents from EBCDIC to ASCII.")
  207 + },
  208 + {
  209 + 0,
  210 + NULL,
  211 + NULL
  212 + }
  213 + };
  214 +
141 215 gtk_window_set_title(GTK_WINDOW(dialog),_( "Receive file from host" ));
142 216  
143 217 gtk_grid_attach(grid,label[FILENAME_HOST],0,0,1,1);
... ... @@ -150,6 +224,8 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options)
150 224 gtk_widget_set_tooltip_text(dialog->filename[FILENAME_HOST],_("Name of the origin file on the host"));
151 225 gtk_widget_set_tooltip_text(dialog->filename[FILENAME_LOCAL],_("Where to save the received file"));
152 226  
  227 + ftOptions = ftoption_new(dialog,opt);
  228 +
153 229 }
154 230 else
155 231 {
... ... @@ -168,6 +244,7 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options)
168 244 }
169 245  
170 246 gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(grid),FALSE,TRUE,2);
  247 + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftOptions,FALSE,TRUE,2);
171 248  
172 249 // File transfer options
173 250  
... ...
src/pw3270/ft/testprogram.c
... ... @@ -37,7 +37,7 @@ int main (int argc, char *argv[])
37 37 GtkWidget *win;
38 38  
39 39 gtk_init (&argc, &argv);
40   - win = v3270_dialog_ft_new(LIB3270_FT_OPTION_RECEIVE);
  40 + win = v3270_dialog_ft_new(LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_ASCII);
41 41  
42 42  
43 43 gtk_widget_show_all (win);
... ...