PageRenderTime 62ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/Library/Formula/spatialite-gui.rb

https://github.com/asymmetric/homebrew
Ruby | 96 lines | 75 code | 15 blank | 6 comment | 2 complexity | dd3120e0faa7634dad657dce8fa5e75b MD5 | raw file
  1. require 'formula'
  2. class SpatialiteGui < Formula
  3. homepage 'https://www.gaia-gis.it/fossil/spatialite_gui/index'
  4. url 'http://www.gaia-gis.it/gaia-sins/spatialite-gui-sources/spatialite_gui-1.5.0-stable.tar.gz'
  5. sha1 'b8cfe3def8c77928f7c9fcc86bae3c99179fa486'
  6. devel do
  7. url 'http://www.gaia-gis.it/gaia-sins/spatialite-gui-sources/spatialite_gui-1.6.0.tar.gz'
  8. sha1 'd06944273b1e19cdd5c17a463582e074f8548ccd'
  9. end
  10. depends_on 'libspatialite'
  11. depends_on 'libgaiagraphics'
  12. depends_on 'wxmac'
  13. def patches
  14. patch_set = {
  15. :p1 => DATA
  16. }
  17. # Compatibility fix for wxWidgets 2.9.x. Remove on next release.
  18. patch_set[:p0] = 'https://www.gaia-gis.it/fossil/spatialite_gui/vpatch?from=d8416d26358a24dc&to=b5b920d8d654dd0e' unless build.devel?
  19. patch_set
  20. end
  21. def install
  22. # This lib doesn't get picked up by configure.
  23. ENV.append 'LDFLAGS', '-lwx_osx_cocoau_aui-2.9'
  24. # 1.6.0 doesn't pick up GEOS libraries. See:
  25. # https://www.gaia-gis.it/fossil/spatialite_gui/tktview?name=d27778d7e4
  26. ENV.append 'LDFLAGS', '-lgeos_c' if build.devel?
  27. system "./configure", "--disable-debug",
  28. "--prefix=#{prefix}"
  29. system "make install"
  30. end
  31. end
  32. __END__
  33. For some strange reason, wxWidgets does not take the required steps to register
  34. programs as GUI apps like other toolkits do. This necessitates the creation of
  35. an app bundle on OS X.
  36. This clever hack sidesteps the headache of packing simple programs into app
  37. bundles:
  38. http://www.miscdebris.net/blog/2010/03/30/
  39. solution-for-my-mac-os-x-gui-program-doesnt-get-focus-if-its-outside-an-application-bundle
  40. ---
  41. Main.cpp | 21 +++++++++++++++++++++
  42. 1 files changed, 21 insertions(+), 0 deletions(-)
  43. diff --git a/Main.cpp b/Main.cpp
  44. index a857e8a..9c90afb 100644
  45. --- a/Main.cpp
  46. +++ b/Main.cpp
  47. @@ -71,6 +71,12 @@
  48. #define unlink _unlink
  49. #endif
  50. +#ifdef __WXMAC__
  51. +// Allow the program to run and recieve focus without creating an app bundle.
  52. +#include <Carbon/Carbon.h>
  53. +extern "C" { void CPSEnableForegroundOperation(ProcessSerialNumber* psn); }
  54. +#endif
  55. +
  56. IMPLEMENT_APP(MyApp)
  57. bool MyApp::OnInit()
  58. {
  59. @@ -86,6 +92,21 @@ IMPLEMENT_APP(MyApp)
  60. frame->Show(true);
  61. SetTopWindow(frame);
  62. frame->LoadConfig(path);
  63. +
  64. +#ifdef __WXMAC__
  65. + // Acquire the necessary resources to run as a GUI app without being inside
  66. + // an app bundle.
  67. + //
  68. + // Credit for this hack goes to:
  69. + //
  70. + // http://www.miscdebris.net/blog/2010/03/30/solution-for-my-mac-os-x-gui-program-doesnt-get-focus-if-its-outside-an-application-bundle
  71. + ProcessSerialNumber psn;
  72. +
  73. + GetCurrentProcess( &psn );
  74. + CPSEnableForegroundOperation( &psn );
  75. + SetFrontProcess( &psn );
  76. +#endif
  77. +
  78. return true;
  79. }
  80. --
  81. 1.7.9