Commit a108255a4f8cb352f40a2aefaac3e21b802ac28d
1 parent
e9ce3fc4
Exists in
develop
Searching standard path for data files.
Showing
2 changed files
with
27 additions
and
1 deletions
Show diff stats
src/include/pw3270.h
src/main/builder.c
| ... | ... | @@ -20,12 +20,37 @@ |
| 20 | 20 | #include "private.h" |
| 21 | 21 | #include <pw3270/application.h> |
| 22 | 22 | #include <pw3270/keypad.h> |
| 23 | + #include <pw3270.h> | |
| 24 | + | |
| 25 | + gchar * pw3270_build_data_filename(const char *filename) { | |
| 26 | + | |
| 27 | + g_autofree gchar * pkgdir = g_win32_get_package_installation_directory_of_module(NULL); | |
| 28 | + | |
| 29 | + gchar * path = g_build_filename(pkgdir,filename,NULL); | |
| 30 | + if(g_file_test(path,G_FILE_TEST_IS_REGULAR)) { | |
| 31 | + return path; | |
| 32 | + } | |
| 33 | + g_free(path); | |
| 34 | + | |
| 35 | + path = g_build_filename(pkgdir,"share",G_STRINGIFY(PRODUCT_NAME),filename,NULL); | |
| 36 | + if(g_file_test(path,G_FILE_TEST_IS_REGULAR)) { | |
| 37 | + return path; | |
| 38 | + } | |
| 39 | + g_free(path); | |
| 40 | + | |
| 41 | + g_error("Cant find '%s'",filename); | |
| 42 | + return NULL; | |
| 43 | + } | |
| 23 | 44 | |
| 24 | 45 | GtkBuilder * pw3270_application_builder_new(GApplication *application) { |
| 25 | 46 | |
| 26 | 47 | #if !defined(DEBUG) |
| 27 | 48 | |
| 28 | - lib3270_autoptr(char) filename = lib3270_build_data_filename(G_STRINGIFY(PRODUCT_NAME) ".ui.xml",NULL); | |
| 49 | + #if defined(G_OS_WIN32) | |
| 50 | + g_autofree gchar * filename = pw3270_build_data_filename(G_STRINGIFY(PRODUCT_NAME) ".ui.xml"); | |
| 51 | + #else | |
| 52 | + lib3270_autoptr(char) filename = lib3270_build_data_filename(G_STRINGIFY(PRODUCT_NAME) ".ui.xml",NULL); | |
| 53 | + #endif // G_OS_WIN32 | |
| 29 | 54 | |
| 30 | 55 | #elif defined(G_OS_UNIX) |
| 31 | 56 | ... | ... |