Commit 1211f8b239a71bbeffba18984b0f3d80577e43c0

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

Reimplementando diálogo de transferência de arquivos

src/pw3270/ft/ftdialog.c
... ... @@ -39,10 +39,22 @@
39 39 FILENAME_COUNT
40 40 };
41 41  
  42 + enum _value
  43 + {
  44 + VALUE_LRECL,
  45 + VALUE_BLKSIZE,
  46 + VALUE_PRIMSPACE,
  47 + VALUE_SECSPACE,
  48 + VALUE_DFT,
  49 +
  50 + VALUE_COUNT
  51 + };
  52 +
42 53 struct _v3270FTD
43 54 {
44 55 GtkDialog parent;
45 56 GtkWidget * filename[FILENAME_COUNT]; /**< Filenames for the transfer */
  57 + int value[VALUE_COUNT];
46 58 LIB3270_FT_OPTION options;
47 59 };
48 60  
... ... @@ -55,7 +67,21 @@
55 67  
56 68 G_DEFINE_TYPE(v3270FTD, v3270FTD, GTK_TYPE_DIALOG);
57 69  
58   -/*--[ Globals ]--------------------------------------------------------------------------------------*/
  70 + struct ftoptions
  71 + {
  72 + LIB3270_FT_OPTION flag;
  73 + const gchar * label;
  74 + const gchar * tooltip;
  75 + };
  76 +
  77 + struct ftvalues
  78 + {
  79 + int id;
  80 + const gchar * label;
  81 + const gchar * tooltip;
  82 + };
  83 +
  84 +/*--[ Implement ]------------------------------------------------------------------------------------*/
59 85  
60 86 static void v3270FTD_class_init(v3270FTDClass *klass)
61 87 {
... ... @@ -100,14 +126,6 @@ static void browse_file(GtkButton *button,v3270FTD *parent)
100 126  
101 127 }
102 128  
103   - struct ftoptions
104   - {
105   - LIB3270_FT_OPTION flag;
106   - const gchar * label;
107   - const gchar * tooltip;
108   - };
109   -
110   -
111 129 static void toggle_option(GtkToggleButton *button, v3270FTD *dialog)
112 130 {
113 131 const struct ftoptions *opt = (const struct ftoptions *) g_object_get_data(G_OBJECT(button),"cfg");
... ... @@ -143,6 +161,37 @@ static GtkWidget * ftoption_new(v3270FTD *dialog, const struct ftoptions *opt)
143 161 return GTK_WIDGET(grid);
144 162 }
145 163  
  164 +static GtkWidget * ftvalue_new(v3270FTD *dialog, const struct ftvalues *val)
  165 +{
  166 + GtkGrid * grid = GTK_GRID(gtk_grid_new());
  167 + int f;
  168 +
  169 + gtk_grid_set_row_homogeneous(grid,TRUE);
  170 + gtk_grid_set_column_homogeneous(grid,TRUE);
  171 + gtk_grid_set_column_spacing(grid,5);
  172 + gtk_grid_set_row_spacing(grid,5);
  173 +
  174 + for(f=0;val[f].label;f++)
  175 + {
  176 + int col = (f&1)*2;
  177 + int row = f/2;
  178 + GtkWidget * label = gtk_label_new_with_mnemonic(gettext(val[f].label));
  179 + GtkEntry * entry = GTK_ENTRY(gtk_entry_new());
  180 +
  181 + gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(entry));
  182 + gtk_widget_set_tooltip_text(GTK_WIDGET(entry),gettext(val[f].tooltip));
  183 +
  184 + g_object_set_data(G_OBJECT(entry),"cfg",(gpointer) &val[f]);
  185 +
  186 + gtk_grid_attach(grid,GTK_WIDGET(label),col,row,1,1);
  187 + gtk_grid_attach(grid,GTK_WIDGET(entry),col+1,row,1,1);
  188 +
  189 + }
  190 +
  191 + return GTK_WIDGET(grid);
  192 +
  193 +}
  194 +
