Commit f0d77a7a2fd8bd969f24bf219203929f760d2ee5
1 parent
9b7064fe
Exists in
master
and in
1 other branch
Fixing keypad view options.
Showing
5 changed files
with
40 additions
and
14 deletions
Show diff stats
src/main/builder.c
... | ... | @@ -21,7 +21,8 @@ |
21 | 21 | #include <pw3270/application.h> |
22 | 22 | #include <pw3270/keypad.h> |
23 | 23 | |
24 | - static GMenu * get_keypad_menu(GApplication *application) { | |
24 | + /* | |
25 | + static GMenu * keypad_menu_new(GApplication *application) { | |
25 | 26 | |
26 | 27 | GList * keypads = pw3270_application_get_keypad_models(application); |
27 | 28 | |
... | ... | @@ -41,6 +42,7 @@ |
41 | 42 | return menu; |
42 | 43 | |
43 | 44 | } |
45 | + */ | |
44 | 46 | |
45 | 47 | GtkBuilder * pw3270_application_builder_new(GApplication *application) { |
46 | 48 | |
... | ... | @@ -100,11 +102,13 @@ |
100 | 102 | // |
101 | 103 | // View options |
102 | 104 | // |
103 | - GMenu * keypad_menu = get_keypad_menu(application); | |
105 | + GList * keypads = pw3270_application_get_keypad_models(application); | |
104 | 106 | |
105 | - if(keypad_menu) { | |
107 | + if(keypads) { | |
106 | 108 | |
107 | 109 | static const gchar * placeholders[] = { |
110 | + "app-menu-view-placeholder", | |
111 | + "top-menu-view-placeholder", | |
108 | 112 | "view-menu-placeholder", |
109 | 113 | "view-when-offline-placeholder", |
110 | 114 | "view-when-online-placeholder" |
... | ... | @@ -114,13 +118,33 @@ |
114 | 118 | |
115 | 119 | placeholder = gtk_builder_get_object(builder, placeholders[ix]); |
116 | 120 | |
117 | - if(placeholder && G_IS_MENU(placeholder)) { | |
118 | - g_menu_append_item(G_MENU(placeholder), g_menu_item_new_submenu(_("Keypads"),G_MENU_MODEL(keypad_menu))); | |
121 | + if(placeholder) { | |
122 | + | |
123 | + if(G_IS_MENU(placeholder)) { | |
124 | + | |
125 | + GMenu * menu = g_menu_new(); | |
126 | + | |
127 | + // Create keypad items. | |
128 | + GList *item; | |
129 | + for(item = keypads; item; item = g_list_next(item)) { | |
130 | + GObject * model = G_OBJECT(item->data); | |
131 | + g_autofree gchar * action_name = g_strconcat("win.keypad.",pw3270_keypad_model_get_name(model),NULL); | |
132 | + g_menu_append(menu,pw3270_keypad_model_get_label(model),action_name); | |
133 | + } | |
134 | + | |
135 | + g_menu_append_item(G_MENU(placeholder), g_menu_item_new_submenu(_("Keypads"),G_MENU_MODEL(menu))); | |
136 | + | |
137 | + g_object_unref(menu); | |
138 | + | |
139 | + } else { | |
140 | + | |
141 | + g_message("Placeholder '%s' is invalid",placeholders[ix]); | |
142 | + | |
143 | + } | |
119 | 144 | } |
120 | 145 | |
121 | 146 | } |
122 | 147 | |
123 | - g_object_unref(keypad_menu); | |
124 | 148 | } |
125 | 149 | |
126 | 150 | return builder; | ... | ... |
src/objects/application/application.c
... | ... | @@ -482,11 +482,6 @@ void startup(GApplication *application) { |
482 | 482 | } |
483 | 483 | |
484 | 484 | // |
485 | - // Setup application menus | |
486 | - // | |
487 | - g_autoptr(GtkBuilder) builder = pw3270_application_builder_new(application); | |
488 | - | |
489 | - // | |
490 | 485 | // Load keypad models |
491 | 486 | // |
492 | 487 | { |
... | ... | @@ -511,6 +506,13 @@ void startup(GApplication *application) { |
511 | 506 | } |
512 | 507 | } |
513 | 508 | |
509 | + // | |
510 | + // Setup application menus | |
511 | + // | |
512 | + debug("%s","AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); | |
513 | + | |
514 | + g_autoptr(GtkBuilder) builder = pw3270_application_builder_new(application); | |
515 | + | |
514 | 516 | if(gtk_application_prefers_app_menu(GTK_APPLICATION(application))) |
515 | 517 | gtk_application_set_app_menu(GTK_APPLICATION (application), G_MENU_MODEL(gtk_builder_get_object (builder, "app-menu"))); |
516 | 518 | ... | ... |
ui/linux.ui.xml
ui/macos.ui.xml