Commit e9ccd4ae952e6c1f7ac179acf83aa8e3b602a419

Authored by perry.werneck@gmail.com
1 parent 18e845d5

Implementando metodo para mudar as opcoes do dialogo de transferencia de arquivos

src/pw3270/ft/ftdialog.c
... ... @@ -50,12 +50,23 @@
50 50 VALUE_COUNT
51 51 };
52 52  
  53 + enum _button
  54 + {
  55 + BUTTON_ASCII,
  56 + BUTTON_CRLF,
  57 + BUTTON_APPEND,
  58 + BUTTON_REMAP,
  59 +
  60 + BUTTON_COUNT
  61 + };
  62 +
53 63 struct _v3270FTD
54 64 {
55 65 GtkDialog parent;
56 66 GtkWidget * filename[FILENAME_COUNT]; /**< Filenames for the transfer */
57 67 GtkWidget * units; /**< Units frame box */
58 68 GtkWidget * ready; /**< Send/Save button */
  69 + GtkToggleButton * button[BUTTON_COUNT]; /**< Buttons */
59 70 GtkSpinButton * value[VALUE_COUNT];
60 71 gboolean local; /**< TRUE if local filename is ok */
61 72 gboolean remote; /**< TRUE if remote filename is ok */
... ... @@ -74,6 +85,14 @@
74 85 struct ftoptions
75 86 {
76 87 LIB3270_FT_OPTION flag;
  88 + enum _button id;
  89 + const gchar * label;
  90 + const gchar * tooltip;
  91 + };
  92 +
  93 + struct rdoptions
  94 + {
  95 + LIB3270_FT_OPTION flag;
77 96 const gchar * label;
78 97 const gchar * tooltip;
79 98 };
... ... @@ -167,6 +186,7 @@ static GtkWidget * ftoption_new(v3270FTD *dialog, const struct ftoptions *opt)
167 186 gtk_grid_attach(grid,button,f&1,f/2,1,1);
168 187 g_object_set_data(G_OBJECT(button),"cfg",(gpointer) &opt[f]);
169 188 g_signal_connect(G_OBJECT(button),"toggled",G_CALLBACK(toggle_option),dialog);
  189 + dialog->button[opt->id] = GTK_TOGGLE_BUTTON(button);
170 190 }
171 191  
172 192 gtk_container_add(frame,GTK_WIDGET(grid));
... ... @@ -209,7 +229,7 @@ static GtkWidget * ftvalue_new(v3270FTD *dialog, GtkGrid *grid, int r, const str
209 229  
210 230 }
211 231  
212   -static GtkWidget * ftradio_new(v3270FTD *dialog, const gchar *title, const gchar *tooltip, const struct ftoptions *opt)
  232 +static GtkWidget * ftradio_new(v3270FTD *dialog, const gchar *title, const gchar *tooltip, const struct rdoptions *opt)
