Commit 367599abedee4ad93fc1eb3c44895d0f4fd689a6

Authored by Perry Werneck
1 parent 79a02067

Implementing keypad view/hide menus.

src/include/pw3270.h
... ... @@ -52,7 +52,7 @@
52 52 #define I_(string) g_intern_static_string (string)
53 53  
54 54  
55   - void pw3270_load_placeholders(GtkBuilder * builder);
  55 + void pw3270_load_placeholders(GApplication *application, GtkBuilder * builder);
56 56 // GtkWidget * pw3270_frame_new(GtkWidget * child, const gchar *title);
57 57  
58 58 // Application settings widget
... ...
src/include/pw3270/application.h
... ... @@ -77,6 +77,7 @@
77 77  
78 78 // Tools
79 79 GtkBuilder * pw3270_application_get_builder(const gchar *name);
  80 +
80 81 void gtk_container_remove_all(GtkContainer *container);
81 82  
82 83 // Actions
... ...
src/include/pw3270/keypad.h
... ... @@ -54,7 +54,7 @@
54 54  
55 55 GList * pw3270_keypad_model_new_from_xml(GList *keypads, const gchar *filename);
56 56 GtkWidget * pw3270_keypad_get_from_model(GObject *model);
57   - const gchar * pw3270_keypad_model_get_action_name(GObject *model);
  57 + const gchar * pw3270_keypad_model_get_name(GObject *model);
