Advertisement
dominus

Untitled

Dec 11th, 2023
912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.08 KB | None | 0 0
  1. diff --git a/files/utils.cc b/files/utils.cc
  2. index 784093eae..1df878900 100644
  3. --- a/files/utils.cc
  4. +++ b/files/utils.cc
  5. @@ -872,7 +872,10 @@ void setup_program_paths() {
  6.     U7mkdir("<HOME>", 0755);
  7.     U7mkdir("<CONFIG>", 0755);
  8.     U7mkdir("<SAVEHOME>", 0755);
  9. +}
  10. +
  11.  #ifdef MACOSX
  12. +void setup_appbundle() {
  13.     // setup APPBUNDLE needed to launch Exult Studio from one
  14.     std::unique_ptr<std::remove_pointer<CFURLRef>::type, CFDeleter> fileUrl {std::move(CFBundleCopyBundleURL(CFBundleGetMainBundle()))};
  15.     if (fileUrl) {
  16. @@ -886,8 +889,8 @@ void setup_program_paths() {
  17.                 clear_system_path("<APPBUNDLE>");
  18.         }
  19.     }
  20. -#endif
  21.  }
  22. +#endif
  23.  
  24.  /*
  25.   *  Change the current directory
  26. diff --git a/files/utils.h b/files/utils.h
  27. index 98a40aeb0..9ed6a96da 100644
  28. --- a/files/utils.h
  29. +++ b/files/utils.h
  30. @@ -455,6 +455,9 @@ void cleanup_output(const char *prefix = "std");
  31.  #endif
  32.  void setup_data_dir(const std::string &data_path, const char *runpath);
  33.  void setup_program_paths();
  34. +#ifdef MACOSX
  35. +void setup_appbundle();
  36. +#endif
  37.  
  38.  int U7chdir(
  39.      const char *dirname
  40. diff --git a/mapedit/exult_studio.cc b/mapedit/exult_studio.cc
  41. index 59817d22b..4fc64a842 100644
  42. --- a/mapedit/exult_studio.cc
  43. +++ b/mapedit/exult_studio.cc
  44. @@ -22,11 +22,44 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  45.  
  46.  #include "studio.h"
  47.  
  48. -#ifdef _WIN32
  49. +#if defined(MACOSX) || defined(_WIN32)
  50.  #include "utils.h"
  51.  #endif
  52.  
  53.  int main(int argc, char **argv) {
  54. +
  55. +#ifdef MACOSX
  56. +   // setting up environment for Exult Studio in an app bundle
  57. +   setup_appbundle();
  58. +   if (is_system_path_defined("<APPBUNDLE>")) {
  59. +       std::string app_path = get_system_path("<APPBUNDLE>");
  60. +       if (U7exists(app_path)) {
  61. +           std::string bundle_res;
  62. +           std::string bundle_data;
  63. +           std::string bundle_pixbuf;
  64. +           std::string bundle_im;
  65. +           bundle_res = app_path;
  66. +           bundle_res += "/Contents/Resources";
  67. +           bundle_data = bundle_res;
  68. +           bundle_data += "/share";
  69. +           bundle_pixbuf = bundle_res;
  70. +           bundle_pixbuf += "/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache";
  71. +           bundle_im = bundle_res;
  72. +           bundle_im += "/lib/gtk-3.0/3.0.0/immodules.cache";
  73. +           const gchar *b_res = bundle_res.c_str();
  74. +           const gchar *b_data = bundle_data.c_str();
  75. +           const gchar *b_pixbuf= bundle_pixbuf.c_str();
  76. +           const gchar *b_im = bundle_im.c_str();
  77. +           g_setenv("XDG_DATA_DIRS", b_data, 1);
  78. +           g_setenv("GTK_DATA_PREFIX", b_res, 1);
  79. +           g_setenv("GTK_EXE_PREFIX", b_res, 1);
  80. +           g_setenv("GTK_PATH", b_res, 1);
  81. +           g_setenv("GDK_PIXBUF_MODULE_FILE", b_pixbuf, 1);
  82. +           g_setenv("GTK_IM_MODULE_FILE", b_im, 1);
  83. +       }
  84. +   }
  85. +#endif
  86. +
  87.     ExultStudio studio(argc, argv);
  88.     studio.run();
  89.  
  90. diff --git a/mapedit/studio.cc b/mapedit/studio.cc
  91. index 8eca18729..b7f065dd7 100644
  92. --- a/mapedit/studio.cc
  93. +++ b/mapedit/studio.cc
  94. @@ -740,6 +740,7 @@ ExultStudio::ExultStudio(int argc, char **argv): glade_path(nullptr),
  95.     // Setup virtual directories
  96.     string data_path;
  97.  #ifdef MACOSX
  98. +   setup_appbundle();
  99.     string app_path;
  100.     if (is_system_path_defined("<APPBUNDLE>")) {
  101.         app_path = get_system_path("<APPBUNDLE>");
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement