Commit edfb6f9262d061f53b52c107b96d6c55b2a831f8
1 parent
9a7ea73f
Exists in
master
and in
4 other branches
Implementing build of menus using standard xml files.
Showing
5 changed files
with
72 additions
and
37 deletions
Show diff stats
src/objects/window/application.ui
... | ... | @@ -1,23 +0,0 @@ |
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | -<interface> | |
3 | - <requires lib="gtk+" version="3.0"/> | |
4 | - <menu id="app-menu"> | |
5 | - <section> | |
6 | - <item> | |
7 | - <attribute name="label" translatable="yes">About</attribute> | |
8 | - <attribute name="action">app.about</attribute> | |
9 | - </item> | |
10 | - <item> | |
11 | - <attribute name="label" translatable="yes">Help</attribute> | |
12 | - <attribute name="action">app.help</attribute> | |
13 | - <attribute name="accel">F1</attribute> | |
14 | - </item> | |
15 | - <item> | |
16 | - <attribute name="label" translatable="yes">Quit</attribute> | |
17 | - <attribute name="action">app.quit</attribute> | |
18 | - <attribute name="accel"><Primary>q</attribute> | |
19 | - </item> | |
20 | - </section> | |
21 | - </menu> | |
22 | -</interface> | |
23 | - |
... | ... | @@ -0,0 +1,53 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<interface> | |
3 | + <requires lib="gtk+" version="3.0"/> | |
4 | + <menu id="app-menu"> | |
5 | + <section> | |
6 | + <item> | |
7 | + <attribute name="label" translatable="yes">About PW3270</attribute> | |
8 | + <attribute name="action">app.about</attribute> | |
9 | + </item> | |
10 | + <item> | |
11 | + <attribute name="label" translatable="yes">Preferences</attribute> | |
12 | + <attribute name="action">app.help</attribute> | |
13 | + </item> | |
14 | + <item> | |
15 | + <attribute name="label" translatable="yes">Quit</attribute> | |
16 | + <attribute name="action">app.quit</attribute> | |
17 | + </item> | |
18 | + </section> | |
19 | + </menu> | |
20 | + <menu id='menubar'> | |
21 | + | |
22 | + <submenu> | |
23 | + <attribute name='label' translatable='yes'>_Edit</attribute> | |
24 | + <section> | |
25 | + <item> | |
26 | + <attribute name='label' translatable='yes'>_Copy</attribute> | |
27 | + <attribute name='action'>app.quit</attribute> | |
28 | + </item> | |
29 | + <item> | |
30 | + <attribute name='label' translatable='yes'>_Paste</attribute> | |
31 | + <attribute name='action'>app.quit</attribute> | |
32 | + </item> | |
33 | + </section> | |
34 | + <section> | |
35 | + <item> | |
36 | + <attribute name='label' translatable='yes'>Plugins</attribute> | |
37 | + <attribute name='action'>app.quit</attribute> | |
38 | + </item> | |
39 | + </section> | |
40 | + </submenu> | |
41 | + | |
42 | + <submenu> | |
43 | + <attribute name='label' translatable='yes'>_View</attribute> | |
44 | + <section> | |
45 | + <item> | |
46 | + <attribute name='label' translatable='yes'>_Fullscreen</attribute> | |
47 | + <attribute name='action'>app.quit</attribute> | |
48 | + </item> | |
49 | + </section> | |
50 | + </submenu> | |
51 | + | |
52 | + </menu> | |
53 | +</interface> | ... | ... |
src/objects/window/init.c
... | ... | @@ -50,8 +50,8 @@ |
50 | 50 | gtk_box_pack_start(vBox,GTK_WIDGET(widget->toolbar),FALSE,TRUE,0); |
51 | 51 | gtk_box_pack_start(vBox,GTK_WIDGET(widget->notebook),TRUE,TRUE,0); |
52 | 52 | |
53 | + gtk_widget_show_all(GTK_WIDGET(vBox)); | |
53 | 54 | gtk_container_add(GTK_CONTAINER(widget),GTK_WIDGET(vBox)); |
54 | - gtk_widget_show_all(GTK_WIDGET(widget)); | |
55 | 55 | |
56 | 56 | } |
57 | 57 | ... | ... |
src/objects/window/terminal.c
... | ... | @@ -72,6 +72,9 @@ |
72 | 72 | g_signal_connect(G_OBJECT(terminal), "focus-in-event", G_CALLBACK(on_terminal_focus), widget); |
73 | 73 | g_signal_connect(G_OBJECT(terminal), "session_changed", G_CALLBACK(session_changed),label); |
74 | 74 | |
75 | + gtk_widget_show_all(terminal); | |
76 | + gtk_widget_show_all(label); | |
77 | + | |
75 | 78 | gtk_notebook_append_page(GTK_NOTEBOOK(window->notebook),terminal,label); |
76 | 79 | gtk_notebook_set_show_tabs(GTK_NOTEBOOK(window->notebook),gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->notebook)) > 1); |
77 | 80 | ... | ... |
src/objects/window/testprogram/testprogram.c
... | ... | @@ -41,6 +41,8 @@ |
41 | 41 | |
42 | 42 | GtkWidget * window = pw3270_application_window_new(app); |
43 | 43 | |
44 | + gtk_application_window_set_show_menubar(GTK_APPLICATION_WINDOW(window),TRUE); | |
45 | + | |
44 | 46 | // Create terminal widget |
45 | 47 | pw3270_terminal_new(window); |
46 | 48 | pw3270_terminal_new(window); |
... | ... | @@ -48,7 +50,9 @@ |
48 | 50 | // Setup and show main window |
49 | 51 | gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); |
50 | 52 | gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); |
51 | - gtk_widget_show_all(window); | |
53 | + | |
54 | + // gtk_widget_show_all(window); | |
55 | + gtk_window_present(GTK_WINDOW(window)); | |
52 | 56 | |
53 | 57 | } |
54 | 58 | |
... | ... | @@ -85,7 +89,7 @@ GtkWidget * pw3270_toolbar_new(void) { |
85 | 89 | return toolbar; |
86 | 90 | } |
87 | 91 | |
88 | -static void preferences_activated(GSimpleAction * action, GtkApplication *application) { | |
92 | +static void preferences_activated(GSimpleAction * action, GVariant *parameter, gpointer application) { | |
89 | 93 | |
90 | 94 | debug("%s",__FUNCTION__); |
91 | 95 | |
... | ... | @@ -97,7 +101,7 @@ static void quit_activated(GSimpleAction * action, GVariant *parameter, gpointer |
97 | 101 | |
98 | 102 | } |
99 | 103 | |
100 | -void startup(GtkApplication *application, gpointer user_data) { | |
104 | +void startup(GtkApplication *app) { | |
101 | 105 | |
102 | 106 | static GActionEntry app_entries[] = { |
103 | 107 | { |
... | ... | @@ -131,32 +135,30 @@ void startup(GtkApplication *application, gpointer user_data) { |
131 | 135 | }; |
132 | 136 | |
133 | 137 | g_action_map_add_action_entries( |
134 | - G_ACTION_MAP(application), | |
138 | + G_ACTION_MAP(app), | |
135 | 139 | app_entries, |
136 | 140 | G_N_ELEMENTS(app_entries), |
137 | - application | |
141 | + app | |
138 | 142 | ); |
139 | 143 | |
140 | - GtkBuilder * builder = gtk_builder_new_from_file("application.ui"); | |
144 | + GtkBuilder * builder = gtk_builder_new_from_file("application.xml"); | |
141 | 145 | |
142 | 146 | debug("Builder: %p",builder); |
143 | 147 | |
144 | - GMenuModel * app_menu = G_MENU_MODEL(gtk_builder_get_object(builder, "app-menu")); | |
145 | - debug("app-menu: %p", app_menu); | |
146 | - gtk_application_set_app_menu(application, app_menu); | |
147 | - | |
148 | - | |
149 | - // gtk_application_set_menubar(application, G_MENU_MODEL(gtk_builder_get_object(builder, "app-menubar"))); | |
148 | + gtk_application_set_app_menu(GTK_APPLICATION (app), G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu"))); | |
149 | + gtk_application_set_menubar(GTK_APPLICATION (app), G_MENU_MODEL (gtk_builder_get_object (builder, "menubar"))); | |
150 | 150 | |
151 | 151 | g_object_unref(builder); |
152 | + | |
152 | 153 | } |
153 | 154 | |
155 | + | |
154 | 156 | int main (int argc, char **argv) { |
155 | 157 | |
156 | 158 | GtkApplication *app; |
157 | 159 | int status; |
158 | 160 | |
159 | - app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
161 | + app = gtk_application_new("br.com.bb.pw3270",G_APPLICATION_HANDLES_OPEN); | |
160 | 162 | |
161 | 163 | g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); |
162 | 164 | g_signal_connect (app, "startup", G_CALLBACK(startup), NULL); | ... | ... |