146 195 GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options)
147 196 {
148 197 v3270FTD *dialog = g_object_new(GTK_TYPE_V3270FTD, NULL);
... ... @@ -172,38 +221,50 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options)
172 221 gtk_grid_set_column_spacing(grid,5);
173 222 gtk_grid_set_row_spacing(grid,5);
174 223  
175   -// GtkButton * browse = GTK_BUTTON(gtk_button_new_with_mnemonic(_( "_Browse")));
176 224 GtkButton * browse = GTK_BUTTON(gtk_button_new_from_icon_name("text-x-generic",GTK_ICON_SIZE_BUTTON));
177 225 gtk_button_set_focus_on_click(browse,FALSE);
178 226 gtk_widget_set_tooltip_text(GTK_WIDGET(browse),_("Select file"));
179 227 g_signal_connect(G_OBJECT(browse),"clicked",G_CALLBACK(browse_file),dialog);
180 228  
181   - GtkWidget * ftOptions;
182   -
183 229 if(options & LIB3270_FT_OPTION_RECEIVE)
184 230 {
185 231 // It's receiving file first host filename, then local filename
  232 + gtk_window_set_title(GTK_WINDOW(dialog),_( "Receive file from host" ));
  233 +
  234 + gtk_grid_attach(grid,label[FILENAME_HOST],0,0,1,1);
  235 + gtk_grid_attach(grid,label[FILENAME_LOCAL],0,1,1,1);
  236 +
  237 + gtk_grid_attach(grid,dialog->filename[FILENAME_HOST],1,0,3,1);
  238 + gtk_grid_attach(grid,dialog->filename[FILENAME_LOCAL],1,1,3,1);
  239 + gtk_grid_attach(grid,GTK_WIDGET(browse),5,1,1,1);
  240 +
  241 + gtk_widget_set_tooltip_text(dialog->filename[FILENAME_HOST],_("Name of the source file."));
  242 + gtk_widget_set_tooltip_text(dialog->filename[FILENAME_LOCAL],_("Where to save the received file."));
  243 +
  244 + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(grid),FALSE,TRUE,2);
  245 +
  246 + // Create options box
186 247 static const struct ftoptions opt[] =
187 248 {
188 249 {
189 250 LIB3270_FT_OPTION_ASCII,
190   - N_( "_Text file" ),
191   - N_( "Mark this box if it's a text file.")
  251 + N_( "_Text file." ),
  252 + N_( "Check for text files.")
192 253 },
193 254 {
194 255 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.")
  256 + N_( "Add _CR at end of line." ),
  257 + N_( "Adds Newline characters to each host file record before transferring it to the local workstation.")
197 258 },
198 259 {
199 260 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.")
  261 + N_( "_Append to destination" ),
  262 + N_( "Appends the source file to the destination file.")
202 263 },
203 264 {
204 265 LIB3270_FT_OPTION_REMAP,
205   - N_("_Remap ASCII Characters"),
206   - N_("Check to translate file contents from EBCDIC to ASCII.")
  266 + N_("_Remap to ASCII Characters."),
  267 + N_("Remap the text to ensure maximum compatibility between the workstation's character set and encoding and the host's EBCDIC code page.")
207 268 },
208 269 {
209 270 0,
... ... @@ -212,19 +273,25 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options)
212 273 }
213 274 };
214 275  
215   - gtk_window_set_title(GTK_WINDOW(dialog),_( "Receive file from host" ));
216   -
217   - gtk_grid_attach(grid,label[FILENAME_HOST],0,0,1,1);
218   - gtk_grid_attach(grid,label[FILENAME_LOCAL],0,1,1,1);
219   -
220   - gtk_grid_attach(grid,dialog->filename[FILENAME_HOST],1,0,3,1);
221   - gtk_grid_attach(grid,dialog->filename[FILENAME_LOCAL],1,1,3,1);
222   - gtk_grid_attach(grid,GTK_WIDGET(browse),5,1,1,1);
  276 + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftoption_new(dialog,opt),FALSE,TRUE,2);
223 277  
224   - gtk_widget_set_tooltip_text(dialog->filename[FILENAME_HOST],_("Name of the origin file on the host"));
225   - gtk_widget_set_tooltip_text(dialog->filename[FILENAME_LOCAL],_("Where to save the received file"));
  278 + // Create values box
  279 + static const struct ftvalues val[] =
  280 + {
  281 + {
  282 + VALUE_DFT,
  283 + N_( "DFT B_uffer size:" ),
  284 + N_( "Buffer size for DFT-mode transfers. Can range from 256 to 32768. Larger values give better performance, but some hosts may not be able to support them." )
  285 + },
  286 +
  287 + {
  288 + 0,
  289 + NULL,
  290 + NULL
  291 + }
  292 + };
226 293  
227   - ftOptions = ftoption_new(dialog,opt);
  294 + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftvalue_new(dialog,val),FALSE,TRUE,2);
