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