Commit 5e333817b3fe10f980a5f10a488608bf08b88fae
1 parent
c7a62db8
Exists in
master
and in
5 other branches
Implementando diálogo de transferência de arquivos
Showing
2 changed files
with
54 additions
and
28 deletions
Show diff stats
src/pw3270/ft/ftdialog.c
| ... | ... | @@ -141,8 +141,9 @@ static void toggle_option(GtkToggleButton *button, v3270FTD *dialog) |
| 141 | 141 | |
| 142 | 142 | static GtkWidget * ftoption_new(v3270FTD *dialog, const struct ftoptions *opt) |
| 143 | 143 | { |
| 144 | - GtkGrid * grid = GTK_GRID(gtk_grid_new()); | |
| 145 | - int f; | |
| 144 | + GtkContainer * frame = GTK_CONTAINER(gtk_frame_new(_("Transfer options"))); | |
| 145 | + GtkGrid * grid = GTK_GRID(gtk_grid_new()); | |
| 146 | + int f; | |
| 146 | 147 | |
| 147 | 148 | gtk_grid_set_row_homogeneous(grid,TRUE); |
| 148 | 149 | gtk_grid_set_column_homogeneous(grid,TRUE); |
| ... | ... | @@ -152,7 +153,7 @@ static GtkWidget * ftoption_new(v3270FTD *dialog, const struct ftoptions *opt) |
| 152 | 153 | for(f=0;opt[f].label;f++) |
| 153 | 154 | { |
| 154 | 155 | GtkWidget * button = gtk_check_button_new_with_mnemonic(gettext(opt[f].label)); |
| 155 | - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),dialog->options & opt[f].flag); | |
| 156 | + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),(dialog->options & opt[f].flag) != 0); | |
| 156 | 157 | gtk_widget_set_tooltip_text(GTK_WIDGET(button),gettext(opt[f].tooltip)); |
| 157 | 158 | gtk_widget_set_hexpand(button,TRUE); |
| 158 | 159 | gtk_grid_attach(grid,button,f&1,f/2,1,1); |
| ... | ... | @@ -160,25 +161,41 @@ static GtkWidget * ftoption_new(v3270FTD *dialog, const struct ftoptions *opt) |
| 160 | 161 | g_signal_connect(G_OBJECT(button),"toggled",G_CALLBACK(toggle_option),dialog); |
| 161 | 162 | } |
| 162 | 163 | |
| 163 | - return GTK_WIDGET(grid); | |
| 164 | + gtk_container_add(frame,GTK_WIDGET(grid)); | |
| 165 | + | |
| 166 | + return GTK_WIDGET(frame); | |
| 164 | 167 | } |
| 165 | 168 | |
| 166 | -static GtkWidget * ftvalue_new(v3270FTD *dialog, const struct ftvalues *val) | |
| 169 | +/* | |
| 170 | +http://stackoverflow.com/questions/16539127/gtkentry-change-text-on-user-input | |
| 171 | +void entry_insert(GtkEntryBuffer *buffer, guint position, gchar *chars, guint n_chars, gpointer user_data) | |
| 167 | 172 | { |
| 168 | - GtkGrid * grid = GTK_GRID(gtk_grid_new()); | |
| 169 | - int f; | |
| 170 | 173 | |
| 171 | - gtk_grid_set_row_homogeneous(grid,TRUE); | |
| 172 | - gtk_grid_set_column_homogeneous(grid,TRUE); | |
| 173 | - gtk_grid_set_column_spacing(grid,5); | |
| 174 | - gtk_grid_set_row_spacing(grid,5); | |
| 174 | +} | |
| 175 | +static void setup_numeric_entry(GtkEntry *entry) | |
| 176 | +{ | |
| 177 | + gtk_entry_set_max_length(entry,10); | |
| 178 | + gtk_entry_set_width_chars(entry,10); | |
| 179 | + gtk_entry_set_alignment(entry,1); | |
| 180 | + gtk_entry_set_input_purpose(entry,GTK_INPUT_PURPOSE_NUMBER); | |
| 181 | + g_signal_connect_after(G_OBJECT(entry), "insert-text", G_CALLBACK(entry_insert),NULL); | |
| 182 | +} | |
| 183 | +*/ | |
| 184 | + | |
| 185 | +static GtkWidget * ftvalue_new(v3270FTD *dialog, GtkGrid *grid, int r, const struct ftvalues *val) | |
| 186 | +{ | |
| 187 | + int f; | |
| 175 | 188 | |
| 176 | 189 | for(f=0;val[f].label;f++) |
| 177 | 190 | { |
| 178 | - int col = (f&1)*2; | |
| 179 | - int row = f/2; | |
| 180 | - GtkWidget * label = gtk_label_new_with_mnemonic(gettext(val[f].label)); | |
| 181 | - GtkEntry * entry = GTK_ENTRY(gtk_entry_new()); | |
| 191 | + int col = (f&1)*2; | |
| 192 | + int row = (f/2)+r; | |
| 193 | + GtkWidget * label = gtk_label_new_with_mnemonic(gettext(val[f].label)); | |
| 194 | + GtkWidget * entry = GTK_WIDGET(gtk_spin_button_new_with_range(0,99999,1)); | |
| 195 | + | |
| 196 | + gtk_widget_set_hexpand(GTK_WIDGET(label),TRUE); | |
| 197 | + gtk_widget_set_tooltip_text(GTK_WIDGET(label),gettext(val[f].tooltip)); | |
| 198 | + gtk_misc_set_alignment(GTK_MISC(label),0,0.5); | |
| 182 | 199 | |
| 183 | 200 | gtk_label_set_mnemonic_widget(GTK_LABEL(label),GTK_WIDGET(entry)); |
| 184 | 201 | gtk_widget_set_tooltip_text(GTK_WIDGET(entry),gettext(val[f].tooltip)); |
| ... | ... | @@ -204,7 +221,7 @@ static GtkWidget * ftradio_new(v3270FTD *dialog, const gchar *title, const gchar |
| 204 | 221 | for(f=0;opt[f].label;f++) |
| 205 | 222 | { |
| 206 | 223 | GtkWidget * button = gtk_radio_button_new_with_label(lst,gettext(opt[f].label)); |
| 207 | - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),dialog->options & opt[f].flag); | |
| 224 | + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),(dialog->options & opt[f].flag) != 0); | |
| 208 | 225 | if(opt[f].tooltip) |
| 209 | 226 | gtk_widget_set_tooltip_text(button,gettext(opt[f].tooltip)); |
| 210 | 227 | |
| ... | ... | @@ -304,6 +321,7 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) |
| 304 | 321 | gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftoption_new(dialog,opt),FALSE,TRUE,2); |
| 305 | 322 | |
| 306 | 323 | // Create values box |
| 324 | + /* | |
| 307 | 325 | static const struct ftvalues val[] = |
| 308 | 326 | { |
| 309 | 327 | { |
| ... | ... | @@ -319,8 +337,8 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) |
| 319 | 337 | } |
| 320 | 338 | }; |
| 321 | 339 | |
| 322 | - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftvalue_new(dialog,val),FALSE,TRUE,2); | |
| 323 | - | |
| 340 | + // gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftvalue_new(dialog,val),FALSE,TRUE,2); | |
| 341 | + */ | |
| 324 | 342 | } |
| 325 | 343 | else |
| 326 | 344 | { |
| ... | ... | @@ -374,7 +392,9 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) |
| 374 | 392 | |
| 375 | 393 | |
| 376 | 394 | // Create format box |
| 377 | - GtkBox * box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL,2)); | |
| 395 | + GtkGrid * grid = GTK_GRID(gtk_grid_new()); | |
| 396 | + gtk_grid_set_column_spacing(grid,5); | |
| 397 | + gtk_grid_set_row_spacing(grid,5); | |
| 378 | 398 | |
| 379 | 399 | // Create record format box |
| 380 | 400 | static const struct ftoptions recfm[] = |
| ... | ... | @@ -406,8 +426,10 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) |
| 406 | 426 | } |
| 407 | 427 | }; |
| 408 | 428 | |
| 409 | - gtk_box_pack_start( box, | |
| 410 | - ftradio_new(dialog,_("Record format"),_("Controls the record format of files created on the host."),recfm),FALSE,TRUE,2); | |
| 429 | + gtk_grid_attach( grid, | |
| 430 | + ftradio_new(dialog,_("Record format"),_("Controls the record format of files created on the host."),recfm), | |
| 431 | + 0,0,2,1 | |
| 432 | + ); | |
| 411 | 433 | |
| 412 | 434 | |
| 413 | 435 | // Create allocation unit box |
| ... | ... | @@ -440,15 +462,18 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) |
| 440 | 462 | } |
| 441 | 463 | }; |
| 442 | 464 | |
| 443 | - gtk_box_pack_start( box, | |
| 444 | - ftradio_new(dialog,_("Space allocation units"),_("Specifies the units for the TSO host primary and secondary space options."),units),FALSE,TRUE,2); | |
| 465 | + gtk_grid_attach( grid, | |
| 466 | + ftradio_new(dialog,_("Space allocation units"),_("Specifies the units for the TSO host primary and secondary space options."),units), | |
| 467 | + 2,0,2,1 | |
| 468 | + ); | |
| 469 | + | |
| 445 | 470 | |
| 446 | 471 | // Create values box |
| 447 | 472 | static const struct ftvalues val[] = |
| 448 | 473 | { |
| 449 | 474 | { |
| 450 | 475 | VALUE_LRECL, |
| 451 | - N_( "Lrecl:" ), | |
| 476 | + N_( "Record Length:" ), | |
| 452 | 477 | N_( "Specifies the record length (or maximum record length) for files created on the host." ) |
| 453 | 478 | }, |
| 454 | 479 | |
| ... | ... | @@ -461,7 +486,7 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) |
| 461 | 486 | |
| 462 | 487 | { |
| 463 | 488 | VALUE_BLKSIZE, |
| 464 | - N_( "Blksize:" ), | |
| 489 | + N_( "Block size:" ), | |
| 465 | 490 | N_( "Specifies the block size for files created on the host (TSO hosts only)." ) |
| 466 | 491 | }, |
| 467 | 492 | |
| ... | ... | @@ -484,8 +509,9 @@ GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options) |
| 484 | 509 | } |
| 485 | 510 | }; |
| 486 | 511 | |
| 487 | - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(box),FALSE,TRUE,2); | |
| 488 | - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),ftvalue_new(dialog,val),FALSE,TRUE,2); | |
| 512 | + ftvalue_new(dialog,grid,1,val); | |
| 513 | + | |
| 514 | + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(grid),FALSE,TRUE,2); | |
| 489 | 515 | |
| 490 | 516 | } |
| 491 | 517 | ... | ... |
src/pw3270/ft/testprogram.c
| ... | ... | @@ -38,7 +38,7 @@ int main (int argc, char *argv[]) |
| 38 | 38 | |
| 39 | 39 | gtk_init (&argc, &argv); |
| 40 | 40 | // win = v3270_dialog_ft_new(LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_ASCII); |
| 41 | - win = v3270_dialog_ft_new(LIB3270_FT_OPTION_SEND); | |
| 41 | + win = v3270_dialog_ft_new(LIB3270_FT_OPTION_SEND|LIB3270_FT_OPTION_REMAP); | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | gtk_widget_show_all (win); | ... | ... |