Commit 4fc113f7e687c1433f8155bff74d7835877d29eb
1 parent
14bc5874
Exists in
master
and in
4 other branches
Loading keypad models on application startup.
Showing
2 changed files
with
49 additions
and
3 deletions
Show diff stats
pw3270.cbp
@@ -46,6 +46,7 @@ | @@ -46,6 +46,7 @@ | ||
46 | <Unit filename="src/include/pw3270.h" /> | 46 | <Unit filename="src/include/pw3270.h" /> |
47 | <Unit filename="src/include/pw3270/actions.h" /> | 47 | <Unit filename="src/include/pw3270/actions.h" /> |
48 | <Unit filename="src/include/pw3270/application.h" /> | 48 | <Unit filename="src/include/pw3270/application.h" /> |
49 | + <Unit filename="src/include/pw3270/keypad.h" /> | ||
49 | <Unit filename="src/include/pw3270/settings.h" /> | 50 | <Unit filename="src/include/pw3270/settings.h" /> |
50 | <Unit filename="src/include/pw3270/toolbar.h" /> | 51 | <Unit filename="src/include/pw3270/toolbar.h" /> |
51 | <Unit filename="src/include/pw3270/window.h" /> | 52 | <Unit filename="src/include/pw3270/window.h" /> |
@@ -109,6 +110,22 @@ | @@ -109,6 +110,22 @@ | ||
109 | <Option compilerVar="CC" /> | 110 | <Option compilerVar="CC" /> |
110 | </Unit> | 111 | </Unit> |
111 | <Unit filename="src/objects/application/private.h" /> | 112 | <Unit filename="src/objects/application/private.h" /> |
113 | + <Unit filename="src/objects/keypad/attribute.c"> | ||
114 | + <Option compilerVar="CC" /> | ||
115 | + </Unit> | ||
116 | + <Unit filename="src/objects/keypad/element.c"> | ||
117 | + <Option compilerVar="CC" /> | ||
118 | + </Unit> | ||
119 | + <Unit filename="src/objects/keypad/keypad.c"> | ||
120 | + <Option compilerVar="CC" /> | ||
121 | + </Unit> | ||
122 | + <Unit filename="src/objects/keypad/load.c"> | ||
123 | + <Option compilerVar="CC" /> | ||
124 | + </Unit> | ||
125 | + <Unit filename="src/objects/keypad/private.h" /> | ||
126 | + <Unit filename="src/objects/keypad/widget.c"> | ||
127 | + <Option compilerVar="CC" /> | ||
128 | + </Unit> | ||
112 | <Unit filename="src/objects/linux/savedesktopicon.c"> | 129 | <Unit filename="src/objects/linux/savedesktopicon.c"> |
113 | <Option compilerVar="CC" /> | 130 | <Option compilerVar="CC" /> |
114 | </Unit> | 131 | </Unit> |
@@ -168,9 +185,6 @@ | @@ -168,9 +185,6 @@ | ||
168 | <Unit filename="ui/application.xml" /> | 185 | <Unit filename="ui/application.xml" /> |
169 | <Unit filename="ui/window.xml" /> | 186 | <Unit filename="ui/window.xml" /> |
170 | <Extensions> | 187 | <Extensions> |
171 | - <code_completion /> | ||
172 | - <debugger /> | ||
173 | - <envvars set="default" /> | ||
174 | <DoxyBlocks> | 188 | <DoxyBlocks> |
175 | <comment_style block="0" line="0" /> | 189 | <comment_style block="0" line="0" /> |
176 | <doxyfile_project /> | 190 | <doxyfile_project /> |
@@ -180,6 +194,7 @@ | @@ -180,6 +194,7 @@ | ||
180 | <doxyfile_dot /> | 194 | <doxyfile_dot /> |
181 | <general /> | 195 | <general /> |
182 | </DoxyBlocks> | 196 | </DoxyBlocks> |
197 | + <envvars set="default" /> | ||
183 | </Extensions> | 198 | </Extensions> |
184 | </Project> | 199 | </Project> |
185 | </CodeBlocks_project_file> | 200 | </CodeBlocks_project_file> |
src/objects/application/application.c
@@ -35,6 +35,7 @@ | @@ -35,6 +35,7 @@ | ||
35 | #include <pw3270.h> | 35 | #include <pw3270.h> |
36 | #include <pw3270/application.h> | 36 | #include <pw3270/application.h> |
37 | #include <pw3270/actions.h> | 37 | #include <pw3270/actions.h> |
38 | + #include <pw3270/keypad.h> | ||
38 | #include <stdlib.h> | 39 | #include <stdlib.h> |
39 | 40 | ||
40 | enum { | 41 | enum { |
@@ -54,6 +55,7 @@ | @@ -54,6 +55,7 @@ | ||
54 | GtkApplication parent; | 55 | GtkApplication parent; |
55 | 56 | ||
56 | GSettings * settings; | 57 | GSettings * settings; |
58 | + GList * keypads; | ||
57 | 59 | ||
58 | GSList * plugins; ///< @brief Handlers of the loaded plugins. | 60 | GSList * plugins; ///< @brief Handlers of the loaded plugins. |
59 | 61 | ||
@@ -331,6 +333,7 @@ | @@ -331,6 +333,7 @@ | ||
331 | application->settings = NULL; | 333 | application->settings = NULL; |
332 | } | 334 | } |
333 | 335 | ||
336 | + g_list_free_full(application->keypads,g_object_unref); | ||
334 | 337 | ||
335 | G_OBJECT_CLASS(pw3270Application_parent_class)->finalize(object); | 338 | G_OBJECT_CLASS(pw3270Application_parent_class)->finalize(object); |
336 | 339 | ||
@@ -350,6 +353,8 @@ | @@ -350,6 +353,8 @@ | ||
350 | 353 | ||
351 | size_t ix; | 354 | size_t ix; |
352 | 355 | ||
356 | + pw3270Application * app = PW3270_APPLICATION(application); | ||
357 | + | ||
353 | G_APPLICATION_CLASS(pw3270Application_parent_class)->startup(application); | 358 | G_APPLICATION_CLASS(pw3270Application_parent_class)->startup(application); |
354 | 359 | ||
355 | GAction * actions[] = { | 360 | GAction * actions[] = { |
@@ -379,6 +384,32 @@ | @@ -379,6 +384,32 @@ | ||
379 | } | 384 | } |
380 | #endif // DEBUG | 385 | #endif // DEBUG |
381 | 386 | ||
387 | + | ||
388 | + // | ||
389 | + // Load keypad models | ||
390 | + // | ||
391 | + { | ||
392 | +#ifdef DEBUG | ||
393 | + const gchar * keypad_path = "keypad"; | ||
394 | +#else | ||
395 | + lib3270_autoptr(char) keypad_path = lib3270_build_data_filename("keypad",NULL); | ||
396 | +#endif // DEBUG | ||
397 | + | ||
398 | + g_autoptr(GError) error = NULL; | ||
399 | + g_autoptr(GDir) dir = g_dir_open(keypad_path,0,&error); | ||
400 | + | ||
401 | + const gchar *name = g_dir_read_name(dir); | ||
402 | + while(!error && name) { | ||
403 | + g_autofree gchar * path = g_build_filename(keypad_path,name,NULL); | ||
404 | + app->keypads = pw3270_keypad_model_new_from_xml(app->keypads,path); | ||
405 | + name = g_dir_read_name(dir); | ||
406 | + } | ||
407 | + | ||
408 | + if(error) { | ||
409 | + g_message("Can't read %s: %s",keypad_path,error->message); | ||
410 | + } | ||
411 | + } | ||
412 | + | ||
382 | if(gtk_application_prefers_app_menu(GTK_APPLICATION(application))) | 413 | if(gtk_application_prefers_app_menu(GTK_APPLICATION(application))) |
383 | gtk_application_set_app_menu(GTK_APPLICATION (application), G_MENU_MODEL(gtk_builder_get_object (builder, "app-menu"))); | 414 | gtk_application_set_app_menu(GTK_APPLICATION (application), G_MENU_MODEL(gtk_builder_get_object (builder, "app-menu"))); |
384 | 415 |