58 58 const gchar * pw3270_keypad_model_get_label(GObject *model);
59 59  
60 60 typedef enum _keypad_position {
... ...
src/main/placeholders.c
... ... @@ -35,14 +35,42 @@
35 35  
36 36 #include "private.h"
37 37 #include <pw3270/application.h>
  38 + #include <pw3270/keypad.h>
38 39 #include <lib3270.h>
39 40 #include <lib3270/log.h>
40 41  
41 42 /*---[ Implement ]----------------------------------------------------------------------------------*/
42 43  
43   - void pw3270_load_placeholders(GtkBuilder * builder) {
  44 + static GMenu * get_keypad_menu(GApplication *application) {
44 45  
45   - GObject * placeholder = gtk_builder_get_object(builder, "font-select-placeholder");
  46 + GList * keypads = pw3270_application_get_keypad_models(application);
  47 +
  48 + if(!keypads)
  49 + return NULL;
  50 +
  51 + GMenu * menu = g_menu_new();
  52 +
  53 + // Create keypad items.
  54 + GList *item;
  55 + for(item = keypads;item;item = g_list_next(item)) {
  56 + GObject * model = G_OBJECT(item->data);
  57 + g_autofree gchar * action_name = g_strconcat("win.keypad.",pw3270_keypad_model_get_name(model),NULL);
  58 + g_menu_append(menu,pw3270_keypad_model_get_label(model),action_name);
  59 + }
  60 +
  61 + return menu;
  62 +
  63 + }
  64 +
  65 + void pw3270_load_placeholders(GApplication *application, GtkBuilder * builder) {
  66 +
  67 + GObject * placeholder;
  68 + size_t ix;
  69 +
  70 + //
  71 + // Load fonts
  72 + //
  73 + placeholder = gtk_builder_get_object(builder, "font-select-placeholder");
46 74  
47 75 if(placeholder && G_IS_MENU(placeholder)) {
48 76  
... ... @@ -52,7 +80,6 @@
52 80 PangoFontFamily **families;
53 81 pango_context_list_families(gdk_pango_context_get_for_screen(gdk_screen_get_default()),&families, &n_families);
54 82  
55   - size_t ix;
56 83 for(ix=0; ix < (size_t) n_families; ix++)
57 84 {
58 85 if(!pango_font_family_is_monospace(families[ix]))
... ... @@ -66,5 +93,30 @@
66 93  
67 94 }
68 95  
  96 + //
  97 + // View options
  98 + //
  99 + GMenu * keypad_menu = get_keypad_menu(application);
  100 +
  101 + if(keypad_menu) {
  102 +
  103 + static const gchar * placeholders[] = {
  104 + "view-menu-placeholder",
  105 + "view-when-offline-placeholder",
  106 + "view-when-online-placeholder"
  107 + };
  108 +
  109 + for(ix = 0; ix < G_N_ELEMENTS(placeholders); ix++) {
  110 +
  111 + placeholder = gtk_builder_get_object(builder, placeholders[ix]);
  112 +
  113 + if(placeholder) {
  114 + g_menu_append_item(G_MENU(placeholder), g_menu_item_new_submenu(_("Keypads"),G_MENU_MODEL(keypad_menu)));
  115 + }
  116 +
  117 + }
  118 +
  119 + g_object_unref(keypad_menu);
  120 + }
69 121  
70 122 }
... ...
src/objects/application/application.c
... ... @@ -415,7 +415,7 @@
415 415  
416 416 gtk_application_set_menubar(GTK_APPLICATION (application), G_MENU_MODEL(gtk_builder_get_object (builder, "menubar")));
417 417  
418   - pw3270_load_placeholders(builder);
  418 + pw3270_load_placeholders(application, builder);
419 419  
420 420 g_object_unref(builder);
421 421  
... ...
src/objects/keypad/model.c
... ... @@ -351,7 +351,7 @@
351 351 return (KEYPAD_POSITION) PW_KEYPAD_MODEL(model)->position;
352 352 }
353 353  
354   - const gchar * pw3270_keypad_model_get_action_name(GObject *model) {
  354 + const gchar * pw3270_keypad_model_get_name(GObject *model) {
355 355 g_return_val_if_fail(PW_IS_KEYPAD_MODEL(model), NULL);
356 356 return PW_KEYPAD_MODEL(model)->name;
357 357 }
... ...
src/objects/window/window.c
... ... @@ -194,9 +194,11 @@
194 194 g_signal_connect(widget,"hide",G_CALLBACK(keypad_hide),model);
195 195 g_signal_connect(widget,"show",G_CALLBACK(keypad_show),model);
196 196  
  197 + g_autofree gchar * action_name = g_strconcat("keypad.",pw3270_keypad_model_get_name(model),NULL);
  198 +
197 199 GPropertyAction * action =
198 200 g_property_action_new(
199   - pw3270_keypad_model_get_action_name(model),
  201 + action_name,
200 202 widget,
201 203 "visible"
202 204 );
... ... @@ -243,7 +245,7 @@
243 245 gtk_notebook_set_action_widget(widget->notebook,new_tab,GTK_PACK_START);
244 246 }
245 247  
246   - widget->toolbar = GTK_TOOLBAR(pw3270_toolbar_new());
  248 + widget->toolbar = GTK_TOOLBAR(pw3270_toolbar_new());
247 249 gtk_box_pack_start(container,GTK_WIDGET(widget->toolbar),FALSE,TRUE,0);
248 250  
249 251 //
... ... @@ -447,6 +449,7 @@
447 449 // Get builder
448 450 //
449 451 g_autoptr(GtkBuilder) builder = pw3270_application_get_builder("window.xml");
  452 + pw3270_load_placeholders(G_APPLICATION(application), builder);
450 453  
451 454 // Load popup menus.
452 455 const gchar * popup_menus[PW3270_APP_WINDOW_POPUP_COUNT] = {
... ...
ui/application.xml
... ... @@ -79,7 +79,6 @@
79 79  
80 80 </submenu>
81 81  
82   -
83 82 <item>
84 83 <attribute name="label" translatable="yes">Application preferences</attribute>
85 84 <attribute name="action">app.preferences</attribute>
... ...
ui/window.xml
... ... @@ -274,181 +274,191 @@
274 274  
275 275 <menu id="popup-over-unselected-area">
276 276  
277   - <submenu>
278   -
279   - <attribute name='label' translatable='yes'>_Edit</attribute>
280   -
281   - <section>
282   -
283   - <item>
284   - <attribute name="label" translatable="yes">Paste from clipboard</attribute>
285   - <attribute name="action">win.paste</attribute>
286   - </item>
287   -
288   - <item>
289   - <attribute name="label" translatable="yes">Paste next</attribute>
290   - <attribute name="action">win.paste-next</attribute>
291   - </item>
292   -
293   - <item>
294   - <attribute name="label" translatable="yes">Paste from text file</attribute>
295   - <attribute name="action">win.paste-file</attribute>
296   - </item>
297   -
298   - </section>
299   -
300   - <section>
301   -
302   - <item>
303   - <attribute name="label" translatable="yes">Select all</attribute>
304   - <attribute name="action">win.select-all</attribute>
305   - </item>
306   -
307   - <item>
308   - <attribute name="label" translatable="yes">Select Field</attribute>
309   - <attribute name="action">win.select-field</attribute>
310   - </item>
311   -
312   - <item>
313   - <attribute name="label" translatable="yes">Reselect</attribute>
314   - <attribute name="action">win.reselect</attribute>
315   - </item>
316   -
317   - </section>
318   -
319   - <section>
  277 + <submenu>
320 278  
321   - <item>
322   - <attribute name="label" translatable="yes">Clear</attribute>
323   - <attribute name="action">win.clear</attribute>
324   - </item>
  279 + <attribute name='label' translatable='yes'>_Edit</attribute>
325 280  
326   - <item>
327   - <attribute name="label" translatable="yes">Erase input</attribute>
328   - <attribute name="action">win.erase_input</attribute>
329   - </item>
  281 + <section>
330 282  
331 283 <item>
332   - <attribute name="label" translatable="yes">Delete Field</attribute>
333   - <attribute name="action">win.delete_field</attribute>
  284 + <attribute name="label" translatable="yes">Paste from clipboard</attribute>
  285 + <attribute name="action">win.paste</attribute>
334 286 </item>
335 287  
336 288 <item>
337   - <attribute name="label" translatable="yes">Erase to end of field</attribute>
338   - <attribute name="action">win.erase_eof</attribute>
  289 + <attribute name="label" translatable="yes">Paste next</attribute>
  290 + <attribute name="action">win.paste-next</attribute>
339 291 </item>
340 292  
341 293 <item>
342   - <attribute name="label" translatable="yes">Erase to end of line</attribute>
343   - <attribute name="action">win.erase_eol</attribute>
  294 + <attribute name="label" translatable="yes">Paste from text file</attribute>
  295 + <attribute name="action">win.paste-file</attribute>
344 296 </item>
345 297  
346   - </section>
347   -
348   - </submenu>
  298 + </section>
349 299  
350   - <item>
351   - <attribute name="label" translatable="yes">Save screen</attribute>
352   - <attribute name="action">win.save.screen</attribute>
353   - </item>
  300 + <section>
354 301  
355   - <item>
356   - <attribute name="label" translatable="yes">Print screen</attribute>
357   - <attribute name="action">win.print.screen</attribute>
358   - </item>
  302 + <item>
  303 + <attribute name="label" translatable="yes">Select all</attribute>
  304 + <attribute name="action">win.select-all</attribute>
  305 + </item>
359 306  
360   - <item>
361   - <attribute name="label" translatable="yes">Send/Receive files</attribute>
362   - <attribute name="action">win.file.transfer</attribute>
363   - </item>
  307 + <item>
  308 + <attribute name="label" translatable="yes">Select Field</attribute>
  309 + <attribute name="action">win.select-field</attribute>
  310 + </item>
364 311  
365   - <submenu>
  312 + <item>
  313 + <attribute name="label" translatable="yes">Reselect</attribute>
  314 + <attribute name="action">win.reselect</attribute>
  315 + </item>
366 316  
367   - <attribute name='label' translatable='yes'>Options</attribute>
  317 + </section>
368 318  
369   - <section>
  319 + <section>
370 320  
371 321 <item>
372   - <attribute name="label" translatable="yes">Cross hair cursor</attribute>
373   - <attribute name="action">win.crosshair</attribute>
  322 + <attribute name="label" translatable="yes">Clear</attribute>
  323 + <attribute name="action">win.clear</attribute>
374 324 </item>
375 325  
376 326 <item>
377   - <attribute name="label" translatable="yes">Resize on alternate screen</attribute>
378   - <attribute name="action">win.altscreen</attribute>
  327 + <attribute name="label" translatable="yes">Erase input</attribute>
  328 + <attribute name="action">win.erase_input</attribute>
379 329 </item>
380 330  
381 331 <item>
382   - <attribute name="label" translatable="yes">Alert sound</attribute>
383   - <attribute name="action">win.beep</attribute>
  332 + <attribute name="label" translatable="yes">Delete Field</attribute>
  333 + <attribute name="action">win.delete_field</attribute>
384 334 </item>
385 335  
386   - </section>
387   -
388 336 <item>
389   - <attribute name="label" translatable="yes">Monocase</attribute>
390   - <attribute name="action">win.monocase</attribute>
  337 + <attribute name="label" translatable="yes">Erase to end of field</attribute>
  338 + <attribute name="action">win.erase_eof</attribute>
391 339 </item>
392 340  
393 341 <item>
394   - <attribute name="label" translatable="yes">Dynamic font spacing</attribute>
395   - <attribute name="action">win.dynamic-font-spacing</attribute>
  342 + <attribute name="label" translatable="yes">Erase to end of line</attribute>
  343 + <attribute name="action">win.erase_eol</attribute>
396 344 </item>
  345 +
  346 + </section>
  347 +
  348 + </submenu>
  349 +
  350 + <submenu>
  351 +
  352 + <attribute name='label' translatable='yes'>Options</attribute>
  353 +
  354 + <section>
  355 +
  356 + <item>
  357 + <attribute name="label" translatable="yes">Cross hair cursor</attribute>
  358 + <attribute name="action">win.crosshair</attribute>
  359 + </item>
  360 +
  361 + <item>
  362 + <attribute name="label" translatable="yes">Resize on alternate screen</attribute>
  363 + <attribute name="action">win.altscreen</attribute>
  364 + </item>
  365 +
  366 + <item>
  367 + <attribute name="label" translatable="yes">Alert sound</attribute>
  368 + <attribute name="action">win.beep</attribute>
  369 + </item>
  370 +
  371 + </section>
  372 +
  373 + <item>
  374 + <attribute name="label" translatable="yes">Monocase</attribute>
  375 + <attribute name="action">win.monocase</attribute>
  376 + </item>
  377 +
  378 + <item>
  379 + <attribute name="label" translatable="yes">Dynamic font spacing</attribute>
  380 + <attribute name="action">win.dynamic-font-spacing</attribute>
  381 + </item>
397 382  
398   - <section>
  383 + <section>
399 384  
400   - </section>
  385 + <item>
  386 + <attribute name="label" translatable="yes">Smart paste</attribute>
  387 + <attribute name="action">win.smartpaste</attribute>
  388 + </item>
401 389  
402   - <section>
  390 + <item>
  391 + <attribute name="label" translatable="yes">Paste with left margin</attribute>
  392 + <attribute name="action">win.marginedpaste</attribute>
  393 + </item>
403 394  
404   - <item>
405   - <attribute name="label" translatable="yes">Smart paste</attribute>
406   - <attribute name="action">win.smartpaste</attribute>
407   - </item>
  395 + <item>
  396 + <attribute name="label" translatable="yes">Blank Fill</attribute>
  397 + <attribute name="action">win.blankfill</attribute>
  398 + </item>
408 399  
409   - <item>
410   - <attribute name="label" translatable="yes">Paste with left margin</attribute>
411   - <attribute name="action">win.marginedpaste</attribute>
412   - </item>
  400 + </section>
  401 +
  402 + <section>
413 403  
414 404 <item>
415   - <attribute name="label" translatable="yes">Blank Fill</attribute>
416   - <attribute name="action">win.blankfill</attribute>
  405 + <attribute name="label" translatable="yes">Full screen</attribute>
  406 + <attribute name="action">win.fullscreen</attribute>
417 407 </item>
418 408  
419   - </section>
  409 + </section>
420 410  
421   - <section>
  411 + </submenu>
  412 +
  413 + <submenu id="view-when-online-placeholder">
  414 +
  415 + <attribute name='label' translatable='yes'>View</attribute>
422 416  
423 417 <item>
424   - <attribute name="label" translatable="yes">Show toolbar</attribute>
  418 + <attribute name="label" translatable="yes">Toolbar</attribute>
425 419 <attribute name="action">win.toolbar</attribute>
426 420 </item>
427 421  
428 422 <item>
429   - <attribute name="label" translatable="yes">Show menu</attribute>
  423 + <attribute name="label" translatable="yes">Top menu</attribute>
430 424 <attribute name="action">win.menubar</attribute>
431 425 </item>
432 426  
  427 + </submenu>
  428 +
  429 + <section>
  430 +
433 431 <item>
434   - <attribute name="label" translatable="yes">Full screen</attribute>
435   - <attribute name="action">win.fullscreen</attribute>
  432 + <attribute name="label" translatable="yes">Save screen</attribute>
  433 + <attribute name="action">win.save.screen</attribute>
  434 + </item>
  435 +
  436 + <item>
  437 + <attribute name="label" translatable="yes">Print screen</attribute>
  438 + <attribute name="action">win.print.screen</attribute>
  439 + </item>
  440 +
  441 + <item>
  442 + <attribute name="label" translatable="yes">Send/Receive files</attribute>
  443 + <attribute name="action">win.file.transfer</attribute>
436 444 </item>
437 445  
438 446 </section>
439 447  
440   - </submenu>
  448 + <section>
441 449  
442   - <item>
443   - <attribute name="label" translatable="yes">Disconnect</attribute>
444   - <attribute name="action">win.disconnect</attribute>
445   - </item>
  450 + <item>
  451 + <attribute name="label" translatable="yes">Disconnect</attribute>
  452 + <attribute name="action">win.disconnect</attribute>
  453 + </item>
446 454  
447   - <item>
448   - <attribute name="label" translatable="yes">Close window</attribute>
449   - <attribute name="action">win.close</attribute>
450   - </item>
  455 + <item>
  456 + <attribute name="label" translatable="yes">Close window</attribute>
  457 + <attribute name="action">win.close</attribute>
  458 + </item>
451 459  
  460 + </section>
  461 +
452 462 </menu>
453 463  
454 464 <menu id="popup-over-oia">
... ... @@ -472,73 +482,84 @@
472 482  
473 483 <menu id="popup-when-offline">
474 484  
475   - <item>
476   - <attribute name="label" translatable="yes">_Connect</attribute>
477   - <attribute name="action">win.connect</attribute>
478   - </item>
479   -
480   - <item>
481   - <attribute name="label" translatable="yes">Session properties</attribute>
482   - <attribute name="action">win.session.properties</attribute>
483   - </item>
484   -
485 485 <submenu>
486 486  
487   - <attribute name="label" translatable="yes">Screen size</attribute>
  487 + <attribute name='label' translatable='yes'>Options</attribute>
488 488  
489 489 <item>
490   - <attribute name="label" translatable="yes">Model 2 - 80x24</attribute>
491   - <attribute name="action">win.model-number</attribute>
492   - <attribute name="target">2</attribute>
493   - </item>
494   - <item>
495   - <attribute name="label" translatable="yes">Model 3 - 80x32</attribute>
496   - <attribute name="action">win.model-number</attribute>
497   - <attribute name="target">3</attribute>
498   - </item>
499   - <item>
500   - <attribute name="label" translatable="yes">Model 4 - 80x43</attribute>
501   - <attribute name="action">win.model-number</attribute>
502   - <attribute name="target">4</attribute>
  490 + <attribute name="label" translatable="yes">Dynamic font spacing</attribute>
  491 + <attribute name="action">win.dynamic-font-spacing</attribute>
503 492 </item>
  493 +
504 494 <item>
505   - <attribute name="label" translatable="yes">Model 5 - 132x27</attribute>
506   - <attribute name="action">win.model-number</attribute>
507   - <attribute name="target">5</attribute>
  495 + <attribute name="label" translatable="yes">Full screen</attribute>
  496 + <attribute name="action">win.fullscreen</attribute>
508 497 </item>
509 498  
  499 + <submenu>
  500 +
  501 + <attribute name="label" translatable="yes">Screen size</attribute>
  502 +
  503 + <item>
  504 + <attribute name="label" translatable="yes">Model 2 - 80x24</attribute>
  505 + <attribute name="action">win.model-number</attribute>
  506 + <attribute name="target">2</attribute>
  507 + </item>
  508 + <item>
  509 + <attribute name="label" translatable="yes">Model 3 - 80x32</attribute>
  510 + <attribute name="action">win.model-number</attribute>
  511 + <attribute name="target">3</attribute>
  512 + </item>
  513 + <item>
  514 + <attribute name="label" translatable="yes">Model 4 - 80x43</attribute>
  515 + <attribute name="action">win.model-number</attribute>
  516 + <attribute name="target">4</attribute>
  517 + </item>
  518 + <item>
  519 + <attribute name="label" translatable="yes">Model 5 - 132x27</attribute>
  520 + <attribute name="action">win.model-number</attribute>
  521 + <attribute name="target">5</attribute>
  522 + </item>
  523 +
  524 + </submenu>
  525 +
510 526 </submenu>
511 527  
512   - <submenu>
  528 + <submenu id="view-when-offline-placeholder">
513 529  
514   - <attribute name='label' translatable='yes'>Options</attribute>
  530 + <attribute name='label' translatable='yes'>View</attribute>
515 531  
516 532 <item>
517   - <attribute name="label" translatable="yes">Dynamic font spacing</attribute>
518   - <attribute name="action">win.dynamic-font-spacing</attribute>
  533 + <attribute name="label" translatable="yes">Toolbar</attribute>
  534 + <attribute name="action">win.toolbar</attribute>
519 535 </item>
520 536  
521 537 <item>
522   - <attribute name="label" translatable="yes">Show toolbar</attribute>
523   - <attribute name="action">win.toolbar</attribute>
  538 + <attribute name="label" translatable="yes">Main menu</attribute>
  539 + <attribute name="action">win.menubar</attribute>
524 540 </item>
525 541  
  542 + </submenu>
  543 +
  544 + <section>
  545 +
526 546 <item>
527   - <attribute name="label" translatable="yes">Show menu</attribute>
528   - <attribute name="action">win.menubar</attribute>
  547 + <attribute name="label" translatable="yes">_Connect</attribute>
  548 + <attribute name="action">win.connect</attribute>
529 549 </item>
530 550  
531 551 <item>
532   - <attribute name="label" translatable="yes">Full screen</attribute>
533   - <attribute name="action">win.fullscreen</attribute>
  552 + <attribute name="label" translatable="yes">Session properties</attribute>
  553 + <attribute name="action">win.session.properties</attribute>
534 554 </item>
535 555  
536   - </submenu>
537 556  
538   - <item>
539   - <attribute name="label" translatable="yes">Close window</attribute>
540   - <attribute name="action">win.close</attribute>
541   - </item>
  557 + <item>
  558 + <attribute name="label" translatable="yes">Close window</attribute>
  559 + <attribute name="action">win.close</attribute>
  560 + </item>
  561 +
  562 + </section>
542 563  
543 564 </menu>
544 565  
... ...