homebrew-core/Formula/spatialite-gui.rb
2018-08-27 07:59:18 +02:00

98 lines
3.1 KiB
Ruby

class SpatialiteGui < Formula
desc "GUI tool supporting SpatiaLite"
homepage "https://www.gaia-gis.it/fossil/spatialite_gui/index"
url "https://www.gaia-gis.it/gaia-sins/spatialite-gui-sources/spatialite_gui-1.7.1.tar.gz"
sha256 "cb9cb1ede7f83a5fc5f52c83437e556ab9cb54d6ace3c545d31b317fd36f05e4"
revision 4
bottle do
cellar :any
rebuild 1
sha256 "877a0b1d4981a2b13031769a812f25549f824817978c6d30b57b2ddecd734f14" => :mojave
sha256 "329a43210fc2f99c3d2c8090bb304bff81e5fc2450778f15f052b32100230151" => :high_sierra
sha256 "1ab0a3f3a0ce183dac239210c4bf2f632cdfe827a59a86f34bf3229bf2df93e4" => :sierra
sha256 "e04f2392b64ad916bb50e62d2267b075eab00ca44f7b8001f7a9f5e30c447e3e" => :el_capitan
end
depends_on "pkg-config" => :build
depends_on "freexl"
depends_on "geos"
depends_on "libgaiagraphics"
depends_on "libspatialite"
depends_on "proj"
depends_on "sqlite"
depends_on "wxmac"
patch :DATA
def install
# Link flags for sqlite don't seem to get passed to make, which
# causes builds to fatally error out on linking.
# https://github.com/Homebrew/homebrew/issues/44003
sqlite = Formula["sqlite"]
ENV.prepend "LDFLAGS", "-L#{sqlite.opt_lib} -lsqlite3"
ENV.prepend "CFLAGS", "-I#{sqlite.opt_include}"
# Add aui library; reported upstream multiple times:
# https://groups.google.com/forum/#!searchin/spatialite-users/aui/spatialite-users/wnkjK9pde2E/hVCpcndUP_wJ
inreplace "configure", "WX_LIBS=\"$(wx-config --libs)\"", "WX_LIBS=\"$(wx-config --libs std,aui)\""
system "./configure", "--prefix=#{prefix}"
system "make", "install"
end
end
__END__
For some strange reason, wxWidgets does not take the required steps to register
programs as GUI apps like other toolkits do. This necessitates the creation of
an app bundle on OS X.
This clever hack sidesteps the headache of packing simple programs into app
bundles:
https://www.miscdebris.net/blog/2010/03/30/
solution-for-my-mac-os-x-gui-program-doesnt-get-focus-if-its-outside-an-application-bundle
---
Main.cpp | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/Main.cpp b/Main.cpp
index a857e8a..9c90afb 100644
--- a/Main.cpp
+++ b/Main.cpp
@@ -71,6 +71,12 @@
#define unlink _unlink
#endif
+#ifdef __WXMAC__
+// Allow the program to run and recieve focus without creating an app bundle.
+#include <Carbon/Carbon.h>
+extern "C" { void CPSEnableForegroundOperation(ProcessSerialNumber* psn); }
+#endif
+
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
@@ -86,6 +92,21 @@ IMPLEMENT_APP(MyApp)
frame->Show(true);
SetTopWindow(frame);
frame->LoadConfig(path);
+
+#ifdef __WXMAC__
+ // Acquire the necessary resources to run as a GUI app without being inside
+ // an app bundle.
+ //
+ // Credit for this hack goes to:
+ //
+ // https://www.miscdebris.net/blog/2010/03/30/solution-for-my-mac-os-x-gui-program-doesnt-get-focus-if-its-outside-an-application-bundle
+ ProcessSerialNumber psn;
+
+ GetCurrentProcess( &psn );
+ CPSEnableForegroundOperation( &psn );
+ SetFrontProcess( &psn );
+#endif
+
return true;
}
--
1.7.9