--- goffice-0.8.17.orig/configure.in	2011-06-17 01:46:53.000000000 +0200
+++ goffice-0.8.17/configure.in	2011-10-08 17:45:30.000000000 +0200
@@ -162,6 +162,51 @@
 AM_CONDITIONAL(WITH_NATIVE_WIN32, test $with_native_win32 = yes)
 AM_CONDITIONAL(HAVE_LIBEXE, test x$LIBEXE = xyes)
 
+dnl ================================================================
+dnl check for osx platform
+dnl ================================================================
+os_osx=no
+AC_MSG_CHECKING([for Mac OS X platform])
+case "$host" in
+  rhapsody* | darwin[1567].*)
+    AC_MSG_RESULT([darwin, but too old])
+    AC_MSG_ERROR([This platform is not supported, please update to latest  darwin])
+    ;;
+  *-*-darwin*)
+    platform_osx=yes
+    ;;
+  *)
+    platform_osx=no
+    ;;
+esac
+AC_MSG_RESULT([$platform_osx])
+AM_CONDITIONAL(PLATFORM_OSX, test "$platform_osx" = "yes")
+if test "x$platform_osx" = xyes; then
+  AC_DEFINE([OS_OSX],[1],[Defined if system is Mac OS X])
+  dnl check for native osx
+  gdk_windowing=`$PKG_CONFIG --variable=target gdk-2.0`
+  AC_MSG_CHECKING([for GDK-Quartz])
+
+  if test "x$gdk_windowing" = xquartz; then
+        platform=darwin/quartz
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(GDK_QUARTZ,[1],[Using GDK Quartz (not X11)])
+        PKG_CHECK_MODULES(GTK_MAC, gtk-mac-integration, [os_osx=yes], [os_osx=no])
+        dnl AC_MSG_RESULT(${os_osx})
+        if test "x$os_osx" = xyes; then
+	      AC_DEFINE([GTKOSXAPPLICATION],[1],[Defined if app is GtkOSXApplication])
+	      AC_SUBST(GTK_MAC_LIBS)
+	      AC_SUBST(GTK_MAC_CFLAGS)
+        fi
+  else
+	AC_MSG_RESULT(no)
+    os_osx=no
+  fi
+else
+    os_osx=no
+fi
+
+
 dnl ***********************************
 dnl Which conf backend should be used?
 dnl ***********************************
@@ -218,7 +263,6 @@
 		;;
 esac
 
-
 dnl *******************
 dnl Should we use gtk ?
 dnl *******************
@@ -707,4 +751,5 @@
 
 	UI:			${ui_msg}
 	Configuration backend:	${conf_msg}
+    Build gtk_mac_integration: ${os_osx}
 "
--- goffice-0.8.17.orig/goffice.mk	2009-05-19 03:56:21.000000000 +0200
+++ goffice-0.8.17/goffice.mk	2011-10-08 17:46:12.000000000 +0200
@@ -2,6 +2,7 @@
 	-I$(top_builddir)		\
 	-I$(top_srcdir)			\
 	$(GOFFICE_CFLAGS)		\
+	$(GTK_MAC_CFLAGS)		\
 	-DGOFFICE_COMPILATION
 
 GOFFICE_PLUGIN_FLAGS = $(GOFFICE_PLUGIN_LDFLAGS)
--- goffice-0.8.17.orig/goffice/Makefile.am	2010-05-28 23:27:17.000000000 +0200
+++ goffice-0.8.17/goffice/Makefile.am	2011-10-08 17:45:48.000000000 +0200
@@ -9,7 +9,8 @@
 	graph/libgoffice-graph.la		\
 	math/libgoffice-math.la		\
 	ms-compat/libgoffice-ms-compat.la	\
-	$(GOFFICE_LIBS)
+	$(GOFFICE_LIBS)	\
+	$(GTK_MAC_LIBS)
 
 if WITH_GTK
 SUBDIRS += gtk drawing component canvas
--- goffice-0.8.17.orig/goffice/goffice.c	2010-09-21 02:33:16.000000000 +0200
+++ goffice-0.8.17/goffice/goffice.c	2011-10-08 17:46:48.000000000 +0200
@@ -57,6 +57,10 @@
 #undef STRICT
 #endif
 
+#ifdef GTKOSXAPPLICATION
+#include <gtkosxapplication.h>
+#endif
+
 #ifdef GOFFICE_WITH_LASEM
 #include <goffice/graph/gog-equation.h>
 #endif
@@ -165,6 +169,24 @@
 		"lib", "goffice", GOFFICE_VERSION, NULL);
 	g_free (dir);
 	}
+#else
+#ifdef GTKOSXAPPLICATION
+    if ( quartz_application_get_bundle_id ( ) )
+    {
+        gchar *dir;
+
+        dir = quartz_application_get_resource_path ();
+	libgoffice_data_dir = g_build_filename (dir,
+		"share", "goffice", GOFFICE_VERSION, NULL);
+	libgoffice_icon_dir = g_build_filename (dir,
+		"share", "pixmaps", "goffice", GOFFICE_VERSION, NULL);
+	libgoffice_locale_dir = g_build_filename (dir,
+		"share", "locale", NULL);
+	libgoffice_lib_dir = g_build_filename (dir,
+		"lib", "goffice", GOFFICE_VERSION, NULL);
+	g_free (dir);       
+    }
+#endif /* GTKOSXAPPLICATION */
 #endif
 
 	bindtextdomain (GETTEXT_PACKAGE, libgoffice_locale_dir);