228 295  
229 296 }
230 297 else
... ... @@ -232,19 +299,97 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options)
232 299 // It's sending file first local filename, then hostfilename
233 300 gtk_window_set_title(GTK_WINDOW(dialog),_( "Send file to host" ));
234 301  
235   - gtk_grid_attach(grid,dialog->filename[FILENAME_LOCAL],0,0,1,1);
236   - gtk_grid_attach(grid,dialog->filename[FILENAME_HOST],0,1,1,1);
  302 + gtk_grid_attach(grid,label[FILENAME_LOCAL],0,0,1,1);
  303 + gtk_grid_attach(grid,label[FILENAME_HOST],0,1,1,1);
237 304  
238 305 gtk_grid_attach(grid,dialog->filename[FILENAME_LOCAL],1,0,3,1);
  306 + gtk_grid_attach(grid,GTK_WIDGET(browse),5,0,1,1);
  307 +
239 308 gtk_grid_attach(grid,dialog->filename[FILENAME_HOST],1,1,3,1);
240 309  
241   - gtk_widget_set_tooltip_text(dialog->filename[FILENAME_HOST],_("Name of the target file on the host"));
242   - gtk_widget_set_tooltip_text(dialog->filename[FILENAME_LOCAL],_("Path of the local file to send"));
  310 + gtk_widget_set_tooltip_text(dialog->filename[FILENAME_HOST],_("Name of the target file."));
  311 + gtk_widget_set_tooltip_text(dialog->filename[FILENAME_LOCAL],_("Path of the local file to send."));
  312 +
  313 + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(grid),FALSE,TRUE,2);
  314 +
  315 + // Create options box
  316 + static const struct ftoptions opt[] =
  317 + {
  318 + {
  319 + LIB3270_FT_OPTION_ASCII,
  320 + N_( "_Text file." ),
  321 + N_( "Check for text files.")
  322 + },
  323 + {
  324 + LIB3270_FT_OPTION_CRLF,
  325 + N_( "_CR delimited file." ),
  326 + N_( "Remove the default newline characters in local files before transferring them to the host.")
  327 + },
  328 + {
  329 + LIB3270_FT_OPTION_APPEND,
  330 + N_( "_Append to destination" ),
  331 + N_( "Appends the source file to the destination file.")
  332 + },
  333 + {
  334 + LIB3270_FT_OPTION_REMAP,
  335 + N_("_Remap to EBCDIC Characters."),
  336 + N_("Remap the text to ensure maximum compatibility between the workstation's character set and encoding and the host's EBCDIC code page.")
  337 + },
  338 + {
  339 + 0,
  340 + NULL,
  341 + NULL
  342 + }
  343 + };
  344 +
  345 + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftoption_new(dialog,opt),FALSE,TRUE,2);
  346 +
  347 +
  348 + // Create values box
  349 + static const struct ftvalues val[] =
  350 + {
  351 + {
  352 + VALUE_LRECL,
  353 + N_( "Lrecl:" ),
  354 + N_( "Specifies the record length (or maximum record length) for files created on the host." )
  355 + },
  356 +
  357 +
  358 + {
  359 + VALUE_PRIMSPACE,
  360 + N_( "Primary space:" ),
  361 + N_( "Primary allocation for a file created on a TSO host.\nThe units are given by the Allocation option." )
  362 + },
  363 +
  364 + {
  365 + VALUE_BLKSIZE,
  366 + N_( "Blksize:" ),
  367 + N_( "Specifies the block size for files created on the host (TSO hosts only)." )
  368 + },
  369 +
  370 + {
  371 + VALUE_SECSPACE,
  372 + N_( "Secondary space:" ),
  373 + N_( "Secondary allocation for a file created on a TSO host.\nThe units are given by the Allocation option." )
  374 + },
  375 +
  376 + {
  377 + VALUE_DFT,
  378 + N_( "DFT B_uffer size:" ),
  379 + N_( "Buffer size for DFT-mode transfers. Can range from 256 to 32768. Larger values give better performance, but some hosts may not be able to support them." )
  380 + },
  381 +
  382 + {
  383 + 0,
  384 + NULL,
  385 + NULL
  386 + }
  387 + };
  388 +
  389 + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftvalue_new(dialog,val),FALSE,TRUE,2);
243 390  
244 391 }
245 392  
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);
248 393  
249 394 // File transfer options
250 395  
... ...
src/pw3270/ft/testprogram.c
... ... @@ -37,7 +37,8 @@ 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|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 42  
42 43  
43 44 gtk_widget_show_all (win);
... ...