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
| @@ -63,6 +63,7 @@ struct _Pw3270SettingsPage { | @@ -63,6 +63,7 @@ struct _Pw3270SettingsPage { | ||
| 63 | }; | 63 | }; |
| 64 | 64 | ||
| 65 | void gtk_file_chooser_set_pw3270_filters(GtkFileChooser *chooser); | 65 | void gtk_file_chooser_set_pw3270_filters(GtkFileChooser *chooser); |
| 66 | +gchar * pw3270_build_data_filename(const char *filename); | ||
| 66 | 67 | ||
| 67 | G_END_DECLS | 68 | G_END_DECLS |
| 68 | 69 |
src/main/builder.c
| @@ -20,12 +20,37 @@ | @@ -20,12 +20,37 @@ | ||
| 20 | #include "private.h" | 20 | #include "private.h" |
| 21 | #include <pw3270/application.h> | 21 | #include <pw3270/application.h> |
| 22 | #include <pw3270/keypad.h> | 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 | GtkBuilder * pw3270_application_builder_new(GApplication *application) { | 45 | GtkBuilder * pw3270_application_builder_new(GApplication *application) { |
| 25 | 46 | ||
| 26 | #if !defined(DEBUG) | 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 | #elif defined(G_OS_UNIX) | 55 | #elif defined(G_OS_UNIX) |
| 31 | 56 |