213 233 {
214 234 GtkContainer * frame = GTK_CONTAINER(gtk_frame_new(title));
215 235 GtkBox * box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL,2));
... ... @@ -366,26 +386,31 @@ GtkWidget * v3270_ft_dialog_new(GtkWidget *parent, LIB3270_FT_OPTION options)
366 386 {
367 387 {
368 388 LIB3270_FT_OPTION_ASCII,
  389 + BUTTON_ASCII,
369 390 N_( "_Text file." ),
370 391 N_( "Check for text files.")
371 392 },
372 393 {
373 394 LIB3270_FT_OPTION_CRLF,
  395 + BUTTON_CRLF,
374 396 N_( "Add _CR at end of line." ),
375 397 N_( "Adds Newline characters to each host file record before transferring it to the local workstation.")
376 398 },
377 399 {
378 400 LIB3270_FT_OPTION_APPEND,
  401 + BUTTON_APPEND,
379 402 N_( "_Append to destination" ),
380 403 N_( "Appends the source file to the destination file.")
381 404 },
382 405 {
383 406 LIB3270_FT_OPTION_REMAP,
  407 + BUTTON_REMAP,
384 408 N_("Re_map to ASCII Characters."),
385 409 N_("Remap the text to ensure maximum compatibility between the workstation's character set and encoding and the host's EBCDIC code page.")
386 410 },
387 411 {
388 412 0,
  413 + 0,
389 414 NULL,
390 415 NULL
391 416 }
... ... @@ -432,26 +457,31 @@ GtkWidget * v3270_ft_dialog_new(GtkWidget *parent, LIB3270_FT_OPTION options)
432 457 {
433 458 {
434 459 LIB3270_FT_OPTION_ASCII,
  460 + BUTTON_ASCII,
435 461 N_( "_Text file." ),
436 462 N_( "Check for text files.")
437 463 },
438 464 {
439 465 LIB3270_FT_OPTION_CRLF,
  466 + BUTTON_CRLF,
440 467 N_( "_CR delimited file." ),
441 468 N_( "Remove the default newline characters in local files before transferring them to the host.")
442 469 },
443 470 {
444 471 LIB3270_FT_OPTION_APPEND,
  472 + BUTTON_APPEND,
445 473 N_( "_Append to destination" ),
446 474 N_( "Appends the source file to the destination file.")
447 475 },
448 476 {
449 477 LIB3270_FT_OPTION_REMAP,
  478 + BUTTON_REMAP,
450 479 N_("Re_map to EBCDIC Characters."),
451 480 N_("Remap the text to ensure maximum compatibility between the workstation's character set and encoding and the host's EBCDIC code page.")
452 481 },
453 482 {
454 483 0,
  484 + 0,
455 485 NULL,
456 486 NULL
457 487 }
... ... @@ -466,7 +496,7 @@ GtkWidget * v3270_ft_dialog_new(GtkWidget *parent, LIB3270_FT_OPTION options)
466 496 gtk_grid_set_row_spacing(grid,5);
467 497  
468 498 // Create record format box
469   - static const struct ftoptions recfm[] =
  499 + static const struct rdoptions recfm[] =
470 500 {
471 501 {
472 502 LIB3270_FT_RECORD_FORMAT_DEFAULT,
... ... @@ -502,7 +532,7 @@ GtkWidget * v3270_ft_dialog_new(GtkWidget *parent, LIB3270_FT_OPTION options)
502 532  
503 533  
504 534 // Create allocation unit box
505   - static const struct ftoptions units[] =
  535 + static const struct rdoptions units[] =
506 536 {
507 537 {
508 538 LIB3270_FT_ALLOCATION_UNITS_DEFAULT,
... ... @@ -628,6 +658,17 @@ LIB3270_FT_OPTION v3270_ft_dialog_get_options(GtkWidget *widget)
628 658 void v3270_ft_dialog_set_options(GtkWidget *widget,LIB3270_FT_OPTION options)
629 659 {
630 660 g_return_if_fail(GTK_IS_V3270FTD(widget));
  661 + int f;
  662 +
  663 + for(f=0;f<BUTTON_COUNT;f++)
  664 + {
  665 + GtkToggleButton *button = GTK_V3270FTD(widget)->button[f];
  666 + if(button)
  667 + {
  668 + const struct ftoptions * opt = (const struct ftoptions *) g_object_get_data(G_OBJECT(button),"cfg");
  669 + gtk_toggle_button_set_active(button,(options & opt->flag) != 0);
  670 + }
  671 + }
631 672  
632 673 #warning Implementar
633 674 }
... ...
src/pw3270/ft/testprogram.c
... ... @@ -38,8 +38,12 @@ int main (int argc, char *argv[])
38 38  
39 39 gtk_init (&argc, &argv);
40 40  
  41 + {
  42 + GtkWidget *win = v3270_ft_dialog_new(NULL,LIB3270_FT_OPTION_RECEIVE);
  43 + v3270_ft_dialog_set_options(win,LIB3270_FT_OPTION_REMAP);
  44 + gtk_dialog_run(GTK_DIALOG(win));
  45 + }
41 46 // gtk_dialog_run(GTK_DIALOG(v3270_ft_dialog_new(NULL,LIB3270_FT_OPTION_SEND|LIB3270_FT_OPTION_REMAP)));
42   - gtk_dialog_run(GTK_DIALOG(v3270_ft_dialog_new(NULL,LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_REMAP)));
43 47  
44 48  
45 49 // v3270_ft_dialog_set_tso(win,TRUE);
... ...