[gedit/gnome-3-2-osx: 1/6] Update OS X support for gnome 3



commit c79dd87ba358ec327623fe389dc91d99507b1572
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sat Apr 2 14:36:43 2011 +0200

    Update OS X support for gnome 3

 configure.ac                                       |    8 +-
 data/Makefile.am                                   |   14 +-
 data/gedit-osx.gschema.override                    |    5 +
 data/osx.accels                                    |   44 ++
 data/osx.css                                       |  132 ++++++
 gedit/Makefile.am                                  |   14 +-
 gedit/gedit-app-osx.c                              |  305 ++++++++++++-
 gedit/gedit-app-osx.h                              |    9 +-
 gedit/gedit-app.c                                  |  477 +++++++++++---------
 gedit/gedit-app.h                                  |   15 +-
 gedit/gedit-dirs.c                                 |   17 +-
 gedit/gedit-osx-delegate.h                         |   39 --
 gedit/gedit-osx-delegate.m                         |  105 -----
 gedit/gedit-window-private.h                       |    6 +-
 gedit/gedit-window.c                               |  121 +----
 osx/README                                         |   71 +++
 osx/gedit.bundle                                   |  110 +++--
 osx/gedit.icns                                     |  Bin 175597 -> 115452 bytes
 osx/gtkrc                                          |  429 ------------------
 osx/gtkrc.key.osx                                  |   55 ---
 osx/jhbuild/gedit.modules                          |  320 +++++++++++++
 osx/jhbuild/jhbuildrc-gedit                        |   37 ++
 osx/jhbuild/patches/dconf-dylib.patch              |  126 +++++
 osx/jhbuild/patches/dconf-echo-escape.patch        |   12 +
 osx/jhbuild/patches/enchant-applespell.patch       |  368 +++++++++++++++
 osx/jhbuild/patches/ffi-darwin11.patch             |   11 +
 .../patches/gobject-introspection-casecmp.patch    |   11 +
 osx/jhbuild/patches/gtk-dnd-offscreen.patch        |   11 +
 osx/jhbuild/patches/gtk-introspection.patch        |   14 +
 osx/jhbuild/patches/gtk-settings-ini-xdg.patch     |   39 ++
 osx/jhbuild/patches/libpeas-disable-valademo.patch |   23 +
 osx/jhbuild/patches/libpeas-pygobject-api.patch    |   25 +
 .../patches/mac-integration-open-files.patch       |  184 ++++++++
 osx/jhbuild/patches/pango-coretext-invisible.patch |   32 ++
 osx/launcher.sh                                    |   56 ++-
 osx/logo.svgz                                      |  Bin 0 -> 40707 bytes
 osx/makebundle.sh                                  |   27 +-
 osx/settings.ini                                   |   10 +
 osx/template.dmg                                   |  Bin 19345408 -> 19345408 bytes
 plugins/checkupdate/gedit-check-update-plugin.c    |    5 +-
 plugins/externaltools/tools/capture.py             |   32 +-
 plugins/quickopen/quickopen/__init__.py            |    2 +-
 plugins/snippets/snippets/library.py               |   27 +-
 plugins/spell/Makefile.am                          |   18 +-
 plugins/spell/gedit-spell-checker-language.c       |   23 +-
 plugins/spell/gedit-spell-checker.c                |   20 +
 plugins/spell/gedit-spell-osx.c                    |   27 ++
 plugins/spell/gedit-spell-osx.h                    |   14 +
 48 files changed, 2364 insertions(+), 1086 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 52a9087..58e9df0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,10 +134,10 @@ AC_SUBST(DEFAULT_PRINT_FONT)
 if test "$os_osx" = "yes"; then
 	AC_DEFINE([OS_OSX],[1],[Defined if os is Mac OSX])
 
-	PKG_CHECK_MODULES(IGE_MAC, ige-mac-integration)
+	PKG_CHECK_MODULES(GTK_MAC, gtk-mac-integration)
 
-	AC_SUBST(IGE_MAC_CFLAGS)
-	AC_SUBST(IGE_MAC_LIBS)
+	AC_SUBST(GTK_MAC_CFLAGS)
+	AC_SUBST(GTK_MAC_LIBS)
 fi
 
 dnl ===============================================================
@@ -174,7 +174,7 @@ dnl ================================================================
 dnl Use gvfs metadata or the old xml file store.
 dnl ================================================================
 
-if test "x$os_osx" != "xno" || test "x$os_win32" != "xno"; then
+if test "x$os_win32" != "xno"; then
 	gvfs_metadata_default="no"
 else
 	gvfs_metadata_default="yes"
diff --git a/data/Makefile.am b/data/Makefile.am
index 4d388a3..4ab6674 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -26,16 +26,28 @@ gsettings_SCHEMAS = org.gnome.gedit.gschema.xml
 
 @GSETTINGS_RULES@
 
+if OS_OSX
+gsettingsschema_DATA = gedit-osx.gschema.override
+endif
+
 convertdir = $(datadir)/GConf/gsettings
 convert_DATA = gedit.convert
 
+if OS_OSX
+geditdatadir = $(datadir)/gedit
+geditdata_DATA = osx.accels osx.css
+endif
+
 EXTRA_DIST = 					\
 	$(desktop_in_files)			\
 	$(service_in_files)			\
 	$(man_MANS)				\
 	gedit.pc.in				\
 	org.gnome.gedit.gschema.xml.in.in	\
-	gedit.convert
+	gedit.convert				\
+	osx.accels				\
+	osx.css					\
+	gedit-osx.gschema.override
 
 CLEANFILES =	 			\
 	$(desktop_DATA)			\
diff --git a/data/gedit-osx.gschema.override b/data/gedit-osx.gschema.override
new file mode 100644
index 0000000..e302e08
--- /dev/null
+++ b/data/gedit-osx.gschema.override
@@ -0,0 +1,5 @@
+[org.gnome.desktop.interface]
+monospace-font-name = 'Monaco 12'
+
+[org.gnome.gedit.preferences.editor]
+editor-font = 'Monaco 12'
\ No newline at end of file
diff --git a/data/osx.accels b/data/osx.accels
new file mode 100644
index 0000000..52825df
--- /dev/null
+++ b/data/osx.accels
@@ -0,0 +1,44 @@
+(gtk_accel_path "<Actions>/GeditWindowActions/EditCut" "<primary>x")
+(gtk_accel_path "<Actions>/GeditWindowActions/DocumentsNextDocument" "<primary><alt>page_down")
+(gtk_accel_path "<Actions>/GeditBookmarksPluginActions/ToggleBookmark" "<primary><alt>b")
+(gtk_accel_path "<Actions>/GeditWindowActions/SearchFindPrevious" "<shift><primary>g")
+(gtk_accel_path "<Actions>/GeditWindowPanelsActions/ViewSidePanel" "F9")
+(gtk_accel_path "<Actions>/GeditWindowActions/DocumentsPreviousTabGroup" "<shift><primary><alt>page_up")
+(gtk_accel_path "<Actions>/GeditWindowActions/FilePrint" "<primary>p")
+(gtk_accel_path "<Actions>/GeditCommanderPluginActions/CommanderModeAction" "<primary>period")
+(gtk_accel_path "<Actions>/GeditWindowAlwaysSensitiveActions/HelpContents" "f1")
+(gtk_accel_path "<Actions>/GeditBookmarksPluginActions/NextBookmark" "<primary>b")
+(gtk_accel_path "<Actions>/GeditWindowActions/EditRedo" "<shift><primary>z")
+(gtk_accel_path "<Actions>/GeditTextSizePluginActions/IncreaseFontSizeAction" "<primary>plus")
+(gtk_accel_path "<Actions>/FileBrowserWidgetBookmarkActionGroup/BookmarkOpen" "<primary>o")
+(gtk_accel_path "<Actions>/GeditSpellPluginActions/CheckSpell" "<shift>f7")
+(gtk_accel_path "<Actions>/GeditTextSizePluginActions/ResetFontSizeAction" "<primary>0")
+(gtk_accel_path "<Actions>/GeditWindowActions/FileCloseAll" "<shift><primary>w")
+(gtk_accel_path "<Actions>/GeditWindowActions/SearchFind" "<primary>f")
+(gtk_accel_path "<Actions>/GeditWindowActions/FileSave" "<primary>s")
+(gtk_accel_path "<Actions>/GeditQuitWindowActions/FileQuit" "<primary>q")
+(gtk_accel_path "<Actions>/GeditWindowAlwaysSensitiveActions/FileOpen" "<primary>o")
+(gtk_accel_path "<Actions>/GeditWindowActions/SearchGoToLine" "<primary>i")
+(gtk_accel_path "<Actions>/GeditWindowActions/SearchReplace" "<primary><alt>f")
+(gtk_accel_path "<Actions>/GeditBookmarksPluginActions/PreviousBookmark" "<shift><primary>b")
+(gtk_accel_path "<Actions>/GeditWindowActions/FileSaveAs" "<shift><primary>s")
+(gtk_accel_path "<Actions>/GeditWindowActions/SearchClearHighlight" "<shift><primary>k")
+(gtk_accel_path "<Actions>/GeditWindowActions/FilePrintPreview" "<shift><primary>p")
+(gtk_accel_path "<Actions>/GeditWindowActions/EditUndo" "<primary>z")
+(gtk_accel_path "<Actions>/GeditTextSizePluginActions/DecreaseFontSizeAction" "<primary>minus")
+(gtk_accel_path "<Actions>/GeditCloseWindowActions/FileClose" "<primary>w")
+(gtk_accel_path "<Actions>/GeditWindowActions/EditPaste" "<primary>v")
+(gtk_accel_path "<Actions>/GeditWindowActions/FileSaveAll" "<shift><primary>l")
+(gtk_accel_path "<Actions>/FileBrowserWidgetSingleMostSelectionActionGroup/FileNew" "<primary>n")
+(gtk_accel_path "<Actions>/FileBrowserWidgetSensitiveActionGroup/DirectoryOpen" "<primary>o")
+(gtk_accel_path "<Actions>/GeditWindowActions/SearchFindNext" "<primary>g")
+(gtk_accel_path "<Actions>/GeditWindowPanelsActions/ViewBottomPanel" "<primary>f9")
+(gtk_accel_path "<Actions>/GeditWindowActions/DocumentsNextTabGroup" "<shift><primary><alt>page_down")
+(gtk_accel_path "<Actions>/GeditWindowAlwaysSensitiveActions/ViewFullscreen" "f11")
+(gtk_accel_path "<Actions>/GeditWindowActions/EditCopy" "<primary>c")
+(gtk_accel_path "<Actions>/GeditWindowAlwaysSensitiveActions/FileNew" "<primary>n")
+(gtk_accel_path "<Actions>/GeditWindowActions/DocumentsPreviousDocument" "<primary><alt>page_up")
+(gtk_accel_path "<Actions>/GeditWindowActions/DocumentsNewTabGroup" "<primary><alt>n")
+(gtk_accel_path "<Actions>/GeditWindowActions/EditSelectAll" "<primary>a")
+(gtk_accel_path "<Actions>/FileBrowserWidgetFileSelectionActionGroup/FileOpen" "<primary>o")
+(gtk_accel_path "<Actions>/GeditWindowAlwaysSensitiveActions/EditPreferences" "<primary>comma")
diff --git a/data/osx.css b/data/osx.css
new file mode 100644
index 0000000..91b210a
--- /dev/null
+++ b/data/osx.css
@@ -0,0 +1,132 @@
+ binding-set gtk-osx-editable {
+  bind "<primary>c" { "copy-clipboard" () };
+  bind "<primary>x" { "cut-clipboard" () };
+  bind "<primary>v" { "paste-clipboard" () };
+
+  unbind "<control>c";
+  unbind "<control>x";
+  unbind "<control>v";
+
+  bind "<primary>Left" { "move-cursor" (display-line-ends, -1, 0) };
+  bind "<primary>KP_Left" { "move-cursor" (display-line-ends, -1, 0) };
+  bind "<primary><shift>Left" { "move-cursor" (display-line-ends, -1, 1) };
+  bind "<primary><shift>KP_Left" { "move-cursor" (display-line-ends, -1, 1) };
+
+  bind "<primary>Right" { "move-cursor" (display-line-ends, 1, 0) };
+  bind "<primary>KP_Right" { "move-cursor" (display-line-ends, 1, 0) };
+  bind "<primary><shift>Right" { "move-cursor" (display-line-ends, 1, 1) };
+  bind "<primary><shift>KP_Right" { "move-cursor" (display-line-ends, 1, 1) };
+
+  unbind "<control>Left";
+  unbind "<control>KP_Left";
+  unbind "<control><shift>Left";
+  unbind "<control><shift>KP_Left";
+  unbind "<control>Right";
+  unbind "<control>KP_Right";
+  unbind "<control><shift>Right";
+  unbind "<control><shift>KP_Right";
+
+  bind "<alt>Right"           { "move-cursor" (words, 1, 0) };
+  bind "<alt>KP_Right"        { "move-cursor" (words, 1, 0) };
+  bind "<alt>Left"            { "move-cursor" (words, -1, 0) };
+  bind "<alt>KP_Left"         { "move-cursor" (words, -1, 0) };
+  bind "<shift><alt>Right"    { "move-cursor" (words, 1, 1) };
+  bind "<shift><alt>KP_Right" { "move-cursor" (words, 1, 1) };
+  bind "<shift><alt>Left"     { "move-cursor" (words, -1, 1) };
+  bind "<shift><alt>KP_Left"  { "move-cursor" (words, -1, 1) };
+
+  bind "<alt>delete"          { "delete-from-cursor" (word-ends, 1) };
+  bind "<alt>KP_delete"       { "delete-from-cursor" (word-ends, 1) };
+  bind "<alt>backspace"       { "delete-from-cursor" (word-ends, -1) };
+
+  bind "<primary>Down"           { "move-cursor" (buffer-ends, 1, 0) };
+  bind "<primary><shift>Down"    { "move-cursor" (buffer-ends, 1, 1) };
+  bind "<primary>KP_Down"        { "move-cursor" (buffer-ends, 1, 0) };
+  bind "<primary><shift>KP_Down" { "move-cursor" (buffer-ends, 1, 1) };
+
+  bind "<primary>Up"             { "move-cursor" (buffer-ends, -1, 0) };
+  bind "<primary><shift>Up"      { "move-cursor" (buffer-ends, -1, 1) };
+  bind "<primary>KP_Up"          { "move-cursor" (buffer-ends, -1, 0) };
+  bind "<primary><shift>KP_Up"   { "move-cursor" (buffer-ends, -1, 1) };
+
+  unbind "<control>Down";
+  unbind "<control>KP_Down";
+  unbind "<control><shift>Down";
+  unbind "<control><shift>KP_Down";
+  unbind "<control>Up";
+  unbind "<control>KP_Up";
+  unbind "<control><shift>Up";
+  unbind "<control><shift>KP_Up";
+}
+
+ binding-set gtk-osx-text-entry {
+  bind "<primary>a" {
+    "move-cursor" (buffer-ends, -1, 0)
+    "move-cursor" (buffer-ends, 1, 1)
+  };
+
+  unbind "<control>a";
+}
+
+ binding-set gtk-osx-text-view {
+  bind "<primary>a"       { "select-all" (1) };
+  unbind "<control>a";
+}
+
+ binding-set gtk-osx-tree-view {
+  bind "<primary>s" { "start-interactive-search" () };
+  unbind "<control>s";
+}
+
+ binding-set gtk-osx-source-view {
+  bind "<primary>z" { "undo" () };
+  unbind "<control>z";
+
+  bind "<primary><shift>z" { "redo" () };
+  unbind "<control><shift>z";
+}
+
+ binding-set gedit-osx-view {
+  bind "<primary>d" { "delete-from-cursor" (GTK_DELETE_PARAGRAPHS, 1) };
+  unbind "<control>d";
+}
+
+GtkEntry {
+  gtk-key-bindings: gtk-osx-editable, gtk-osx-text-entry;
+}
+
+GtkTextView {
+  gtk-key-bindings: gtk-osx-editable, gtk-osx-text-view;
+}
+
+GtkSourceView {
+  gtk-key-bindings: gtk-osx-editable, gtk-osx-text-view, gtk-osx-source-view;
+}
+
+GeditView {
+  gtk-key-bindings: gtk-osx-editable, gtk-osx-text-view, gtk-osx-source-view, gedit-osx-view;
+}
+
+GtkTreeView {
+  gtk-key-bindings: gtk-osx-tree-view;
+}
+
+GtkNotebook
+{
+	padding: 0;
+}
+
+GtkNotebook tab
+{
+	padding: 4 2 2 2;
+}
+
+GtkWidget
+{
+	font-family: "Lucida Grande";
+}
+
+GtkEntry
+{
+	font-family: "Helvetica";
+}
\ No newline at end of file
diff --git a/gedit/Makefile.am b/gedit/Makefile.am
index b5d730c..e10212c 100644
--- a/gedit/Makefile.am
+++ b/gedit/Makefile.am
@@ -12,7 +12,7 @@ INCLUDES =								\
 	-I$(srcdir)							\
 	-I$(srcdir)/smclient						\
 	$(GEDIT_CFLAGS)							\
-	$(IGE_MAC_CFLAGS)						\
+	$(GTK_MAC_CFLAGS)						\
 	$(WARN_CFLAGS)							\
 	$(DISABLE_DEPRECATED_CFLAGS)					\
 	$(INTROSPECTION_CFLAGS)						\
@@ -26,7 +26,7 @@ gedit_LDADD =			\
 	libgedit.la		\
 	libgedit-private.la	\
 	$(GEDIT_LIBS)		\
-	$(IGE_MAC_LIBS)		\
+	$(GTK_MAC_LIBS)		\
 	$(EGG_SMCLIENT_LIBS)	\
 	$(INTROSPECTION_LIBS)
 
@@ -44,23 +44,19 @@ libgedit_la_LIBADD = \
 	theatrics/libtheatrics.la
 
 # GEDIT_LIBS must be the last to ensure correct order on some platforms
-libgedit_la_LIBADD += $(GEDIT_LIBS)
+libgedit_la_LIBADD += $(GEDIT_LIBS) $(GTK_MAC_LIBS)
 
 # Mac OSX convenience library and ldflags
 if OS_OSX
-gedit_LDFLAGS += -framework Carbon
-
 noinst_LTLIBRARIES += libosx.la
 
-libosx_la_LDFLAGS = -framework Carbon -framework ApplicationServices -framework Cocoa
+libosx_la_LDFLAGS = -framework Cocoa
 libosx_la_LIBADD = -lobjc
 libosx_la_CFLAGS = -xobjective-c
 
 libosx_la_SOURCES = 		\
 	gedit-app-osx.c		\
-	gedit-app-osx.h		\
-	gedit-osx-delegate.m 	\
-	gedit-osx-delegate.h
+	gedit-app-osx.h
 
 libgedit_la_LIBADD += libosx.la
 endif
diff --git a/gedit/gedit-app-osx.c b/gedit/gedit-app-osx.c
index 643b8f4..294c604 100644
--- a/gedit/gedit-app-osx.c
+++ b/gedit/gedit-app-osx.c
@@ -21,11 +21,15 @@
  */
 
 #include "gedit-app-osx.h"
-
+#include <gedit/gedit-dirs.h>
+#include <gedit/gedit-debug.h>
 #include <gdk/gdkquartz.h>
-#include <Carbon/Carbon.h>
+#include <gtkosxapplication.h>
+#include <string.h>
+#include <glib/gi18n.h>
 
-#import "gedit-osx-delegate.h"
+#include "gedit-commands.h"
+#include <AvailabilityMacros.h>
 
 G_DEFINE_TYPE (GeditAppOSX, gedit_app_osx, GEDIT_TYPE_APP)
 
@@ -36,7 +40,8 @@ gedit_app_osx_finalize (GObject *object)
 }
 
 static gboolean
-gedit_app_osx_last_window_destroyed_impl (GeditApp *app)
+gedit_app_osx_last_window_destroyed_impl (GeditApp *app,
+                                          GeditWindow *window)
 {
 	if (!GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "gedit-is-quitting-all")))
 	{
@@ -45,10 +50,10 @@ gedit_app_osx_last_window_destroyed_impl (GeditApp *app)
 		return FALSE;
 	}
 
-	return GEDIT_APP_CLASS (gedit_app_osx_parent_class)->last_window_destroyed (app);
+	return GEDIT_APP_CLASS (gedit_app_osx_parent_class)->last_window_destroyed (app, window);
 }
 
-static gboolean
+gboolean
 gedit_app_osx_show_url (GeditAppOSX *app,
                         const gchar *url)
 {
@@ -63,7 +68,7 @@ gedit_app_osx_show_help_impl (GeditApp    *app,
 {
 	gboolean ret = FALSE;
 
-	if (name == NULL || strcmp (name, "gedit.xml") == NULL || strcmp (name, "gedit") == 0)
+	if (name == NULL || g_strcmp0 (name, "gedit.xml") == 0 || g_strcmp0 (name, "gedit") == 0)
 	{
 		gchar *link;
 
@@ -77,7 +82,7 @@ gedit_app_osx_show_help_impl (GeditApp    *app,
 			link = g_strdup ("http://library.gnome.org/users/gedit/stable/";);
 		}
 
-		ret = gedit_osx_show_url (link);
+		ret = gedit_app_osx_show_url (GEDIT_APP_OSX (app), link);
 		g_free (link);
 	}
 
@@ -91,16 +96,19 @@ gedit_app_osx_set_window_title_impl (GeditApp    *app,
 {
 	NSWindow *native;
 	GeditDocument *document;
+	GdkWindow *wnd;
 
 	g_return_if_fail (GEDIT_IS_WINDOW (window));
 
-	if (GTK_WIDGET (window)->window == NULL)
+	wnd = gtk_widget_get_window (GTK_WIDGET (window));
+
+	if (wnd == NULL)
 	{
 		return;
 	}
 
-	native = gdk_quartz_window_get_nswindow (GTK_WIDGET (window)->window);
-	document = gedit_app_get_active_document (app);
+	native = gdk_quartz_window_get_nswindow (wnd);
+	document = gedit_window_get_active_document (window);
 
 	if (document)
 	{
@@ -108,14 +116,36 @@ gedit_app_osx_set_window_title_impl (GeditApp    *app,
 
 		if (gedit_document_is_untitled (document))
 		{
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
 			[native setRepresentedURL:nil];
+#else
+			[native setRepresentedFilename:nil];
+#endif
 		}
 		else
 		{
-			const gchar *uri = gedit_document_get_uri (document);
+			GFile *location;
+			gchar *uri;
+
+			location = gedit_document_get_location (document);
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+			uri = g_file_get_uri (location);
+			g_object_unref (location);
+
 			NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:uri]];
 			
 			[native setRepresentedURL:nsurl];
+			g_free (uri);
+#else
+			if (g_file_has_uri_scheme (location, "file"))
+			{
+				uri = g_file_get_path (location);
+				[native setRepresentedFilename:[NSString stringWithUTF8String:uri]];
+
+				g_free (uri);
+			}
+#endif
 		}
 
 		ismodified = !gedit_document_is_untouched (document); 
@@ -123,11 +153,188 @@ gedit_app_osx_set_window_title_impl (GeditApp    *app,
 	}
 	else
 	{
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
 		[native setRepresentedURL:nil];
+#else
+		[native setRepresentedFilename:nil];
+#endif
 		[native setDocumentEdited:false];
 	}
 
-	GEDIT_APP (gedit_app_osx_parent_class)->set_window_title (app, window, title);
+	GEDIT_APP_CLASS (gedit_app_osx_parent_class)->set_window_title (app, window, title);
+}
+
+static void
+gedit_app_osx_quit_impl (GeditApp *app)
+{
+	GtkOSXApplication *osxapp;
+
+	osxapp = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL);
+	gtk_osxapplication_cleanup (osxapp);
+
+	GEDIT_APP_CLASS (gedit_app_osx_parent_class)->quit (app);
+}
+
+static void
+load_accels (void)
+{
+	gchar *filename;
+
+	filename = g_build_filename (gedit_dirs_get_gedit_data_dir (),
+	                             "osx.accels",
+	                             NULL);
+
+	if (filename != NULL)
+	{
+		gedit_debug_message (DEBUG_APP, "Loading accels from %s\n", filename);
+
+		gtk_accel_map_load (filename);
+		g_free (filename);
+	}
+}
+
+static void
+load_keybindings (void)
+{
+	gchar *filename;
+
+	filename = g_build_filename (gedit_dirs_get_gedit_data_dir (),
+	                             "osx.css",
+	                             NULL);
+
+	if (filename != NULL)
+	{
+		GtkCssProvider *provider;
+		GError *error = NULL;
+
+		gedit_debug_message (DEBUG_APP, "Loading keybindings from %s\n", filename);
+
+		provider = gtk_css_provider_new ();
+
+		if (!gtk_css_provider_load_from_path (provider,
+		                                      filename,
+		                                      &error))
+		{
+			g_warning ("Failed to load osx keybindings from `%s':\n%s",
+			           filename,
+			           error->message);
+
+			g_error_free (error);
+		}
+		else
+		{
+			gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+			                                           GTK_STYLE_PROVIDER (provider),
+			                                           GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
+		}
+
+		g_object_unref (provider);
+		g_free (filename);
+	}
+}
+
+static void
+gedit_app_osx_constructed (GObject *object)
+{
+	/* First load the osx specific accel overrides */
+	load_accels ();
+	load_keybindings ();
+
+	if (G_OBJECT_CLASS (gedit_app_osx_parent_class)->constructed)
+	{
+		/* Then chain up to load the user specific accels */
+		G_OBJECT_CLASS (gedit_app_osx_parent_class)->constructed (object);
+	}
+}
+
+static GtkMenuItem *
+ui_manager_menu_item (GtkUIManager *uimanager,
+                      const gchar  *path)
+{
+	return GTK_MENU_ITEM (gtk_ui_manager_get_widget (uimanager, path));
+}
+
+static void
+setup_mac_menu (GeditWindow *window)
+{
+	GtkAction *action;
+	GtkOSXApplication *osxapp;
+	GtkUIManager *manager;
+	GtkWidget *menu;
+
+	manager = gedit_window_get_ui_manager (window);
+	
+	/* Hide the menu bar */
+	menu = gtk_ui_manager_get_widget (manager, "/MenuBar");
+	gtk_widget_hide (menu);
+
+	osxapp = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL);
+
+	action = gtk_ui_manager_get_action (manager, "/ui/MenuBar/HelpMenu/HelpAboutMenu");
+	gtk_action_set_label (action, _("About gedit"));
+
+	gtk_widget_hide (GTK_WIDGET (ui_manager_menu_item (manager,
+	                             "/ui/MenuBar/FileMenu/FileQuitMenu")));
+
+	gtk_osxapplication_set_menu_bar (osxapp,
+	                                 GTK_MENU_SHELL (menu));
+
+	gtk_osxapplication_set_help_menu (osxapp,
+	                                  ui_manager_menu_item (manager,
+	                                                        "/ui/MenuBar/HelpMenu"));
+
+	gtk_osxapplication_set_window_menu (osxapp, NULL);
+
+	gtk_osxapplication_insert_app_menu_item (osxapp,
+	                                         GTK_WIDGET (ui_manager_menu_item (manager,
+	                                                                           "/ui/MenuBar/HelpMenu/HelpAboutMenu")),
+	                                         0);
+
+	gtk_osxapplication_insert_app_menu_item (osxapp,
+	                                         g_object_ref (gtk_separator_menu_item_new ()),
+	                                         1);
+
+	gtk_osxapplication_insert_app_menu_item (osxapp,
+	                                         GTK_WIDGET (ui_manager_menu_item (manager,
+	                                                                           "/ui/MenuBar/EditMenu/EditPreferencesMenu")),
+	                                         2);
+
+	/* We remove the accel group of the uimanager from the window */
+	gtk_window_remove_accel_group (GTK_WINDOW (window),
+	                               gtk_ui_manager_get_accel_group (manager));
+}
+
+static GeditWindow *
+gedit_app_osx_create_window_impl (GeditApp *app)
+{
+	GeditWindow *window;
+	
+	window = GEDIT_APP_CLASS (gedit_app_osx_parent_class)->create_window (app);
+
+	setup_mac_menu (window);
+
+
+	return window;
+}
+
+static gboolean
+gedit_app_osx_process_window_event_impl (GeditApp    *app,
+                                         GeditWindow *window,
+                                         GdkEvent    *event)
+{
+	NSEvent *nsevent;
+	
+	/* For OS X we will propagate the event to NSApp, which handles some OS X
+	 * specific keybindings and the accelerators for the menu
+	 */
+	nsevent = gdk_quartz_event_get_nsevent (event);
+	[NSApp sendEvent:nsevent];
+	
+	/* It does not really matter what we return here since it's the last thing
+	 * in the chain. Also we can't get from sendEvent whether the event was
+	 * actually handled by NSApp anyway
+	 */
+	return TRUE;
 }
 
 static void
@@ -137,32 +344,82 @@ gedit_app_osx_class_init (GeditAppOSXClass *klass)
 	GeditAppClass *app_class = GEDIT_APP_CLASS (klass);
 
 	object_class->finalize = gedit_app_osx_finalize;
+	object_class->constructed = gedit_app_osx_constructed;
 
 	app_class->last_window_destroyed = gedit_app_osx_last_window_destroyed_impl;
-	app_class->show_help = gedit_app_show_help_impl;
+	app_class->show_help = gedit_app_osx_show_help_impl;
+	app_class->set_window_title = gedit_app_osx_set_window_title_impl;
+	app_class->quit = gedit_app_osx_quit_impl;
+	app_class->create_window = gedit_app_osx_create_window_impl;
+	app_class->process_window_event = gedit_app_osx_process_window_event_impl;
 }
 
 static void
-destroy_delegate (GeditOSXDelegate *delegate)
+on_osx_will_terminate (GtkOSXApplication *osxapp,
+                       GeditAppOSX       *app)
 {
-	[delegate dealloc];
+	_gedit_app_quit (GEDIT_APP (app));
 }
 
-static void
-gedit_app_osx_init (GeditAppOSX *self)
+static gboolean
+on_osx_open_files (GtkOSXApplication  *osxapp,
+                   gchar const       **paths,
+                   GeditAppOSX        *app)
 {
-	GeditOSXDelegate *delegate = [[GeditOSXDelegate alloc] init];
+	GSList *locations = NULL;
+
+	while (paths && *paths)
+	{
+		locations = g_slist_prepend (locations,
+		                             g_file_new_for_uri (*paths));
+		++paths;
+	}
+	
+	locations = g_slist_reverse (locations);
+	
+	if (locations != NULL)
+	{
+		GSList *files;
+		GeditWindow *window;
+		
+		window = gedit_app_get_active_window (GEDIT_APP (app));
 
-	g_object_set_data_full (G_OBJECT (app),
-	                        "GeditOSXDelegate",
-	                        delegate,
-	                        (GDestroyNotify)destroy_delegate);
+		files = gedit_commands_load_locations (window,
+		                                       locations,
+		                                       NULL,
+		                                       0,
+		                                       0);
 
-	ige_mac_menu_set_global_key_handler_enabled (FALSE);
+		g_slist_free_full (locations, g_object_unref);
+	}
+	
+	return TRUE;
+}
+
+static void
+gedit_app_osx_init (GeditAppOSX *app)
+{
+	GtkOSXApplication *osxapp;
+
+	/* This is a singleton */
+	osxapp = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL);
 
 	/* manually set name and icon */
 	g_set_application_name ("gedit");
 	gtk_window_set_default_icon_name ("accessories-text-editor");
+
+	g_signal_connect (osxapp,
+	                  "NSApplicationWillTerminate",
+	                  G_CALLBACK (on_osx_will_terminate),
+	                  app);
+
+	g_signal_connect (osxapp,
+	                  "NSApplicationOpenFiles",
+	                  G_CALLBACK (on_osx_open_files),
+	                  app);
+
+	gtk_osxapplication_set_use_quartz_accelerators (osxapp, FALSE);
+	gtk_osxapplication_ready (osxapp);
 }
 
 /* ex:set ts=8 noet: */
diff --git a/gedit/gedit-app-osx.h b/gedit/gedit-app-osx.h
index 1981c39..fa4533f 100644
--- a/gedit/gedit-app-osx.h
+++ b/gedit/gedit-app-osx.h
@@ -24,7 +24,6 @@
 #define __GEDIT_APP_OSX_H__
 
 #include "gedit-app.h"
-#include <ige-mac-integration.h>
 
 G_BEGIN_DECLS
 
@@ -51,14 +50,14 @@ struct _GeditAppOSXClass
 };
 
 GType		 gedit_app_osx_get_type		(void) G_GNUC_CONST;
+
 void		 gedit_app_osx_set_window_title	(GeditAppOSX   *app,
 						 GeditWindow   *window,
 						 const gchar   *title,
 						 GeditDocument *document);
-gboolean	 gedit_app_osx_show_url		(GeditAppOSX   *app,
-						 const gchar   *url);
-gboolean	 gedit_app_osx_show_help	(GeditAppOSX   *app,
-						 const gchar   *link_id);
+
+gboolean         gedit_app_osx_show_url         (GeditAppOSX *app,
+                                                 const gchar *url);
 
 G_END_DECLS
 
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index ce6d726..3cb50af 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -175,7 +175,8 @@ gedit_app_constructor (GType                  gtype,
 }
 
 static gboolean
-gedit_app_last_window_destroyed_impl (GeditApp *app)
+gedit_app_last_window_destroyed_impl (GeditApp    *app,
+                                      GeditWindow *window)
 {
 	return TRUE;
 }
@@ -260,34 +261,6 @@ gedit_app_set_window_title_impl (GeditApp    *app,
 	gtk_window_set_title (GTK_WINDOW (window), title);
 }
 
-static void
-gedit_app_class_init (GeditAppClass *klass)
-{
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-	object_class->finalize = gedit_app_finalize;
-	object_class->dispose = gedit_app_dispose;
-	object_class->get_property = gedit_app_get_property;
-	object_class->constructor = gedit_app_constructor;
-
-	klass->last_window_destroyed = gedit_app_last_window_destroyed_impl;
-	klass->show_help = gedit_app_show_help_impl;
-	klass->help_link_id = gedit_app_help_link_id_impl;
-	klass->set_window_title = gedit_app_set_window_title_impl;
-
-	g_object_class_install_property (object_class,
-					 PROP_LOCKDOWN,
-					 g_param_spec_flags ("lockdown",
-							     "Lockdown",
-							     "The lockdown mask",
-							     GEDIT_TYPE_LOCKDOWN_MASK,
-							     0,
-							     G_PARAM_READABLE |
-							     G_PARAM_STATIC_STRINGS));
-
-	g_type_class_add_private (object_class, sizeof (GeditAppPrivate));
-}
-
 static gboolean
 ensure_user_config_dir (void)
 {
@@ -313,22 +286,6 @@ ensure_user_config_dir (void)
 }
 
 static void
-load_accels (void)
-{
-	gchar *filename;
-
-	filename = g_build_filename (gedit_dirs_get_user_config_dir (),
-				     "accels",
-				     NULL);
-	if (filename != NULL)
-	{
-		gedit_debug_message (DEBUG_APP, "Loading keybindings from %s\n", filename);
-		gtk_accel_map_load (filename);
-		g_free (filename);
-	}
-}
-
-static void
 save_accels (void)
 {
 	gchar *filename;
@@ -363,37 +320,6 @@ get_page_setup_file (void)
 }
 
 static void
-load_page_setup (GeditApp *app)
-{
-	gchar *filename;
-	GError *error = NULL;
-
-	g_return_if_fail (app->priv->page_setup == NULL);
-
-	filename = get_page_setup_file ();
-
-	app->priv->page_setup = gtk_page_setup_new_from_file (filename,
-							      &error);
-	if (error)
-	{
-		/* Ignore file not found error */
-		if (error->domain != G_FILE_ERROR ||
-		    error->code != G_FILE_ERROR_NOENT)
-		{
-			g_warning ("%s", error->message);
-		}
-
-		g_error_free (error);
-	}
-
-	g_free (filename);
-
-	/* fall back to default settings */
-	if (app->priv->page_setup == NULL)
-		app->priv->page_setup = gtk_page_setup_new ();
-}
-
-static void
 save_page_setup (GeditApp *app)
 {
 	gchar *filename;
@@ -435,17 +361,233 @@ get_print_settings_file (void)
 }
 
 static void
-load_print_settings (GeditApp *app)
+save_print_settings (GeditApp *app)
 {
 	gchar *filename;
 	GError *error = NULL;
 
-	g_return_if_fail (app->priv->print_settings == NULL);
+	if (app->priv->print_settings == NULL)
+		return;
 
 	filename = get_print_settings_file ();
 
-	app->priv->print_settings = gtk_print_settings_new_from_file (filename,
-								      &error);
+	gtk_print_settings_to_file (app->priv->print_settings,
+				    filename,
+				    &error);
+	if (error)
+	{
+		g_warning ("%s", error->message);
+		g_error_free (error);
+	}
+
+	g_free (filename);
+}
+
+static void
+gedit_app_quit_impl (GeditApp *app)
+{
+	gedit_debug_message (DEBUG_APP, "Quitting\n");
+
+	/* Last window is gone... save some settings and exit */
+	ensure_user_config_dir ();
+
+	save_accels ();
+	save_page_setup (app);
+	save_print_settings (app);
+
+	gtk_main_quit ();
+}
+
+static void
+load_accels (void)
+{
+	gchar *filename;
+
+	filename = g_build_filename (gedit_dirs_get_user_config_dir (),
+				     "accels",
+				     NULL);
+	if (filename != NULL)
+	{
+		gedit_debug_message (DEBUG_APP, "Loading keybindings from %s\n", filename);
+		gtk_accel_map_load (filename);
+		g_free (filename);
+	}
+}
+
+static void
+gedit_app_constructed (GObject *object)
+{
+	load_accels ();
+}
+
+static void
+set_active_window (GeditApp    *app,
+                   GeditWindow *window)
+{
+	app->priv->active_window = window;
+}
+
+static gboolean
+window_focus_in_event (GeditWindow   *window, 
+		       GdkEventFocus *event, 
+		       GeditApp      *app)
+{
+	/* updates active_view and active_child when a new toplevel receives focus */
+	g_return_val_if_fail (GEDIT_IS_WINDOW (window), FALSE);
+
+	set_active_window (app, window);
+
+	return FALSE;
+}
+
+static gboolean 
+window_delete_event (GeditWindow *window,
+                     GdkEvent    *event,
+                     GeditApp    *app)
+{
+	GeditWindowState ws;
+
+	ws = gedit_window_get_state (window);
+
+	if (ws & 
+	    (GEDIT_WINDOW_STATE_SAVING |
+	     GEDIT_WINDOW_STATE_PRINTING |
+	     GEDIT_WINDOW_STATE_SAVING_SESSION))
+	{
+		return TRUE;
+	}
+
+	_gedit_cmd_file_quit (NULL, window);
+
+	/* Do not destroy the window */
+	return TRUE;
+}
+
+void
+_gedit_app_quit (GeditApp *app)
+{
+	GEDIT_APP_GET_CLASS (app)->quit (app);
+}
+
+static void
+window_destroy (GeditWindow *window, 
+		GeditApp    *app)
+{
+	app->priv->windows = g_list_remove (app->priv->windows,
+					    window);
+
+	if (window == app->priv->active_window)
+	{
+		set_active_window (app, app->priv->windows != NULL ? app->priv->windows->data : NULL);
+	}
+
+/* CHECK: I don't think we have to disconnect this function, since windows
+   is being destroyed */
+/*					     
+	g_signal_handlers_disconnect_by_func (window, 
+					      G_CALLBACK (window_focus_in_event),
+					      app);
+	g_signal_handlers_disconnect_by_func (window, 
+					      G_CALLBACK (window_destroy),
+					      app);
+*/
+	if (app->priv->windows == NULL)
+	{
+		if (!GEDIT_APP_GET_CLASS (app)->last_window_destroyed (app, window))
+		{
+			return;
+		}
+
+		_gedit_app_quit (app);
+	}
+}
+
+static GeditWindow *
+gedit_app_create_window_impl (GeditApp *app)
+{
+	GeditWindow *window;
+	gboolean isfirst;
+	
+	/*
+	 * We need to be careful here, there is a race condition:
+	 * when another gedit is launched it checks active_window,
+	 * so we must do our best to ensure that active_window
+	 * is never NULL when at least a window exists.
+	 */
+
+	isfirst = (app->priv->windows == NULL);
+	
+	window = g_object_new (GEDIT_TYPE_WINDOW, NULL);
+
+	if (isfirst)
+	{
+		set_active_window (app, window);
+	}
+
+	app->priv->windows = g_list_prepend (app->priv->windows,
+					     window);
+
+	gedit_debug_message (DEBUG_APP, "Window created");
+
+	g_signal_connect (window, 
+			  "focus_in_event",
+			  G_CALLBACK (window_focus_in_event), 
+			  app);
+	g_signal_connect (window,
+			  "delete_event",
+			  G_CALLBACK (window_delete_event),
+			  app);			  
+	g_signal_connect (window, 
+			  "destroy",
+			  G_CALLBACK (window_destroy),
+			  app);
+
+	return window;
+}
+
+static void
+gedit_app_class_init (GeditAppClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = gedit_app_finalize;
+	object_class->dispose = gedit_app_dispose;
+	object_class->get_property = gedit_app_get_property;
+	object_class->constructor = gedit_app_constructor;
+	object_class->constructed = gedit_app_constructed;
+
+	klass->last_window_destroyed = gedit_app_last_window_destroyed_impl;
+	klass->show_help = gedit_app_show_help_impl;
+	klass->help_link_id = gedit_app_help_link_id_impl;
+	klass->set_window_title = gedit_app_set_window_title_impl;
+	klass->quit = gedit_app_quit_impl;
+	klass->create_window = gedit_app_create_window_impl;
+
+	g_object_class_install_property (object_class,
+					 PROP_LOCKDOWN,
+					 g_param_spec_flags ("lockdown",
+							     "Lockdown",
+							     "The lockdown mask",
+							     GEDIT_TYPE_LOCKDOWN_MASK,
+							     0,
+							     G_PARAM_READABLE |
+							     G_PARAM_STATIC_STRINGS));
+
+	g_type_class_add_private (object_class, sizeof (GeditAppPrivate));
+}
+
+static void
+load_page_setup (GeditApp *app)
+{
+	gchar *filename;
+	GError *error = NULL;
+
+	g_return_if_fail (app->priv->page_setup == NULL);
+
+	filename = get_page_setup_file ();
+
+	app->priv->page_setup = gtk_page_setup_new_from_file (filename,
+							      &error);
 	if (error)
 	{
 		/* Ignore file not found error */
@@ -461,31 +603,39 @@ load_print_settings (GeditApp *app)
 	g_free (filename);
 
 	/* fall back to default settings */
-	if (app->priv->print_settings == NULL)
-		app->priv->print_settings = gtk_print_settings_new ();
+	if (app->priv->page_setup == NULL)
+		app->priv->page_setup = gtk_page_setup_new ();
 }
 
 static void
-save_print_settings (GeditApp *app)
+load_print_settings (GeditApp *app)
 {
 	gchar *filename;
 	GError *error = NULL;
 
-	if (app->priv->print_settings == NULL)
-		return;
+	g_return_if_fail (app->priv->print_settings == NULL);
 
 	filename = get_print_settings_file ();
 
-	gtk_print_settings_to_file (app->priv->print_settings,
-				    filename,
-				    &error);
+	app->priv->print_settings = gtk_print_settings_new_from_file (filename,
+								      &error);
 	if (error)
 	{
-		g_warning ("%s", error->message);
+		/* Ignore file not found error */
+		if (error->domain != G_FILE_ERROR ||
+		    error->code != G_FILE_ERROR_NOENT)
+		{
+			g_warning ("%s", error->message);
+		}
+
 		g_error_free (error);
 	}
 
 	g_free (filename);
+
+	/* fall back to default settings */
+	if (app->priv->print_settings == NULL)
+		app->priv->print_settings = gtk_print_settings_new ();
 }
 
 static void
@@ -511,8 +661,6 @@ gedit_app_init (GeditApp *app)
 {
 	app->priv = GEDIT_APP_GET_PRIVATE (app);
 
-	load_accels ();
-
 	/* Load settings */
 	app->priv->settings = gedit_settings_new ();
 	app->priv->window_settings = g_settings_new ("org.gnome.gedit.state.window");
@@ -571,89 +719,6 @@ gedit_app_get_default (void)
 	return GEDIT_APP (g_object_new (type, NULL));
 }
 
-static void
-set_active_window (GeditApp    *app,
-                   GeditWindow *window)
-{
-	app->priv->active_window = window;
-}
-
-static gboolean
-window_focus_in_event (GeditWindow   *window, 
-		       GdkEventFocus *event, 
-		       GeditApp      *app)
-{
-	/* updates active_view and active_child when a new toplevel receives focus */
-	g_return_val_if_fail (GEDIT_IS_WINDOW (window), FALSE);
-
-	set_active_window (app, window);
-
-	return FALSE;
-}
-
-static gboolean 
-window_delete_event (GeditWindow *window,
-                     GdkEvent    *event,
-                     GeditApp    *app)
-{
-	GeditWindowState ws;
-
-	ws = gedit_window_get_state (window);
-
-	if (ws & 
-	    (GEDIT_WINDOW_STATE_SAVING |
-	     GEDIT_WINDOW_STATE_PRINTING |
-	     GEDIT_WINDOW_STATE_SAVING_SESSION))
-	{
-		return TRUE;
-	}
-
-	_gedit_cmd_file_quit (NULL, window);
-
-	/* Do not destroy the window */
-	return TRUE;
-}
-
-static void
-window_destroy (GeditWindow *window, 
-		GeditApp    *app)
-{
-	app->priv->windows = g_list_remove (app->priv->windows,
-					    window);
-
-	if (window == app->priv->active_window)
-	{
-		set_active_window (app, app->priv->windows != NULL ? app->priv->windows->data : NULL);
-	}
-
-/* CHECK: I don't think we have to disconnect this function, since windows
-   is being destroyed */
-/*					     
-	g_signal_handlers_disconnect_by_func (window, 
-					      G_CALLBACK (window_focus_in_event),
-					      app);
-	g_signal_handlers_disconnect_by_func (window, 
-					      G_CALLBACK (window_destroy),
-					      app);
-*/
-	if (app->priv->windows == NULL)
-	{
-		if (!GEDIT_APP_GET_CLASS (app)->last_window_destroyed (app))
-		{
-			return;
-		}
-
-		/* Last window is gone... save some settings and exit */
-		ensure_user_config_dir ();
-
-		save_accels ();
-		save_page_setup (app);
-		save_print_settings (app);
-
-		gtk_main_quit ();
-	}
-}
-
 /* Generates a unique string for a window role */
 static gchar *
 gen_role (void)
@@ -676,27 +741,8 @@ gedit_app_create_window_real (GeditApp    *app,
 			      const gchar *role)
 {
 	GeditWindow *window;
-
-	/*
-	 * We need to be careful here, there is a race condition:
-	 * when another gedit is launched it checks active_window,
-	 * so we must do our best to ensure that active_window
-	 * is never NULL when at least a window exists.
-	 */
-	if (app->priv->windows == NULL)
-	{
-		window = g_object_new (GEDIT_TYPE_WINDOW, NULL);
-		set_active_window (app, window);
-	}
-	else
-	{
-		window = g_object_new (GEDIT_TYPE_WINDOW, NULL);
-	}
-
-	app->priv->windows = g_list_prepend (app->priv->windows,
-					     window);
-
-	gedit_debug_message (DEBUG_APP, "Window created");
+	
+	window = GEDIT_APP_GET_CLASS (app)->create_window (app);
 
 	if (role != NULL)
 	{
@@ -722,32 +768,28 @@ gedit_app_create_window_real (GeditApp    *app,
 		g_settings_get (app->priv->window_settings,
 				GEDIT_SETTINGS_WINDOW_SIZE,
 				"(ii)", &w, &h);
+
 		gtk_window_set_default_size (GTK_WINDOW (window), w, h);
 
 		if ((state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
+		{
 			gtk_window_maximize (GTK_WINDOW (window));
+		}
 		else
+		{
 			gtk_window_unmaximize (GTK_WINDOW (window));
+		}
 
 		if ((state & GDK_WINDOW_STATE_STICKY ) != 0)
+		{
 			gtk_window_stick (GTK_WINDOW (window));
+		}
 		else
+		{
 			gtk_window_unstick (GTK_WINDOW (window));
+		}
 	}
 
-	g_signal_connect (window, 
-			  "focus_in_event",
-			  G_CALLBACK (window_focus_in_event), 
-			  app);
-	g_signal_connect (window,
-			  "delete_event",
-			  G_CALLBACK (window_delete_event),
-			  app);			  
-	g_signal_connect (window, 
-			  "destroy",
-			  G_CALLBACK (window_destroy),
-			  app);
-
 	return window;
 }
 
@@ -771,7 +813,9 @@ gedit_app_create_window (GeditApp  *app,
 	window = gedit_app_create_window_real (app, TRUE, NULL);
 
 	if (screen != NULL)
+	{
 		gtk_window_set_screen (GTK_WINDOW (window), screen);
+	}
 
 	return window;
 }
@@ -1030,9 +1074,26 @@ gedit_app_set_window_title (GeditApp    *app,
                             GeditWindow *window,
                             const gchar *title)
 {
+	g_return_if_fail (GEDIT_IS_APP (app));
+	g_return_if_fail (GEDIT_IS_WINDOW (window));
+
 	GEDIT_APP_GET_CLASS (app)->set_window_title (app, window, title);
 }
 
+gboolean
+gedit_app_process_window_event (GeditApp    *app,
+                                GeditWindow *window,
+                                GdkEvent    *event)
+{
+	g_return_val_if_fail (GEDIT_IS_APP (app), FALSE);
+	g_return_val_if_fail (GEDIT_IS_WINDOW (window), FALSE);
+
+	if (GEDIT_APP_GET_CLASS (app)->process_window_event)
+	{
+		GEDIT_APP_GET_CLASS (app)->process_window_event (app, window, event);
+	}
+}
+
 static void
 app_lockdown_changed (GeditApp *app)
 {
diff --git a/gedit/gedit-app.h b/gedit/gedit-app.h
index 4d2d2ff..988b135 100644
--- a/gedit/gedit-app.h
+++ b/gedit/gedit-app.h
@@ -72,7 +72,8 @@ struct _GeditAppClass
 {
 	GObjectClass parent_class;
 
-	gboolean (*last_window_destroyed)	(GeditApp    *app);
+	gboolean (*last_window_destroyed)	(GeditApp    *app,
+	                                         GeditWindow *window);
 
 	gboolean (*show_help)			(GeditApp    *app,
 	                                         GtkWindow   *parent,
@@ -86,6 +87,14 @@ struct _GeditAppClass
 	void (*set_window_title)		(GeditApp    *app,
 	                                         GeditWindow *window,
 	                                         const gchar *title);
+
+	void (*quit)                            (GeditApp    *app);
+
+	GeditWindow *(*create_window)		(GeditApp    *app);
+
+	gboolean (*process_window_event)	(GeditApp    *app,
+						 GeditWindow *window,
+						 GdkEvent    *event);
 };
 
 /*
@@ -132,6 +141,9 @@ gboolean	 gedit_app_show_help			(GeditApp    *app,
 void		 gedit_app_set_window_title		(GeditApp    *app,
                                                          GeditWindow *window,
                                                          const gchar *title);
+gboolean	gedit_app_process_window_event		(GeditApp    *app,
+							 GeditWindow *window,
+							 GdkEvent    *event);
 
 /*
  * Non exported functions
@@ -164,6 +176,7 @@ void			 _gedit_app_set_default_print_settings	(GeditApp         *app,
 								 GtkPrintSettings *settings);
 
 GObject			*_gedit_app_get_settings		(GeditApp  *app);
+void                     _gedit_app_quit                        (GeditApp  *app);
 
 G_END_DECLS
 
diff --git a/gedit/gedit-dirs.c b/gedit/gedit-dirs.c
index 353fc59..87eb5df 100644
--- a/gedit/gedit-dirs.c
+++ b/gedit/gedit-dirs.c
@@ -27,7 +27,7 @@
 #include "gedit-dirs.h"
 
 #ifdef OS_OSX
-#include <ige-mac-bundle.h>
+#include <gtkosxapplication.h>
 #endif
 
 static gchar *user_config_dir        = NULL;
@@ -63,17 +63,18 @@ gedit_dirs_init ()
 	g_free (win32_dir);
 #else /* !G_OS_WIN32 */
 #ifdef OS_OSX
-	IgeMacBundle *bundle = ige_mac_bundle_get_default ();
-
-	if (ige_mac_bundle_get_is_app_bundle (bundle))
+	if (quartz_application_get_bundle_id ())
 	{
-		const gchar *bundle_data_dir = ige_mac_bundle_get_datadir (bundle);
-		const gchar *bundle_resource_dir = ige_mac_bundle_get_resourcesdir (bundle);
+		const gchar *bundle_resource_dir = quartz_application_get_resource_path ();
 
-		gedit_data_dir = g_build_filename (bundle_data_dir,
+		gedit_data_dir = g_build_filename (bundle_resource_dir,
+						   "share",
 						   "gedit",
 						   NULL);
-		gedit_locale_dir = g_strdup (ige_mac_bundle_get_localedir (bundle));
+		gedit_locale_dir = g_build_filename (bundle_resource_dir,
+						     "share",
+						     "locale",
+						     NULL);
 		gedit_lib_dir = g_build_filename (bundle_resource_dir,
 						  "lib",
 						  "gedit",
diff --git a/gedit/gedit-window-private.h b/gedit/gedit-window-private.h
index aaef03b..a092495 100644
--- a/gedit/gedit-window-private.h
+++ b/gedit/gedit-window-private.h
@@ -39,7 +39,7 @@
 #include "gedit-multi-notebook.h"
 
 #ifdef OS_OSX
-#include <ige-mac-integration.h>
+#include <gtkosxapplication.h>
 #endif
 
 G_BEGIN_DECLS
@@ -63,7 +63,7 @@ struct _GeditWindowPrivate
 	GtkWidget      *tab_width_combo;
 	GtkWidget      *language_combo;
 	
-	GeditMessageBus *message_bus;	
+	GeditMessageBus *message_bus;
 	PeasExtensionSet *extensions;
 
 	/* Widgets for fullscreen mode */
@@ -121,7 +121,7 @@ struct _GeditWindowPrivate
 	GFile          *default_location;
 
 #ifdef OS_OSX
-	IgeMacMenuGroup *mac_menu_group;
+	GtkOSXApplicationMenuGroup *mac_menu_group;
 #endif
 
 	gboolean        removing_tabs : 1;
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 1b396be..758473b 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -61,10 +61,6 @@
 #include "gedit-settings.h"
 #include "gedit-marshal.h"
 
-#ifdef OS_OSX
-#include "osx/gedit-osx.h"
-#endif
-
 #define LANGUAGE_NONE (const gchar *)"LangNone"
 #define GEDIT_UIFILE "gedit-ui.xml"
 #define TAB_WIDTH_DATA "GeditWindowTabWidthData"
@@ -163,60 +159,6 @@ save_panels_state (GeditWindow *window)
 	g_settings_apply (window->priv->window_settings);
 }
 
-#ifdef OS_OSX
-static GtkMenuItem *
-ui_manager_menu_item (GtkUIManager *uimanager,
-                      const gchar  *path)
-{
-	return GTK_MENU_ITEM (gtk_ui_manager_get_widget (uimanager, path));
-}
-
-static void
-add_mac_root_menu (GeditWindow *window)
-{
-	if (window->priv->mac_menu_group != NULL)
-	{
-		return;
-	}
-	
-	window->priv->mac_menu_group = ige_mac_menu_add_app_menu_group ();
-
-	ige_mac_menu_add_app_menu_item (window->priv->mac_menu_group,
-	                                ui_manager_menu_item (window->priv->manager, "/ui/MenuBar/HelpMenu/HelpAboutMenu"),
-	                                NULL);
-}
-
-static void
-remove_mac_root_menu (GeditWindow *window)
-{
-	if (window->priv->mac_menu_group == NULL)
-	{
-		return;
-	}
-	
-	ige_mac_menu_remove_app_menu_group (window->priv->mac_menu_group);
-	window->priv->mac_menu_group = NULL;
-}
-
-static gboolean
-gedit_window_focus_in_event (GtkWidget     *widget,
-                             GdkEventFocus *event)
-{
-	add_mac_root_menu (GEDIT_WINDOW (widget));
-
-	return GTK_WIDGET_CLASS (gedit_window_parent_class)->focus_in_event (widget, event);
-}
-
-static gboolean
-gedit_window_focus_out_event (GtkWidget     *widget,
-                              GdkEventFocus *event)
-{
-	remove_mac_root_menu (GEDIT_WINDOW (widget));
-
-	return GTK_WIDGET_CLASS (gedit_window_parent_class)->focus_out_event (widget, event);
-}
-#endif
-
 static void
 save_window_state (GtkWidget *widget)
 {
@@ -354,10 +296,6 @@ gedit_window_dispose (GObject *object)
 	 */
 	peas_engine_garbage_collect (PEAS_ENGINE (gedit_plugins_engine_get_default ()));
 
-#ifdef OS_OSX
-	remove_mac_root_menu (window);
-#endif
-
 	G_OBJECT_CLASS (gedit_window_parent_class)->dispose (object);
 }
 
@@ -427,25 +365,41 @@ gedit_window_key_press_event (GtkWidget   *widget,
 			      GdkEventKey *event)
 {
 	static gpointer grand_parent_class = NULL;
+	
 	GtkWindow *window = GTK_WINDOW (widget);
 	gboolean handled = FALSE;
 
 	if (grand_parent_class == NULL)
+	{
 		grand_parent_class = g_type_class_peek_parent (gedit_window_parent_class);
+	}
 
 	/* handle focus widget key events */
 	if (!handled)
+	{
 		handled = gtk_window_propagate_key_event (window, event);
+	}
 
 	/* handle mnemonics and accelerators */
 	if (!handled)
+	{
 		handled = gtk_window_activate_key (window, event);
+	}
 
-	/* Chain up, invokes binding set */
+	/* Chain up, invokes binding set on window */
 	if (!handled)
+	{
 		handled = GTK_WIDGET_CLASS (grand_parent_class)->key_press_event (widget, event);
+	}
 
-	return handled;
+	if (!handled)
+	{
+		return gedit_app_process_window_event (gedit_app_get_default (),
+		                                       GEDIT_WINDOW (widget),
+		                                       (GdkEvent *)event);
+	}
+	
+	return TRUE;
 }
 
 static void
@@ -471,11 +425,6 @@ gedit_window_class_init (GeditWindowClass *klass)
 	widget_class->configure_event = gedit_window_configure_event;
 	widget_class->key_press_event = gedit_window_key_press_event;
 
-#ifdef OS_OSX
-	widget_class->focus_in_event = gedit_window_focus_in_event;
-	widget_class->focus_out_event = gedit_window_focus_out_event;
-#endif
-
 	signals[TAB_ADDED] =
 		g_signal_new ("tab-added",
 			      G_OBJECT_CLASS_TYPE (object_class),
@@ -1882,8 +1831,15 @@ update_documents_list_menu_idle (GeditWindow *window)
 			if (active_notebook)
 			{
 				gchar *accel;
+				gchar const *mod;
 
-				accel = (j < 10) ? g_strdup_printf ("<alt>%d", (j + 1) % 10) : NULL;
+#ifndef OS_OSX
+				mod = "alt";
+#else
+				mod = "meta";
+#endif
+
+				accel = (j < 10) ? g_strdup_printf ("<%s>%d", mod, (j + 1) % 10) : NULL;
 
 				gtk_action_group_add_action_with_accel (p->documents_list_action_group,
 									GTK_ACTION (action),
@@ -4102,27 +4058,6 @@ check_window_is_active (GeditWindow *window,
 	}
 }
 
-#ifdef OS_OSX
-static void
-setup_mac_menu (GeditWindow *window)
-{
-	GtkAction *action;
-
-	gtk_widget_hide (window->priv->menubar);
-	action = gtk_ui_manager_get_action (window->priv->manager, "/ui/MenuBar/HelpMenu/HelpAboutMenu");
-
-	gtk_action_set_label (action, _("About gedit"));
-
-	ige_mac_menu_set_menu_bar (GTK_MENU_SHELL (window->priv->menubar));
-	ige_mac_menu_set_quit_menu_item (ui_manager_menu_item (window->priv->manager, "/ui/MenuBar/FileMenu/FileQuitMenu"));
-
-	ige_mac_menu_set_preferences_menu_item (ui_manager_menu_item (window->priv->manager, "/ui/MenuBar/EditMenu/EditPreferencesMenu"));
-	
-	add_mac_root_menu (window);
-	ige_mac_menu_connect_window_key_handler (GTK_WINDOW (window));
-}
-#endif
-
 static void
 extension_added (PeasExtensionSet *extensions,
 		 PeasPluginInfo   *info,
@@ -4346,10 +4281,6 @@ gedit_window_init (GeditWindow *window)
 	/* When we initiate we have 1 notebook and 1 tab */
 	update_sensitivity_according_to_open_tabs (window, 1, 1);
 
-#ifdef OS_OSX
-	setup_mac_menu (window);
-#endif
-
 	gedit_debug_message (DEBUG_WINDOW, "END");
 }
 
diff --git a/osx/README b/osx/README
new file mode 100644
index 0000000..d666391
--- /dev/null
+++ b/osx/README
@@ -0,0 +1,71 @@
+This is a guide to building gedit on OS X. This guide assumes that you are
+already familiar with building gtk+ software on OS X (natively) using jhbuild.
+Please make sure to read http://sourceforge.net/apps/trac/gtk-osx/wiki/Build
+before proceeding.
+
+Note: Terminal commands are preceded by dollar signs.
+
+1) Building gedit for OS X
+=============================================================================
+
+Get and install the gtk-osx-build-setup.sh from:
+http://git.gnome.org/browse/gtk-osx/plain/gtk-osx-build-setup.sh
+
+$ curl -O http://git.gnome.org/browse/gtk-osx/plain/gtk-osx-build-setup.sh
+$ sh gtk-osx-build-setup.sh
+
+Make sure that you are not conflicting anything from fink/macports. If you
+are using fink/macports, you can add the following to your ~/.bashrc to
+remove any PATHS related to fink/macports when using jhbuild:
+
+    # Remove fink/macports path from PATH and store in local var origpath
+    origpath=$(echo $PATH | sed -E -e 's;:?/opt/local/bin;;' -e 's;:?/opt/local/sbin;;')
+
+    # Alias jhbuild
+    alias jhbuild="PATH=$origpath:$HOME/.local/bin jhbuild"
+
+For gedit we need to modify some configuration for jhbuild. A special
+jhbuildrc is provided in the gedit source (osx/jhbuild/jhbuildrc-gedit). Copy
+this file to your home.
+
+$ curl -o ~/.jhbuildrc-gedit http://git.gnome.org/browse/gedit/plain/osx/jhbuild/jhbuildrc-gedit
+
+gedit provides a custom moduleset for jhbuild that you can use to built gedit. This moduleset is specified in jhbuildrc-gedit (together with some other
+configurations for jhbuild specific for gedit).
+
+To use the special gedit jhbuild configuration you will have to set the
+environment variables JHB=gedit and GEDIT_SDK=<sdk>. Where <sdk> is the SDK
+version you want to built for (i.e. 10.4, 10.5, 10.6, etc.).
+
+IMPORTANT: jhbuildrc-gedit will call setup_sdk for the right sdk. However, by
+default setup_sdk is already called from ~/.jhbuildrc-custom. Please make sure
+to comment out the call to setup_sdk in ~/.jhbuildrc-custom!
+
+Finally we are ready to built gedit:
+
+$ JHB=gedit GEDIT_SDK=10.6 jhbuild bootstrap --ignore-system
+$ JHB=gedit GEDIT_SDK=10.6 jhbuild build gedit-meta
+
+Note that it's perfectly possible that something might fail during the built,
+as the OS X (quartz) port of gedit, gtk+, glib etc. is under development.
+Please feel free to drop by on IRC or send an e-mail to the gedit mailing list
+(or gtk-osx-users mailing list) if you are not able to make things work.
+
+Packages will be downloaded in ~/gedit/pkgs. Sources are extracted in ~/gedit/<sdk>/source and installation of the binaries is in ~/gedit/<sdk>/inst.
+ 
+
+2) Making a gedit bundle
+=============================================================================
+
+You can make a gedit bundle (i.e. a gedit.app) with a script provided by
+gedit. Note that you have to execute script from within the jhbuild shell:
+
+$ JHB=gedit GEDIT_SDK=10.6 jhbuild shell
+
+Then, go to the osx directory in the gedit source and execute:
+
+$ sh makebundle.sh
+
+If succeeded, you will now have a gedit.app bundle in the osx directory.
+Similarly, if you want to built the final dmg image, you can use the script
+makedmg.sh
\ No newline at end of file
diff --git a/osx/gedit.bundle b/osx/gedit.bundle
index 0d83b77..8bab9cf 100644
--- a/osx/gedit.bundle
+++ b/osx/gedit.bundle
@@ -12,6 +12,7 @@
          defined by jhbuild, so it you are not using jhbuild you can
          either define your own or just hardcode the path here.
     -->
+    <gtk>gtk+-3.0</gtk>
     <prefix name="default">${env:JHBUILD_PREFIX}</prefix>
 
     <!-- The project directory is the default location of the created
@@ -41,70 +42,95 @@
 
   <main-binary>${prefix}/bin/gedit</main-binary>
 
-  <!-- Copy in GTK+ modules -->
-  <binary>${prefix}/lib/gtk-2.0/${pkg:gtk+-2.0:gtk_binary_version}/loaders/*.so</binary>
-
-  <!-- Copy in GTK+ theme engines -->
-  <binary>${prefix}/lib/gtk-2.0/${pkg:gtk+-2.0:gtk_binary_version}/engines/*.so</binary>
-
   <!-- Copy in GTK+ printer backends -->
-  <binary>${prefix}/lib/gtk-2.0/${pkg:gtk+-2.0:gtk_binary_version}/printbackends/*.so</binary>
+  <binary>${prefix}/lib/gtk-3.0/${pkg:gtk+-3.0:gtk_binary_version}/printbackends/*.so</binary>
 
   <!-- Copy in GTK+ im modules -->
-  <binary>${prefix}/lib/gtk-2.0/${pkg:gtk+-2.0:gtk_binary_version}/immodules/*.so</binary>
+  <binary>${prefix}/lib/gtk-3.0/${pkg:gtk+-3.0:gtk_binary_version}/immodules/*.so</binary>
+
+  <!-- Copy in GTK+ theming engines -->
+  <binary>${prefix}/lib/gtk-3.0/${pkg:gtk+-3.0:gtk_binary_version}/theming-engines/*.so</binary>
+
+  <!-- Copy in pango modules -->
+  <binary>${prefix}/lib/pango/${pkg:pango:pango_module_version}/modules/*.so</binary>
+
+  <!-- Copy in gdk pixbuf loader modules -->
+  <binary>${prefix}/lib/gdk-pixbuf-2.0/${pkg:gdk-pixbuf-2.0:gdk_pixbuf_binary_version}/loaders/*.so</binary>
 
   <!-- Copy in plugins and plugin loaders -->
-  <binary>${prefix}/lib/gedit-2/plugin-loaders/*.so</binary>
-  <binary>${prefix}/lib/gedit-2/plugins/*.so</binary>
-
-  <!-- Python gtk binaries -->
-  <binary>${prefix}/lib/python2.5/site-packages/*.so</binary>
-  <binary>${prefix}/lib/python2.5/site-packages/cairo/*.so</binary>
-  <binary>${prefix}/lib/python2.5/site-packages/gtk-2.0/*.so</binary>
-  <binary>${prefix}/lib/python2.5/site-packages/gtk-2.0/gio/*.so</binary>
-  <binary>${prefix}/lib/python2.5/site-packages/gtk-2.0/glib/*.so</binary>
-  <binary>${prefix}/lib/python2.5/site-packages/gtk-2.0/gobject/*.so</binary>
-  <binary>${prefix}/lib/python2.5/site-packages/gtk-2.0/gtk/*.so</binary>
-
-  <!-- Python others -->
-  <data>${prefix}/lib/python2.5/site-packages</data>
-
-  <!-- gconf -->
-  <data>${prefix}/etc/gconf</data>
-  <data>${prefix}/libexec/gconfd-2</data>
-  <data>${prefix}/libexec/gedit-2</data>
-  <data>${prefix}/lib/GConf</data>
+  <binary>${prefix}/lib/libpeas-1.0/loaders/*.so</binary>
+  <binary>${prefix}/lib/gedit/plugins/*.so</binary>
 
-  <!-- gtksourceview -->
-  <data>${prefix}/share/gtksourceview-2.0</data>
+  <!-- Take the applespell enchant provider -->
+  <binary>${prefix}/lib/enchant/libenchant_applespell.so</binary>
+
+  <!-- Copy in gio modules -->
+  <binary>${prefix}/lib/gio/modules/*.so</binary>
+
+  <!-- Copy in girepository typelibs -->
+  <data>${prefix}/lib/girepository-1.0</data>
+
+  <!-- DBUS -->
+  <binary>${prefix}/bin/dbus-*</binary>
+  <data>${prefix}/etc/dbus-1</data>
+  <binary>${prefix}/libexec/dbus-daemon-launch-helper</binary>
 
-  <!-- gtkengines -->
-  <data>${prefix}/share/gtk-engines</data>
+  <!-- Copy in peas modules -->
+  <binary>${prefix}/lib/libpeas-1.0/loaders/*.so</binary>
+
+  <!-- python -->
+  <binary>${prefix}/lib/python2.7/site-packages/cairo/*.so</binary>
+  <binary>${prefix}/lib/python2.7/site-packages/gi/*.so</binary>
+  <binary>${prefix}/lib/python2.7/site-packages/gi/_glib/*.so</binary>
+  <binary>${prefix}/lib/python2.7/site-packages/gi/_gobject/*.so</binary>
+  <binary>${prefix}/lib/python2.7/site-packages/libxml2mod.so</binary>
+
+  <data>${prefix}/lib/python2.7/site-packages/cairo</data>
+  <data>${prefix}/lib/python2.7/site-packages/gi</data>
+  <data>${prefix}/lib/python2.7/site-packages/libxml2.py</data>
+
+  <!-- GTK+3 data -->
+  <data>${prefix}/etc/gtk-3.0/*</data>
+
+  <!-- dconf -->
+  <binary>${prefix}/libexec/dconf-service</binary>
+
+  <!-- gvfs -->
+  <binary>${prefix}/libexec/gvfsd-*</binary>
+  <data>${prefix}/share/gvfs</data>
+
+  <!-- gtksourceview -->
+  <data>${prefix}/share/gtksourceview-3.0</data>
 
   <!-- gedit -->
-  <data>${prefix}/share/gedit-2</data>
-  <data>${prefix}/lib/gedit-2</data>
+  <data>${prefix}/share/gedit</data>
+  <data>${prefix}/lib/gedit</data>
 
   <!-- locale (TODO: trim) -->
   <data>${prefix}/share/locale</data>
   <data>${prefix}/lib/charset.alias</data>
 
-  <!-- Themes (TODO: trim files) -->
-  <data>${prefix}/share/themes</data>
+  <!-- mime database -->
+  <data>${prefix}/share/mime</data>
+
+  <!-- Themes -->
+  <data>${prefix}/share/themes/Default</data>
+  <data>${prefix}/share/themes/Adwaita</data>
 
   <!-- App icon -->
   <data dest="${bundle}/Contents/Resources">${project}/gedit.icns</data>
   <data dest="${bundle}/Contents/Resources">${project}/geditdoc.icns</data>
 
-  <!-- Custom theme settings -->
-  <data dest="${bundle}/Contents/Resources/etc/gtk-2.0/gtkrc">${project}/gtkrc</data>
-  <data dest="${bundle}/Contents/Resources/share/themes/GeditOSX/gtk-2.0-key/gtkrc">${project}/gtkrc.key.osx</data>
+  <!-- gsettings schema -->
+  <data>${prefix}/share/glib-2.0/schemas/gschemas.compiled</data>
+
+  <data dest="${bundle}/Contents/Resources/etc/gtk-3.0/settings.ini">${project}/settings.ini</data>
 
   <!-- Icon theme -->
-  <icon-theme icons="auto">Tango</icon-theme>
-  <data>${prefix}/share/icons/gnome/16x16/apps/system-file-manager.png</data>
+  <icon-theme icons="auto">gnome</icon-theme>
+  <!--<data>${prefix}/share/icons/gnome/16x16/apps/system-file-manager.png</data>
   <data>${prefix}/share/icons/gnome/22x22/apps/system-file-manager.png</data>
   <data>${prefix}/share/icons/gnome/24x24/apps/system-file-manager.png</data>
   <data>${prefix}/share/icons/gnome/32x32/apps/system-file-manager.png</data>
-  <data>${prefix}/share/icons/gnome/scalable/apps/system-file-manager.svg</data>
+  <data>${prefix}/share/icons/gnome/scalable/apps/system-file-manager.svg</data>-->
 </app-bundle>
diff --git a/osx/gedit.icns b/osx/gedit.icns
index ccd50be..9332db2 100644
Binary files a/osx/gedit.icns and b/osx/gedit.icns differ
diff --git a/osx/jhbuild/gedit.modules b/osx/jhbuild/gedit.modules
new file mode 100644
index 0000000..03c007e
--- /dev/null
+++ b/osx/jhbuild/gedit.modules
@@ -0,0 +1,320 @@
+<?xml version="1.0"?>
+<!DOCTYPE moduleset SYSTEM "moduleset.dtd">
+<?xml-stylesheet type="text/xsl" href="moduleset.xsl"?>
+<moduleset>
+  <include href="https://raw.github.com/jralls/gtk-osx-build/master/modulesets-stable/gtk-osx.modules"/>
+  <repository type="git" name="git.gnome.org"
+              href="git://git.gnome.org/"/>
+  <repository type="tarball" name="ftp.gnome.org" default="yes"
+              href="http://ftp.gnome.org/pub/GNOME/sources/"/>
+  <repository type="git" name="github" href="git://github.com/"/>
+  <repository type="git" name="githubjessevdk" href="git://github.com/jessevdk/"/>
+  <repository type="tarball" name="ftp.gnupg.org" href="ftp://ftp.gnupg.org/"; />
+  <repository type="tarball" name="ftp.gnu.org" href="ftp://ftp.gnu.org/gnu/"/>
+  <repository type="tarball" name="launchpad" href="http://edge.launchpad.net/"/>
+  <repository type="git" name="cairographics" 
+              href="git://anongit.freedesktop.org/git/"/>
+  <repository type="svn" name="libarchive" href="http://libarchive.googlecode.com/svn/trunk/"/>
+  <repository type="tarball" name="iso-codes"
+              href="http://pkg-isocodes.alioth.debian.org/downloads/"/>
+  <repository type="tarball" name="abisource/enchant"
+              href="http://www.abisource.com/downloads/enchant/"; />
+  <repository type="tarball" name="sourceware.org"
+                href="ftp://sourceware.org/pub/"/>
+  <autotools id="iso-codes" autogen-sh="configure" >
+    <branch repo="iso-codes" version="3.32"
+            module="iso-codes-3.32.tar.bz2"/>
+
+  </autotools>
+
+   <autotools id="pygobject3" autogen-sh="configure" >
+    <branch version="3.0.3" module="pygobject/3.0/pygobject-3.0.3.tar.xz"
+            hash="sha256:088b1e682be02a969a0a3f2e650e4fe72bb3638ee8229819841d3e8f4cde2d7c"/>
+    <dependencies>
+      <dep package="meta-gtk-osx-gtk3"/>
+    </dependencies>
+    <after>
+      <dep package="python"/>
+    </after>
+  </autotools>
+
+  <autotools id="gtksourceview" autogenargs="DATADIRNAME=share">
+    <branch module="gtksourceview/3.2/gtksourceview-3.2.3.tar.bz2"
+            version="3.2.3"
+            hash="sha256:b6a62a41d84ec2f6264a2b6126950ca1b49488b4cd084a894c39535f60f95f6c"/>
+    <dependencies>
+      <dep package="intltool"/>
+      <dep package="libxml2"/>
+      <dep package="shared-mime-info"/>
+      <dep package="gtk+-3.0"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="gtk+-3.0" autogen-sh="configure"
+             autogenargs="--enable-quartz-backend">
+    <branch module="gtk+/3.2/gtk+-3.2.3.tar.xz" version="3.2.3"
+            hash="sha256:e2cf20f2510ebbc7be122a1a33dd1f472a7d06aaf16b4f2a63eb048cd9141d3d">
+      <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0001-Bug-571582-GtkSelection-implementation-for-quartz.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gedit/plain/osx/jhbuild/patches/gtk-settings-ini-xdg.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gedit/plain/osx/jhbuild/patches/gtk-dnd-offscreen.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gedit/plain/osx/jhbuild/patches/gtk-introspection.patch"; strip="1"/>
+    </branch>
+    <dependencies>
+      <dep package="glib-gtk3"/>
+      <dep package="pango-gtk3"/>
+      <dep package="atk"/>
+      <dep package="gdk-pixbuf"/>
+      <dep package="gobject-introspection-gtk3"/>
+    </dependencies>
+    <after>
+      <dep package="meta-gtk-osx-bootstrap"/>
+    </after>
+  </autotools>
+
+  <autotools id="pango-gtk3"  autogen-sh="configure"
+             autogenargs="--without-x"
+             makeargs="-k -C modules; make">
+    <branch version="1.29.4" module="pango/1.29/pango-1.29.4.tar.bz2"
+            hash="sha256:f15deecaecf1e9dcb7db0e4947d12b5bcff112586434f8d30a5afd750747ff2b">
+      <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/pangoatsui-fontname.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0001-Make-ATSUI-backend-compile-again.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gedit/plain/osx/jhbuild/patches/pango-coretext-invisible.patch"; strip="1"/>
+    </branch>
+    <dependencies>
+      <dep package="cairo"/>
+      <dep package="fontconfig"/>
+      <dep package="glib-gtk3"/>
+      <dep package="gobject-introspection-gtk3"/>
+    </dependencies>
+    <after>
+      <dep package="meta-gtk-osx-bootstrap"/>
+    </after>
+  </autotools>
+
+  <autotools id="libpeas" autogenargs="DATADIRNAME=share">
+    <branch module="libpeas/1.2/libpeas-1.2.0.tar.bz2"
+            version="1.2.0"
+            hash="sha256:d4a4cf804d59e602ff73b33ba41d37d8c1f9bb3ce7f0533d9181d96d88e4a508">
+      <patch file="http://git.gnome.org/browse/gedit/plain/osx/jhbuild/patches/libpeas-pygobject-api.patch"; strip="1"/>
+    </branch>
+    <dependencies>
+      <dep package="meta-gtk-osx-bootstrap"/>
+      <dep package="meta-gtk-osx-gtk3"/>
+      <dep package="pycairo-python2.6"/>
+      <dep package="pygobject3"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="dconf">
+    <branch module="dconf/0.10/dconf-0.10.0.tar.bz2"
+            version="0.10.0"
+            hash="sha256:4b034e9e5560ab703f60bb2b6dc1ada7856416660af7dd1207c2c3ab9c9d533b">
+      <patch file="http://git.gnome.org/browse/gedit/plain/osx/jhbuild/patches/dconf-dylib.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gedit/plain/osx/jhbuild/patches/dconf-echo-escape.patch"; strip="1"/>
+    </branch>
+    <dependencies>
+      <dep package="meta-gtk-osx-bootstrap"/>
+      <dep package="glib-gtk3"/>
+      <dep package="vala"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="vala">
+    <branch module="vala/0.14/vala-0.14.0.tar.bz2"
+            version="0.14.0"
+            hash="sha256:4cbca602e2e2a09803ae33fd7324219bc2c611db5a62a52e733e7d8806acb6f5">
+    </branch>
+    <dependencies>
+    </dependencies>
+  </autotools>
+
+  <autotools id="gvfs">
+    <branch module="gvfs/1.10/gvfs-1.10.1.tar.bz2"
+            version="1.10.1"
+            hash="sha256:417a15e53fc20c2e1a1de5ea5903430b0ac2e98178d2fcbcfc8fba3082e801ea">
+    </branch>
+    <dependencies>
+      <dep package="meta-gtk-osx-bootstrap"/>
+      <dep package="glib-gtk3"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="gsettings-desktop-schemas">
+    <branch module="gsettings-desktop-schemas/3.2/gsettings-desktop-schemas-3.2.0.tar.bz2"
+            version="3.2.0"
+            hash="sha256:4a99260fddc4c9ae797c61d55d37e893b0c26261d86676a9f26b6b8ab5a99d3c">
+    </branch>
+    <dependencies>
+      <dep package="meta-gtk-osx-bootstrap"/>
+      <dep package="glib-gtk3"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="gnome-themes-standard">
+    <branch module="gnome-themes-standard/3.2/gnome-themes-standard-3.2.1.tar.bz2"
+            version="3.2.1"
+            hash="sha256:e0acbcbf5663c14a324999a4ff8ca5b88253d4e5dea6cd1aef428f3bb09e6476">
+    </branch>
+    <dependencies>
+      <dep package="meta-gtk-osx-bootstrap"/>
+      <dep package="meta-gtk-osx-gtk3"/>
+      <dep package="librsvg"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="gnome-icon-theme-extras">
+    <branch module="gnome-icon-theme-extras/3.0/gnome-icon-theme-extras-3.0.0.tar.bz2"
+            version="3.0.0"
+            hash="sha256:b9e4af7cb9cce3123da257f70223ee3fd78e0963a040386aaef449b111f862eb">
+    </branch>
+    <dependencies>
+      <dep package="meta-gtk-osx-bootstrap"/>
+      <dep package="glib-gtk3"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="gnome-icon-theme-symbolic">
+    <branch module="gnome-icon-theme-symbolic/3.2/gnome-icon-theme-symbolic-3.2.1.tar.bz2"
+            version="3.2.1"
+            hash="sha256:7943659c8e2174cdc3c5fa33d3294de5d209bf45bb040462945713f012d2c001">
+    </branch>
+    <dependencies>
+      <dep package="meta-gtk-osx-bootstrap"/>
+      <dep package="glib-gtk3"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="gedit-plugins" autogenargs="DATADIRNAME=share">
+    <branch module="gedit-plugins/3.2/gedit-plugins-3.2.1.tar.bz2"
+            version="3.2.1"
+            hash="sha256:8f6b5bc88ca61d8f0bc4dd54b2dc82473acfefd90453e4d4ffc3ca88d4182f4d">
+    </branch>
+    <dependencies>
+      <dep package="meta-gtk-osx-bootstrap"/>
+      <dep package="gedit"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="libsoup">
+    <branch module="libsoup/2.4/libsoup-2.4.1.tar.bz2"
+            version="2.4.1"
+            hash="sha256:774094746748fb0c8985210de0994accdc7095c222fba42c5623e2137443b6cd">
+    </branch>
+    <dependencies>
+      <dep package="glib-gtk3"/>
+      <dep package="libxml2"/>
+      <dep package="libgnome-keyring"/>
+      <dep package="glib-networking"/>
+      <dep package="gobject-introspection-gtk3"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="gobject-introspection-gtk3">
+    <branch module="gobject-introspection/1.30/gobject-introspection-1.30.0.tar.bz2"
+            version="1.30.0"
+            hash="sha256:72f5b8886d23d4bfff1f9824df00831b48b7ebb98d35a50a8f322cb7ff037d12">
+      <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/girscanner-objc.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0001-scanner-split-CC-environment-variable.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gedit/plain/osx/jhbuild/patches/gobject-introspection-casecmp.patch"; strip="1"/>
+    </branch>
+    <dependencies>
+      <dep package="glib-gtk3"/>
+      <dep package="cairo"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="enchant" autogen-sh="autogen.sh">
+    <branch module="1.6.0/enchant-1.6.0.tar.gz" version="1.6.0"
+	    repo="abisource/enchant">
+	  <patch file="http://git.gnome.org/browse/gedit/plain/osx/jhbuild/patches/enchant-applespell.patch"; strip="1"/>
+	</branch>
+    <dependencies>
+      <dep package="glib-gtk3"/>
+    </dependencies>
+  </autotools>
+
+  <tarball id="shared-mime-info" supports-non-srcdir-builds="no" version="0.71">
+    <source href="http://people.freedesktop.org/~hadess/shared-mime-info-0.71.tar.bz2";
+            hash="sha256:1d8f97f17de77ae0d8a3a4ef357280ef444da87f4ce19170392712d0c2f6d04f"
+            md5sum="0a90508234d415f761a79fbffdff74f4" size="493216"/>
+    <dependencies>
+      <dep package="intltool"/>
+      <dep package="libxml2"/>
+      <dep package="glib-gtk3"/>
+    </dependencies>
+  </tarball>
+
+  <autotools id="libgnome-keyring">
+    <branch module="libgnome-keyring/3.2/libgnome-keyring-3.2.2.tar.bz2"
+            version="3.2.2"
+            hash="sha256:5332e1e428aa7c1cece68fb37799681df30eeb8a73d96c354969d401fdfeddd7">
+    </branch>
+    <dependencies>
+      <dep package="intltool"/>
+      <dep package="dbus"/>
+      <dep package="libgcrypt"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="libgcrypt" autogen-sh="configure" autogenargs="--disable-asm --disable-aesni-support">
+    <branch repo='ftp.gnupg.org' version='1.5.0'
+	    module='gcrypt/libgcrypt/libgcrypt-1.5.0.tar.bz2'/>
+    <dependencies>
+      <dep package="libgpg-error" />
+    </dependencies>
+  </autotools>
+
+  <autotools id="gedit" autogenargs="DATADIRNAME=share">
+    <branch repo="githubjessevdk" module="gedit" revision="gnome-3-2"/>
+    <dependencies>
+      <dep package="meta-gtk-osx-bootstrap"/>
+      <dep package="meta-gtk-osx-gtk3"/>
+      <dep package="libpeas"/>
+      <dep package="gtksourceview"/>
+      <dep package="libsoup"/>
+      <dep package="enchant"/>
+      <dep package="dconf"/>
+      <dep package="gvfs"/>
+      <dep package="gsettings-desktop-schemas"/>
+      <dep package="gnome-themes-standard"/>
+      <dep package="icon-naming-utils"/>
+      <dep package="gnome-icon-theme"/>
+      <dep package="gnome-icon-theme-extras"/>
+      <dep package="gnome-icon-theme-symbolic"/>
+      <dep package="iso-codes"/>
+    </dependencies>
+  </autotools>
+
+  <autotools id="libffi" autogenargs="--disable-builddir">
+    <branch module="libffi/libffi-3.0.10.tar.gz" repo="sourceware.org"
+            version="3.0.10" checkoutdir="atgreen-libffi-873d687">
+      <patch file="http://git.gnome.org/browse/gedit/plain/osx/jhbuild/patches/ffi-darwin11.patch"; strip="1"/>
+    </branch>
+  </autotools>
+
+  <autotools id="gtk-mac-integration" autogen-sh="configure"
+             autogenargs="--disable-python">
+    <branch module="gtk-mac-integration/1.0/gtk-mac-integration-1.0.1.tar.bz2"
+            version="1.0.1"
+            hash="sha256:417773d32be5304839f6f917a6ce4637d9a642829105ce8f9527f663830b8089">
+      <patch file="http://git.gnome.org/browse/gedit/plain/osx/jhbuild/patches/mac-integration-open-files.patch"; strip="1"/>
+    </branch>
+    <dependencies>
+    </dependencies>
+    <after>
+      <dep package="gtk+-3.0"/>
+      <dep package="meta-gtk-osx-bootstrap"/>
+    </after>
+  </autotools>
+
+  <metamodule id="gedit-meta">
+    <dependencies>
+      <dep package="python"/>
+      <dep package="libxml2"/>
+      <dep package="gedit"/>
+      <dep package="gedit-plugins"/>
+    </dependencies>
+  </metamodule>
+</moduleset>
+
+<!-- vi:ex:ts=2:et -->
diff --git a/osx/jhbuild/jhbuildrc-gedit b/osx/jhbuild/jhbuildrc-gedit
new file mode 100644
index 0000000..42c1147
--- /dev/null
+++ b/osx/jhbuild/jhbuildrc-gedit
@@ -0,0 +1,37 @@
+# -*- mode: python -*-
+
+import sys
+
+_gsdk = os.environ.get('GEDIT_SDK', None)
+
+if not _gsdk:
+    sys.stderr.write("No GEDIT_SDK environment given. Please provide 10.x\n")
+    sys.exit(1)
+
+_sdkversion = _gsdk
+_architecture = _default_arch
+
+if _gsdk == '10.4':
+    _sdkversion = "10.4u"
+    _architecture = "i386"
+else:
+    skip.append("python")
+
+checkoutroot = os.path.expanduser("~/gedit/" + _gsdk + "/source")
+prefix = os.path.expanduser("~/gedit/" + _gsdk + "/inst")
+tarballdir = os.path.expanduser("~/gedit" + _gsdk + "/pkgs")
+
+# Main setup
+setup_sdk(target=_gsdk, sdk_version=_sdkversion, architectures=[_architecture])
+
+# Set OBJCFLAGS
+_sdkdir = get_sdkdir(make_sdk_name(_sdkversion))
+
+environ_prepend("OBJCFLAGS", "-I" + _sdkdir + "/usr/include")
+environ_append("OBJCFLAGS", "-isysroot " + _sdkdir)
+environ_prepend("OBJCFLAGS", "-arch " + _architecture)
+environ_append("OBJCFLAGS", "-mmacosx-version-min=" + _gsdk)
+
+# Main module set
+moduleset = "http://git.gnome.org/browse/gedit/plain/osx/jhbuild/gedit.modules";
+
diff --git a/osx/jhbuild/patches/dconf-dylib.patch b/osx/jhbuild/patches/dconf-dylib.patch
new file mode 100644
index 0000000..177fce7
--- /dev/null
+++ b/osx/jhbuild/patches/dconf-dylib.patch
@@ -0,0 +1,126 @@
+diff --git a/bin/Makefile.am b/bin/Makefile.am
+index d3252cc..a832d5a 100644
+--- a/bin/Makefile.am
++++ b/bin/Makefile.am
+@@ -5,7 +5,7 @@ INCLUDES = -I$(top_srcdir)/common -I$(top_srcdir)/engine -I$(top_srcdir)/client
+ bin_PROGRAMS = dconf
+ 
+ dconf_VALAFLAGS = --vapidir ../client --pkg=gio-2.0 --pkg=posix --pkg=dconf
+-dconf_LDADD = $(gio_LIBS) ../client/libdconf.so.0
++dconf_LDADD = $(gio_LIBS) ../client/libdconf.dylib
+ dconf_SOURCES = dconf.vala dconf-update.vala dconf-dump.vala ../gvdb/gvdb-builder.c gvdb.vapi fixes.vapi
+ 
+ completiondir = $(sysconfdir)/bash_completion.d
+diff --git a/client/Makefile.am b/client/Makefile.am
+index a6c9212..3700c69 100644
+--- a/client/Makefile.am
++++ b/client/Makefile.am
+@@ -3,36 +3,24 @@ CFLAGS += -Wno-error
+ INCLUDES = -I$(top_srcdir)/common -I$(top_srcdir)/gvdb -I$(top_srcdir)/engine $(gio_CFLAGS)
+ 
+ shlibdir=$(libdir)
+-shlib_PROGRAMS = libdconf.so.0.0.0
+-nodist_noinst_DATA = libdconf.so.0 libdconf.so
+-
+-libdconf.so.0 libdconf.so: libdconf.so.0.0.0
+-	$(AM_V_GEN) ln -fs libdconf.so.0.0.0 $@
+-
+-install-data-hook:
+-	ln -fs libdconf.so.0.0.0 $(DESTDIR)$(shlibdir)/libdconf.so.0
+-	ln -fs libdconf.so.0.0.0 $(DESTDIR)$(shlibdir)/libdconf.so
+-
+-uninstall-hook:
+-	rm -f $(DESTDIR)$(shlibdir)/libdconf.so.0
+-	rm -f $(DESTDIR)$(shlibdir)/libdconf.so
++shlib_PROGRAMS = libdconf.dylib
+ 
+ dconfinclude_HEADERS = \
+ 	dconf-client.h	\
+ 	dconf.h
+ 
+-libdconf_so_0_0_0_LDADD = $(gio_LIBS)
+-libdconf_so_0_0_0_LDFLAGS = -shared -Wl,-soname=libdconf.so.0
+-libdconf_so_0_0_0_SOURCES = \
++libdconf_dylib_LDADD = $(gio_LIBS)
++libdconf_dylib_LDFLAGS = -dynamiclib
++libdconf_dylib_SOURCES = \
+ 	../common/dconf-shmdir.c	\
+ 	../common/dconf-paths.c		\
+ 	../engine/dconf-engine.c	\
+ 	../gvdb/gvdb-reader.c		\
+ 	dconf-client.vala engine.vapi
+-libdconf_so_0_0_0_VALAFLAGS = --library dconf --pkg=gio-2.0
++libdconf_dylib_VALAFLAGS = --library dconf --pkg=gio-2.0
+ 
+ EXTRA_DIST = dconf.vapi extra-docs.c
+-dconf.vapi: libdconf.so.0
++dconf.vapi: libdconf.dylib
+ 
+ dconf.deps:
+ 	$(AM_V_GEN) echo gio-2.0 > dconf.deps
+@@ -43,4 +31,4 @@ vapidir = $(datadir)/vala/vapi
+ pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = dconf.pc
+ 
+-CLEANFILES = dconf.deps libdconf.so.0 libdconf.so
++CLEANFILES = dconf.deps
+diff --git a/dbus-1/Makefile.am b/dbus-1/Makefile.am
+index 6e740f1..a5e6f1d 100644
+--- a/dbus-1/Makefile.am
++++ b/dbus-1/Makefile.am
+@@ -8,27 +8,12 @@ pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = dconf-dbus-1.pc
+ 
+ shlibdir = $(libdir)
+-shlib_PROGRAMS = libdconf-dbus-1.so.0.0.0
++shlib_PROGRAMS = libdconf-dbus-1.dylib
+ 
+-libdconf_dbus_1_so_0_0_0_LDADD = $(glib_LIBS) $(dbus_LIBS)
+-libdconf_dbus_1_so_0_0_0_LDFLAGS = -shared -Wl,-soname=libdconf-dbus-1.so.0
+-libdconf_dbus_1_so_0_0_0_SOURCES = \
++libdconf_dbus_1_dylib_LDADD = $(glib_LIBS) $(dbus_LIBS)
++libdconf_dbus_1_dylib_LDFLAGS = -dynamiclib
++libdconf_dbus_1_dylib_SOURCES = \
+ 	../engine/dconf-engine.c	\
+ 	../common/dconf-shmdir.c	\
+ 	../gvdb/gvdb-reader.c		\
+ 	dconf-dbus-1.c
+-
+-noinst_DATA = libdconf-dbus-1.so libdconf-dbus-1.so.0
+-
+-libdconf-dbus-1.so.0 libdconf-dbus-1.so: libdconf-dbus-1.so.0.0.0
+-	$(AM_V_GEN) ln -fs libdconf-dbus-1.so.0.0.0 $@
+-
+-install-data-hook:
+-	ln -fs libdconf-dbus-1.so.0.0.0 $(DESTDIR)$(shlibdir)/libdconf-dbus-1.so.0
+-	ln -fs libdconf-dbus-1.so.0.0.0 $(DESTDIR)$(shlibdir)/libdconf-dbus-1.so
+-
+-uninstall-hook:
+-	rm -f $(DESTDIR)$(shlibdir)/libdconf-dbus-1.so.0
+-	rm -f $(DESTDIR)$(shlibdir)/libdconf-dbus-1.so
+-
+-CLEANFILES = libdconf-dbus-1.so.0 libdconf-dbus-1.so
+
+--- a/editor/Makefile.am	2011-12-29 17:44:02.000000000 +0100
++++ b/editor/Makefile.am	2011-12-29 17:43:50.000000000 +0100
+@@ -3,7 +3,7 @@
+ AM_CFLAGS = $(gtk_CFLAGS) $(gmodule_CFLAGS) $(libxml_CFLAGS) -I$(top_srcdir)/common -I$(top_srcdir)/client -DPKGDATADIR=\"@datadir@/dconf-editor\"
+ AM_VALAFLAGS = --vapidir ../client --pkg gtk+-3.0 --pkg gmodule-2.0 --pkg libxml-2.0 --pkg dconf
+ CFLAGS += -Wno-error
+-dconf_editor_LDADD = ../client/libdconf.so.0 $(gtk_LIBS) $(gmodule_LIBS) $(gee_LIBS) $(libxml_LIBS)
++dconf_editor_LDADD = ../client/libdconf.dylib $(gtk_LIBS) $(gmodule_LIBS) $(gee_LIBS) $(libxml_LIBS)
+ dconf_editor_SOURCES = config.vapi dconf-editor.vala dconf-model.vala dconf-schema.vala dconf-view.vala
+ 
+ desktopdir = $(datadir)/applications
+
+--- a/gsettings/Makefile.am	2011-08-04 00:07:20.000000000 +0200
++++ b/gsettings/Makefile.am	2012-01-10 17:00:21.000000000 +0100
+@@ -4,7 +4,7 @@
+ giomodules_PROGRAMS = libdconfsettings.so
+
+ libdconfsettings_so_LDADD = $(gio_LIBS)
+-libdconfsettings_so_LDFLAGS = -shared
++libdconfsettings_so_LDFLAGS = -dynamiclib
+ libdconfsettings_so_SOURCES = \
+ 	../engine/dconf-engine.c	\
+ 	../common/dconf-shmdir.c	\
diff --git a/osx/jhbuild/patches/dconf-echo-escape.patch b/osx/jhbuild/patches/dconf-echo-escape.patch
new file mode 100644
index 0000000..c0e1b3c
--- /dev/null
+++ b/osx/jhbuild/patches/dconf-echo-escape.patch
@@ -0,0 +1,12 @@
+--- a/service/Makefile.in	2011-09-26 23:20:36.000000000 +0200
++++ b/service/Makefile.in	2012-01-06 18:08:55.000000000 +0100
+@@ -636,7 +638,7 @@
+ 
+ 
+ ca.desrt.dconf.service: Makefile
+-	$(AM_V_GEN) echo -e '[D-BUS Service]\nName=ca.desrt.dconf\nExec=${libexecdir}/dconf-service' > $@
++	$(AM_V_GEN) bash -c "echo -e '[D-BUS Service]\nName=ca.desrt.dconf\nExec=${libexecdir}/dconf-service'" > $@
+ 
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+
diff --git a/osx/jhbuild/patches/enchant-applespell.patch b/osx/jhbuild/patches/enchant-applespell.patch
new file mode 100644
index 0000000..f6f1f65
--- /dev/null
+++ b/osx/jhbuild/patches/enchant-applespell.patch
@@ -0,0 +1,368 @@
+--- a/configure.in       (revision 30591)
++++ b/configure.in       (working copy)
+@@ -33,4 +33,5 @@
+ AC_PROG_CC
+ AC_PROG_CPP
++AC_PROG_OBJC
+ AC_PROG_INSTALL
+ AC_PROG_LN_S
+--- a/src/applespell/Makefile.am	2010-04-01 22:53:37.000000000 +0200
++++ b/src/applespell/Makefile.am	2012-01-11 22:42:13.000000000 +0100
+@@ -1,4 +1,13 @@
+-EXTRA_DIST=			\
+-	applespell_checker.h	\
+-	applespell_checker.mm	\
+-	AppleSpell.config
++target_lib = libenchant_applespell.la
++
++INCLUDES=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(CC_WARN_CFLAGS) -DXP_TARGET_COCOA -xobjective-c -D_ENCHANT_BUILD=1
++
++applespell_LTLIBRARIES = $(target_lib)
++applespelldir= $(libdir)/enchant
++
++libenchant_applespell_la_LIBADD= $(ENCHANT_LIBS) -lobjc $(top_builddir)/src/libenchant.la
++libenchant_applespell_la_LDFLAGS = -module -avoid-version -no-undefined -framework Cocoa
++libenchant_applespell_la_SOURCES = applespell_provider.m
++libenchant_applespell_la_LIBTOOLFLAGS = --tag=CC
++
++libenchant_applespell_lalibdir=$(libdir)/enchant
+--- a/src/applespell/applespell_provider.m	2012-01-11 22:46:35.000000000 +0100
++++ b/src/applespell/applespell_provider.m	2012-01-11 22:39:17.000000000 +0100
+@@ -0,0 +1,337 @@
++/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
++/* enchant
++ * Copyright (C) 2004 Remi Payette
++ * Copyright (C) 2004 Francis James Franklin
++ * 
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2
++ * of the License, or (at your option) any later version.
++ * 
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ * 
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
++ * 02110-1301, USA.
++ */
++
++#include <glib.h>
++#include <gmodule.h>
++#include <Cocoa/Cocoa.h>
++#include <AvailabilityMacros.h>
++
++#include "enchant-provider.h"
++
++#ifdef __cplusplus
++extern "C"
++{
++#endif
++
++ENCHANT_MODULE_EXPORT (EnchantProvider *)
++init_enchant_provider (void);
++
++ENCHANT_MODULE_EXPORT (void)
++configure_enchant_provider (EnchantProvider *provider, const gchar *module_dir);
++
++#ifdef __cplusplus
++}
++#endif
++
++ENCHANT_PLUGIN_DECLARE("AppleSpell")
++
++typedef struct
++{
++	NSSpellChecker *checker;
++	NSString *language;
++} Dictionary;
++
++static Dictionary *
++dictionary_new (NSSpellChecker *checker,
++                NSString       *language)
++{
++	Dictionary *ret;
++
++	ret = g_slice_new (Dictionary);
++
++	ret->checker = checker;
++	ret->language = language;
++
++	return ret;
++}
++
++static void
++dictionary_free (Dictionary *dictionary)
++{
++	[dictionary->language release];
++	g_slice_free (Dictionary, dictionary);
++}
++
++static gchar **
++applespell_dict_suggest (EnchantDict         *dict,
++                         const gchar * const  word,
++                         size_t               len,
++                         size_t              *out_n_suggs)
++{
++	NSAutoreleasePool *pool;
++	gchar **ret = NULL;
++	NSString *str;
++	Dictionary *d;
++	NSArray *words;
++	NSRange range;
++	guint i = 0;
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	d = dict->user_data;
++
++	str = [[NSString alloc] initWithBytes:word length:len encoding:NSUTF8StringEncoding];
++
++	range.location = 0;
++	range.length = [str length];
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
++	words = [d->checker guessesForWordRange:range
++	                    inString:str
++	                    language:d->language
++	                    inSpellDocumentWithTag:0];
++#else
++	[d->checker setLanguage:d->language]; 
++	words = [d->checker guessesForWord:str];
++#endif
++
++	*out_n_suggs = [words count];
++
++	ret = g_new0 (gchar *, *out_n_suggs + 1);
++
++	for (i = 0; i < [words count]; ++i)
++	{
++		ret[i] = g_strdup ([[words objectAtIndex:i] UTF8String]);
++	}
++
++	[str release];
++	[pool release];
++
++	return ret;
++}
++
++static gint
++applespell_dict_check (EnchantDict         *dict,
++                       const gchar * const  word,
++                       size_t               len)
++{
++	NSAutoreleasePool *pool;
++	gint result = 0;
++	NSString *str;
++	Dictionary *d;
++	NSRange range;
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	d = dict->user_data;
++
++	str = [[NSString alloc] initWithBytes:word length:len encoding:NSUTF8StringEncoding];
++
++	range = [d->checker checkSpellingOfString:str
++	                    startingAt:0
++	                    language:d->language
++	                    wrap:true
++	                    inSpellDocumentWithTag:0
++	                    wordCount:NULL];
++
++	result = range.length > 0 ? 1 : 0;
++
++	[str release];
++	[pool release];
++
++	return result;
++}
++
++static EnchantDict *
++applespell_provider_request_dict (EnchantProvider    *provider,
++                                  const char * const  tag)
++{
++	NSAutoreleasePool *pool;
++	EnchantDict *dict;
++	NSString *str;
++
++	pool = [[NSAutoreleasePool alloc] init];
++	str = [[NSString alloc] initWithUTF8String:tag];
++
++	dict = g_new0 (EnchantDict, 1);
++
++	dict->check = applespell_dict_check;
++	dict->suggest = applespell_dict_suggest;
++
++	dict->user_data = dictionary_new (provider->user_data,
++	                                  str);
++
++	[str retain];
++
++	[pool release];
++	return dict;
++}
++
++static void
++applespell_provider_dispose_dict (EnchantProvider *provider,
++                                  EnchantDict     *dict)
++{
++	NSAutoreleasePool *pool;
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	dictionary_free (dict->user_data);
++	g_free (dict);
++
++	[pool release];
++}
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
++static gchar const *available_languages[] = {
++	"en",
++	"en_GB",
++	"en_AU",
++	"de",
++	"fr",
++	"nl",
++	"pl",
++	NULL
++};
++
++#endif
++
++static gint
++applespell_provider_dictionary_exists (EnchantProvider     *provider,
++                                       const gchar * const  tag)
++{
++	NSAutoreleasePool *pool;
++	gint result = 0;
++	NSSpellChecker *checker;
++#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
++	NSArray *languages;
++	guint i;
++#else
++	gchar const **ptr;
++#endif
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	checker = provider->user_data;
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
++	languages = [checker availableLanguages];
++
++	for (i = 0; i < [languages count]; ++i)
++	{
++		if (g_strcmp0 (tag, [[languages objectAtIndex:i] UTF8String]) == 0)
++		{
++			result = 1;
++			break;
++		}
++	}
++#else
++	ptr = available_languages;
++	
++	while (ptr && *ptr)
++	{
++		if (g_strcmp0 (tag, *ptr) == 0)
++		{
++			result = 1;
++			break;
++		}
++		++ptr;
++	}
++#endif
++
++	[pool release];
++
++	return result;
++}
++
++static void
++applespell_provider_dispose (EnchantProvider *provider)
++{
++	g_free (provider);
++}
++
++static const gchar *
++applespell_provider_identify (EnchantProvider *provider)
++{
++	return "AppleSpell";
++}
++
++static const gchar *
++applespell_provider_describe (EnchantProvider *provider)
++{
++	return "AppleSpell Provider";
++}
++
++static gchar **
++applespell_provider_list_dicts (EnchantProvider *provider,
++                                size_t          *out_n_dicts)
++{
++	NSSpellChecker *checker;
++	NSAutoreleasePool *pool;
++	gchar **ret = NULL;
++#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
++	NSArray *languages;
++	guint i = 0;
++#endif
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	checker = provider->user_data;
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
++	languages = [checker availableLanguages];
++	*out_n_dicts = [languages count];
++
++	ret = g_new0 (gchar *, *out_n_dicts + 1);
++
++	for (i = 0; i < [languages count]; ++i)
++	{
++		ret[i] = g_strdup ([[languages objectAtIndex:i] UTF8String]);
++	}
++#else
++	ret = g_strdupv ((gchar **)available_languages);
++#endif
++
++	[pool release];
++
++	return ret;
++}
++
++ENCHANT_MODULE_EXPORT (EnchantProvider *)
++init_enchant_provider (void)
++{
++	NSAutoreleasePool *pool;
++	EnchantProvider *provider;
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	provider = g_new0 (EnchantProvider, 1);
++
++	provider->dispose = applespell_provider_dispose;
++	provider->request_dict = applespell_provider_request_dict;
++	provider->dispose_dict = applespell_provider_dispose_dict;
++	provider->dictionary_exists = applespell_provider_dictionary_exists;
++	provider->identify = applespell_provider_identify;
++	provider->describe = applespell_provider_describe;
++	provider->list_dicts = applespell_provider_list_dicts;
++
++	provider->user_data = [NSSpellChecker sharedSpellChecker];
++
++	[pool release];
++
++	return provider;
++}
++
++ENCHANT_MODULE_EXPORT (void)
++configure_enchant_provider (EnchantProvider *provider,
++                            const gchar     *module_dir)
++{
++	return;
++}
diff --git a/osx/jhbuild/patches/ffi-darwin11.patch b/osx/jhbuild/patches/ffi-darwin11.patch
new file mode 100644
index 0000000..54adf0c
--- /dev/null
+++ b/osx/jhbuild/patches/ffi-darwin11.patch
@@ -0,0 +1,11 @@
+--- a/configure	2012-01-12 18:50:47.000000000 +0100
++++ b/configure	2012-01-12 18:53:06.000000000 +0100
+@@ -14292,7 +14292,7 @@
+ $as_echo "#define FFI_EXEC_TRAMPOLINE_TABLE 1" >>confdefs.h
+ 
+      ;;
+-     *-apple-darwin10* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*)
++     *-apple-darwin* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*)
+ 
+ $as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h
+ 
diff --git a/osx/jhbuild/patches/gobject-introspection-casecmp.patch b/osx/jhbuild/patches/gobject-introspection-casecmp.patch
new file mode 100644
index 0000000..f7edac8
--- /dev/null
+++ b/osx/jhbuild/patches/gobject-introspection-casecmp.patch
@@ -0,0 +1,11 @@
+--- a/giscanner/sourcescanner.c	2012-01-05 17:55:08.000000000 +0100
++++ b/giscanner/sourcescanner.c	2011-08-25 21:49:38.000000000 +0200
+@@ -246,7 +246,7 @@
+   g_assert (scanner->current_filename);
+   for (l = scanner->filenames; l != NULL; l = l->next)
+     {
+-      if (strcmp (l->data, scanner->current_filename) == 0)
++      if (g_ascii_strcasecmp (l->data, scanner->current_filename) == 0)
+ 	{
+ 	  found_filename = TRUE;
+ 	  break;
diff --git a/osx/jhbuild/patches/gtk-dnd-offscreen.patch b/osx/jhbuild/patches/gtk-dnd-offscreen.patch
new file mode 100644
index 0000000..d1ad0c2
--- /dev/null
+++ b/osx/jhbuild/patches/gtk-dnd-offscreen.patch
@@ -0,0 +1,11 @@
+--- a/gtk/gtkdnd-quartz.c	2011-12-18 17:18:55.000000000 +0100
++++ b/gtk/gtkdnd-quartz.c	2012-01-12 07:57:04.000000000 +0100
+@@ -413,7 +413,7 @@
+   GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
+   GdkWindow *window = gtk_widget_get_window (toplevel);
+   
+-  if (gtk_widget_is_toplevel (toplevel) && window)
++  if (gtk_widget_is_toplevel (toplevel) && !GTK_IS_OFFSCREEN_WINDOW (toplevel) && window)
+     return [gdk_quartz_window_get_nsview (window) window];
+   else
+     return NULL;
diff --git a/osx/jhbuild/patches/gtk-introspection.patch b/osx/jhbuild/patches/gtk-introspection.patch
new file mode 100644
index 0000000..42e46f3
--- /dev/null
+++ b/osx/jhbuild/patches/gtk-introspection.patch
@@ -0,0 +1,14 @@
+--- a/gtk/Makefile.am	2011-12-19 14:58:28.000000000 +0100
++++ b/gtk/Makefile.am	2012-01-12 13:10:42.000000000 +0100
+@@ -1028,6 +1028,11 @@
+     gtkplug.c
+ endif
+ 
++if USE_QUARTZ
++introspection_files += \
++    gtkdnd.c
++endif
++
+ Gtk-3.0.gir: $(INTROSPECTION_SCANNER) libgtk-3.la $(top_builddir)/gdk/Gdk-3.0.gir Makefile
+ Gtk_3_0_gir_SCANNERFLAGS = 			\
+ 	--add-include-path=$(top_builddir)/gdk	\
diff --git a/osx/jhbuild/patches/gtk-settings-ini-xdg.patch b/osx/jhbuild/patches/gtk-settings-ini-xdg.patch
new file mode 100644
index 0000000..388e467
--- /dev/null
+++ b/osx/jhbuild/patches/gtk-settings-ini-xdg.patch
@@ -0,0 +1,39 @@
+--- a/gtk/gtksettings.c	2011-12-19 14:58:28.000000000 +0100
++++ b/gtk/gtksettings.c	2012-01-09 18:17:38.000000000 +0100
+@@ -255,6 +255,7 @@
+   GParamSpec **pspecs, **p;
+   guint i = 0;
+   gchar *path;
++  gchar const *xdgdirs;
+ 
+   priv = G_TYPE_INSTANCE_GET_PRIVATE (settings,
+                                       GTK_TYPE_SETTINGS,
+@@ -297,6 +298,28 @@
+     gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
+   g_free (path);
+ 
++  xdgdirs = g_getenv ("XDG_CONFIG_DIRS");
++
++  if (xdgdirs)
++    {
++      gchar **dirs;
++      gchar **ptr;
++
++      dirs = g_strsplit_set (xdgdirs, ":", -1);
++
++      for (ptr = dirs; ptr && *ptr; ++ptr)
++        {
++          path = g_build_filename (*ptr, "gtk-3.0", "settings.ini", NULL);
++
++          if (g_file_test (path, G_FILE_TEST_EXISTS))
++            gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
++
++          g_free (path);
++        }
++
++      g_strfreev (dirs);
++    }
++
+   path = g_build_filename (g_get_user_config_dir (), "gtk-3.0", "settings.ini", NULL);
+   if (g_file_test (path, G_FILE_TEST_EXISTS))
+     gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
diff --git a/osx/jhbuild/patches/libpeas-disable-valademo.patch b/osx/jhbuild/patches/libpeas-disable-valademo.patch
new file mode 100644
index 0000000..cea2ea5
--- /dev/null
+++ b/osx/jhbuild/patches/libpeas-disable-valademo.patch
@@ -0,0 +1,23 @@
+From 48ff6ef571423e06cd483bbb6640b0e2e4b963fc Mon Sep 17 00:00:00 2001
+From: Jesse van den Kieboom <jessevdk gnome org>
+Date: Mon, 15 Aug 2011 23:05:15 +0200
+Subject: [PATCH 3/3] Disable vala demo plugin (does not compile)
+
+---
+ peas-demo/plugins/Makefile.am |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/peas-demo/plugins/Makefile.am b/peas-demo/plugins/Makefile.am
+index 1298928..3925a6c 100644
+--- a/peas-demo/plugins/Makefile.am
++++ b/peas-demo/plugins/Makefile.am
+@@ -13,5 +13,5 @@ SUBDIRS += seedhello
+ endif
+ 
+ if ENABLE_VALA
+-SUBDIRS += valahello
++#SUBDIRS += valahello
+ endif
+-- 
+1.7.4.1
+
diff --git a/osx/jhbuild/patches/libpeas-pygobject-api.patch b/osx/jhbuild/patches/libpeas-pygobject-api.patch
new file mode 100644
index 0000000..7c4ccb3
--- /dev/null
+++ b/osx/jhbuild/patches/libpeas-pygobject-api.patch
@@ -0,0 +1,25 @@
+From b1f1cf5c9d2a1fce8837cc448abac80727522fff Mon Sep 17 00:00:00 2001
+From: Jesse van den Kieboom <jessevdk gnome org>
+Date: Mon, 15 Aug 2011 23:05:01 +0200
+Subject: [PATCH 2/3] Do not import pygobject API twice
+
+---
+ loaders/python/peas-plugin-loader-python.c |    2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
+index 2d713fd..96de2f3 100644
+--- a/loaders/python/peas-plugin-loader-python.c
++++ b/loaders/python/peas-plugin-loader-python.c
+@@ -27,6 +27,8 @@
+ #include "peas-extension-python.h"
+ #include "peas-plugin-loader-python.h"
+ 
++#define NO_IMPORT_PYGOBJECT
++
+ /* _POSIX_C_SOURCE is defined in Python.h and in limits.h included by
+  * glib-object.h, so we unset it here to avoid a warning. Yep, that's bad. */
+ #undef _POSIX_C_SOURCE
+-- 
+1.7.4.1
+
diff --git a/osx/jhbuild/patches/mac-integration-open-files.patch b/osx/jhbuild/patches/mac-integration-open-files.patch
new file mode 100644
index 0000000..9955b36
--- /dev/null
+++ b/osx/jhbuild/patches/mac-integration-open-files.patch
@@ -0,0 +1,184 @@
+diff -ud pkgs/gtk-mac-integration-1.0.1/src/GtkApplicationDelegate.c gtk-mac-integration-1.0.1/src/GtkApplicationDelegate.c
+--- a/src/GtkApplicationDelegate.c	2011-05-01 07:20:54.000000000 +0200
++++ b/GtkApplicationDelegate.c	2012-01-10 21:27:16.000000000 +0100
+@@ -25,19 +25,43 @@
+ #include "gtkosxapplication.h"
+ 
+ @implementation GtkApplicationDelegate
+--(BOOL) application:(NSApplication*) theApplication openFile:(NSString*) file
++-(void) application:(NSApplication*) theApplication openFiles:(NSArray*) files
+ {
+-  const gchar *utf8_path =  [file UTF8String];
+-  GtkOSXApplication *app = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
+-  guint sig = g_signal_lookup("NSApplicationOpenFile", 
+-			      GTK_TYPE_OSX_APPLICATION);
+-  gboolean result = FALSE;
+-  if (sig)
+-      g_signal_emit(app, sig, 0, utf8_path, &result);
+-  g_object_unref(app);
+-  return result;
+-}
++	guint i;
++	gchar **paths;
++
++	paths = g_new0 (gchar *, [files count] + 1);
+ 
++	for (i = 0; i < [files count]; ++i)
++	{
++		const gchar *path =  [[files objectAtIndex:i] UTF8String];
++		paths[i] = g_strdup (path);
++	}
++	
++	GtkOSXApplication *app = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL);
++	
++	guint sig = g_signal_lookup ("NSApplicationOpenFiles", 
++			                     GTK_TYPE_OSX_APPLICATION);
++	gboolean result = FALSE;
++  
++	if (sig)
++	{
++         g_signal_emit (app, sig, 0, paths, &result);
++	}
++	
++	g_strfreev (paths);
++	
++	if (result)
++	{
++		[theApplication replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
++	}
++	else
++	{
++		[theApplication replyToOpenOrPrint:NSApplicationDelegateReplyFailure];
++	}
++		
++	g_object_unref (app);
++}
+ 
+ - (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)sender
+ {
+Only in gtk-mac-integration-1.0.1/src/: Makefile
+diff -ud pkgs/gtk-mac-integration-1.0.1/src/cocoa_menu_item.c gtk-mac-integration-1.0.1/src/cocoa_menu_item.c
+--- a/src/cocoa_menu_item.c	2011-05-01 07:20:54.000000000 +0200
++++ b/src/cocoa_menu_item.c	2012-01-06 17:07:50.000000000 +0100
+@@ -274,7 +274,7 @@
+ 		modifiers |= NSControlKeyMask;
+ 	      }
+ 
+-	      /* gdk/quartz maps Alt/Option to Mod5 */
+-	      if (key->accel_mods & (GDK_MOD5_MASK)) {
++	      /* gdk/quartz maps Alt/Option to Mod1 */
++	      if (key->accel_mods & GDK_MOD1_MASK) {
+ 		modifiers |= NSAlternateKeyMask;
+ 	      }
+--- a/src/gtkosxapplication_quartz.c	2011-10-03 21:41:14.000000000 +0200
++++ b/src/gtkosxapplication_quartz.c	2012-01-12 07:53:32.000000000 +0100
+@@ -38,6 +38,8 @@
+ #include "getlabel.h"
+ #include "gtk-mac-image-utils.h"
+ 
++#include <gdk/gdkquartz.h>
++
+ /* This is a private function in libgdk; we need to have is so that we
+    can force new windows onto the Window menu */
+ extern NSWindow* gdk_quartz_window_get_nswindow(GdkWindow*);
+@@ -338,23 +340,23 @@
+ 
+ 
+ /*
+- * g_cclosure_marshal_BOOLEAN__STRING:
++ * g_cclosure_marshal_BOOLEAN__STRV:
+  *
+- * A private marshaller for handlers which take a string parameter and
++ * A private marshaller for handlers which take a stringv parameter and
+  * return a boolean.
+  */
+ static void
+-g_cclosure_marshal_BOOLEAN__STRING (GClosure     *closure,
++g_cclosure_marshal_BOOLEAN__STRV (GClosure     *closure,
+                                GValue       *return_value G_GNUC_UNUSED,
+                                guint         n_param_values,
+                                const GValue *param_values,
+                                gpointer      invocation_hint G_GNUC_UNUSED,
+                                gpointer      marshal_data)
+ {
+-  typedef gboolean (*GMarshalFunc_BOOLEAN__STRING) (gpointer     data1,
++  typedef gboolean (*GMarshalFunc_BOOLEAN__STRV) (gpointer     data1,
+ 						    const char     *arg1,
+ 						    gpointer     data2);
+-  register GMarshalFunc_BOOLEAN__STRING callback;
++  register GMarshalFunc_BOOLEAN__STRV callback;
+   register GCClosure *cc = (GCClosure*) closure;
+   register gpointer data1, data2;
+   gboolean v_return;
+@@ -371,10 +373,10 @@
+       data1 = g_value_peek_pointer (param_values + 0);
+       data2 = closure->data;
+     }
+-  callback = (GMarshalFunc_BOOLEAN__STRING) (marshal_data ? marshal_data : cc->callback);
++  callback = (GMarshalFunc_BOOLEAN__STRV) (marshal_data ? marshal_data : cc->callback);
+ 
+     v_return = callback (data1,            
+-			 g_value_get_string (param_values + 1),
++			 g_value_get_boxed (param_values + 1),
+ 			 data2);
+     g_value_set_boolean (return_value, v_return);
+ }
+@@ -448,7 +450,7 @@
+     WillResignActive,
+     BlockTermination,
+     WillTerminate,
+-    OpenFile,
++    OpenFiles,
+     LastSignal
+ };
+ 
+@@ -561,9 +563,9 @@
+ 	       G_TYPE_NONE, 0);
+ 
+ /**
+- * GtkOSXApplication::NSApplicationOpenFile:
++ * GtkOSXApplication::NSApplicationOpenFiles:
+  * @app: The application object
+- * @path: A UTF8-encoded file path to open.
++ * @paths: UTF8-encoded file paths to open.
+  * @user_data: Data attached at connection
+  *
+  * Emitted when a OpenFile, OpenFiles, or OpenEmptyFile event is
+@@ -573,13 +575,13 @@
+  *
+  * Returns: Boolean indicating success at opening the file.
+  */
+-gtk_osxapplication_signals[OpenFile] =
+-    g_signal_new("NSApplicationOpenFile",
++gtk_osxapplication_signals[OpenFiles] =
++    g_signal_new("NSApplicationOpenFiles",
+ 	       GTK_TYPE_OSX_APPLICATION,
+ 	       G_SIGNAL_NO_RECURSE | G_SIGNAL_ACTION,
+ 	       0, NULL, NULL,
+-	       g_cclosure_marshal_BOOLEAN__STRING,
+-	       G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
++	       g_cclosure_marshal_BOOLEAN__STRV,
++	       G_TYPE_BOOLEAN, 1, G_TYPE_STRV);
+ 
+ }
+ 
+@@ -661,6 +663,7 @@
+     [cocoa_menubar setAutoenablesItems:NO];
+ 
+   }
++
+   if (cocoa_menubar != [NSApp mainMenu])
+     [NSApp setMainMenu: cocoa_menubar];
+ 
+@@ -684,10 +687,9 @@
+   cocoa_menu_item_add_submenu (menu_shell, cocoa_menubar, TRUE, FALSE);
+   /* Stupid hack to force the menubar to look right when a window is
+      opened after starting the main loop. */
+-  if (old_menubar != NULL) {
++
+     [NSApp setMainMenu: old_menubar];
+     [NSApp setMainMenu: cocoa_menubar];
+-  }
+ }
+ 
+ /**
diff --git a/osx/jhbuild/patches/pango-coretext-invisible.patch b/osx/jhbuild/patches/pango-coretext-invisible.patch
new file mode 100644
index 0000000..6498ae8
--- /dev/null
+++ b/osx/jhbuild/patches/pango-coretext-invisible.patch
@@ -0,0 +1,32 @@
+--- a/modules/basic/basic-coretext.c	2011-08-16 03:11:08.000000000 +0200
++++ b/modules/basic/basic-coretext.c	2012-01-09 14:13:32.000000000 +0100
+@@ -123,10 +123,25 @@
+   /* Since Pango divides things into runs already, we assume there is
+    * only a single run in this line.
+    */
+-  run = CFArrayGetValueAtIndex (runs, 0);
+-  run_status = CTRunGetStatus (run);
+-  glyph_count = CTRunGetGlyphCount (run);
+-  cgglyphs = CTRunGetGlyphsPtr (run);
++  if (CFArrayGetCount (runs) != 0)
++    {
++      run = CFArrayGetValueAtIndex (runs, 0);
++      run_status = CTRunGetStatus (run);
++      glyph_count = CTRunGetGlyphCount (run);
++      cgglyphs = CTRunGetGlyphsPtr (run);
++    }
++  else
++    {
++      run = NULL;
++      run_status = 0;
++      glyph_count = g_utf8_strlen (text, length);
++      cgglyphs = NULL;
++
++      if (glyph_count > 0 && g_utf8_get_char (text) == 8207)
++        {
++          run_status = kCTRunStatusRightToLeft;
++        }
++    }
+ 
+   p = text;
+   pango_glyph_string_set_size (glyphs, glyph_count);
diff --git a/osx/launcher.sh b/osx/launcher.sh
index f7fa06c..6e9eeaa 100755
--- a/osx/launcher.sh
+++ b/osx/launcher.sh
@@ -1,13 +1,19 @@
 #!/bin/sh
 
-if test "x$IGE_DEBUG_LAUNCHER" != x; then
-    set -x
+if test "x$GTK_DEBUG_LAUNCHER" != x; then
+	set -x
 fi
 
-if test "x$IGE_DEBUG_GDB" != x; then
-    EXEC="gdb --args"
+if test "x$GTK_DEBUG_GDB" != x; then
+	EXEC="gdb --args"
 else
-    EXEC=exec
+	EXEC=exec
+fi
+
+if test "x$GTK_DEBUG_DTRUSS" != x; then
+	EXEC="dtruss"
+else
+	EXEC=exec
 fi
 
 name=$(basename "$0")
@@ -22,37 +28,47 @@ bundle_data="$bundle_res"/share
 bundle_etc="$bundle_res"/etc
 
 export DYLD_LIBRARY_PATH="$bundle_lib:$DYLD_LIBRARY_PATH"
-export XDG_CONFIG_DIRS="$bundle_etc/xdg:$XDG_CONFIG_DIRS"
+export XDG_CONFIG_DIRS="$bundle_etc:$XDG_CONFIG_DIRS"
 export XDG_DATA_DIRS="$bundle_data:$XDG_DATA_DIRS"
 export GTK_DATA_PREFIX="$bundle_res"
 export GTK_EXE_PREFIX="$bundle_res"
 export GTK_PATH="$bundle_res"
-export GCONF_PREFIX="$bundle_res"
-
-export GTK2_RC_FILES="$bundle_etc/gtk-2.0/gtkrc"
-export GTK_IM_MODULE_FILE="$bundle_etc/gtk-2.0/gtk.immodules"
-export GDK_PIXBUF_MODULE_FILE="$bundle_etc/gtk-2.0/gdk-pixbuf.loaders"
-export PANGO_RC_FILE="$bundle_etc/pango/pangorc"
-
-# Python path
-export PYTHONPATH="$bundle_lib/python2.5/site-packages:$bundle_lib/python2.5/site-packages/gtk-2.0:$PYTHONPATH"
+export GDK_PIXBUF_MODULE_FILE="$bundle_lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
+export GIO_EXTRA_MODULES="$bundle_lib/gio/modules"
+export GI_TYPELIB_PATH="$bundle_lib/girepository-1.0"
+export PYTHONPATH="$bundle_lib/python2.6/site-packages:$PYTHONPATH"
+export PANGO_LIBDIR="$bundle_lib"
+export PANGO_SYSCONFDIR="$bundle_etc"
 
 if test -f "$bundle_lib/charset.alias"; then
-    export CHARSETALIASDIR="$bundle_lib"
+	export CHARSETALIASDIR="$bundle_lib"
 fi
 
 # Extra arguments can be added in environment.sh.
 EXTRA_ARGS=
 if test -f "$bundle_res/environment.sh"; then
-  source "$bundle_res/environment.sh"
+	source "$bundle_res/environment.sh"
 fi
 
 # Strip out the argument added by the OS.
 if [ x`echo "x$1" | sed -e "s/^x-psn_.*//"` == x ]; then
-    shift 1
+	shift 1
+fi
+
+# Launch dbus if needed
+dbusenv="$TMPDIR/gedit-$USER.dbus"
+
+if [ -f "$dbusenv" ]; then
+	source "$dbusenv"
+fi
+
+if [ -z "$DBUS_SESSION_BUS_PID" ] || ! ps -p "$DBUS_SESSION_BUS_PID" >/dev/null; then
+	"$bundle_bin"/dbus-launch > "$dbusenv"
+
+	source "$dbusenv"
 fi
 
-# Start gconf first
-"$bundle_res/libexec/gconfd-2" &
+export DBUS_SESSION_BUS_PID
+export DBUS_SESSION_BUS_ADDRESS
 
 $EXEC "$bundle_contents/MacOS/$name-bin" "$@" $EXTRA_ARGS
diff --git a/osx/logo.svgz b/osx/logo.svgz
new file mode 100644
index 0000000..b663994
Binary files /dev/null and b/osx/logo.svgz differ
diff --git a/osx/makebundle.sh b/osx/makebundle.sh
index 493c336..bc6d2f5 100755
--- a/osx/makebundle.sh
+++ b/osx/makebundle.sh
@@ -4,9 +4,28 @@ if [ -d gedit.app ] && [ "$1x" = "-fx" ]; then
 	rm -rf gedit.app
 fi
 
-ige-mac-bundler gedit.bundle
+gtk-mac-bundler gedit.bundle
+
+function do_strip {
+    name=$(mktemp -t bundle)
+    st=$(stat -f %p "$1")
+    
+    strip -o "$name" -S "$1"
+    mv -f "$name" "$1"
+    
+    chmod "$st" "$1"
+	chmod u+w "$1"
+}
 
 # Strip debug symbols
-find gedit.app/Contents/Resources | grep -E '\.(so|dylib)' | xargs strip -S
-find gedit.app/Contents/Resources/bin | xargs strip -S
-strip -S gedit.app/Contents/MacOS/gedit-bin
\ No newline at end of file
+for i in $(find gedit.app/Contents/Resources | grep -E '\.(so|dylib)'); do
+    do_strip "$i"
+done
+
+for i in $(find gedit.app/Contents/Resources/bin -type f); do
+    if [ -x "$i" ]; then
+        do_strip "$i"
+    fi
+done
+
+do_strip gedit.app/Contents/MacOS/gedit-bin
diff --git a/osx/settings.ini b/osx/settings.ini
new file mode 100644
index 0000000..0365096
--- /dev/null
+++ b/osx/settings.ini
@@ -0,0 +1,10 @@
+[Settings]
+gtk-theme-name = Adwaita
+gtk-icon-theme-name = Adwaita
+gtk-fallback-icon-theme = gnome
+gtk-font-name = Lucida Grande
+gtk-toolbar-style = icons
+gtk-toolbar-icon-size = small-toolbar
+gtk-auto-mnemonics = false
+gtk-button-images = false
+gtk-menu-images = false
\ No newline at end of file
diff --git a/osx/template.dmg b/osx/template.dmg
index b71c47d..9f79d71 100644
Binary files a/osx/template.dmg and b/osx/template.dmg differ
diff --git a/plugins/checkupdate/gedit-check-update-plugin.c b/plugins/checkupdate/gedit-check-update-plugin.c
index b7394a8..d11f3d1 100644
--- a/plugins/checkupdate/gedit-check-update-plugin.c
+++ b/plugins/checkupdate/gedit-check-update-plugin.c
@@ -45,7 +45,7 @@
 #endif
 
 #ifdef OS_OSX
-#include "gedit/osx/gedit-osx.h"
+#include "gedit/gedit-app-osx.h"
 #endif
 
 #define GEDIT_CHECK_UPDATE_PLUGIN_GET_PRIVATE(object) \
@@ -252,7 +252,8 @@ on_response_cb (GtkWidget              *infobar,
 		GError *error = NULL;
 
 #ifdef OS_OSX
-		gedit_osx_show_url (plugin->priv->url);
+		gedit_app_osx_show_url (GEDIT_APP_OSX (gedit_app_get_default ()),
+		                        plugin->priv->url);
 #else
 		gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (plugin->priv->window)),
 			      plugin->priv->url,
diff --git a/plugins/externaltools/tools/capture.py b/plugins/externaltools/tools/capture.py
index 6184a82..1a31f27 100644
--- a/plugins/externaltools/tools/capture.py
+++ b/plugins/externaltools/tools/capture.py
@@ -84,7 +84,7 @@ class Capture(GObject.Object):
         self.tried_killing = False
         self.idle_write_id = 0
         self.read_buffer = ''
-        
+
         try:
             self.pipe = subprocess.Popen(self.command, **popen_args)
         except OSError, e:
@@ -101,7 +101,7 @@ class Capture(GObject.Object):
             fcntl.fcntl(self.pipe.stdout.fileno(), fcntl.F_SETFL, flags)
 
             GObject.io_add_watch(self.pipe.stdout,
-                                 GObject.IO_IN | GObject.IO_HUP,
+                                 GObject.IO_IN | GObject.IO_HUP | GObject.IO_ERR,
                                  self.on_output)
 
         if self.flags & self.CAPTURE_STDERR:
@@ -110,7 +110,7 @@ class Capture(GObject.Object):
             fcntl.fcntl(self.pipe.stderr.fileno(), fcntl.F_SETFL, flags)
 
             GObject.io_add_watch(self.pipe.stderr,
-                                 GObject.IO_IN | GObject.IO_HUP,
+                                 GObject.IO_IN | GObject.IO_HUP | GObject.IO_ERR,
                                  self.on_output)
 
         # IO
@@ -132,7 +132,7 @@ class Capture(GObject.Object):
         try:
             l = len(self.write_buffer)
             m = min(l, self.WRITE_BUFFER_SIZE)
-         
+
             self.pipe.stdin.write(self.write_buffer[:m])
             
             if m == l:
@@ -151,6 +151,15 @@ class Capture(GObject.Object):
 
             return False
 
+    def process_read_buffer(self):
+        if self.read_buffer:
+            if source == self.pipe.stdout:
+                self.emit('stdout-line', self.read_buffer)
+            else:
+                self.emit('stderr-line', self.read_buffer)
+
+            self.read_buffer = ''
+
     def on_output(self, source, condition):
         if condition & (GObject.IO_IN | GObject.IO_PRI):
             line = source.read()
@@ -177,16 +186,15 @@ class Capture(GObject.Object):
                         self.emit('stdout-line', line)
                     else:
                         self.emit('stderr-line', line)
+            else:
+                source.close()
+                self.process_read_buffer()
+                self.pipe = None
 
-        if condition & ~(GObject.IO_IN | GObject.IO_PRI):
-            if self.read_buffer:
-                if source == self.pipe.stdout:
-                    self.emit('stdout-line', self.read_buffer)
-                else:
-                    self.emit('stderr-line', self.read_buffer)
-
-                self.read_buffer = ''
+                return False
 
+        if condition & ~(GObject.IO_IN | GObject.IO_PRI):
+            self.process_read_buffer()
             self.pipe = None
 
             return False
diff --git a/plugins/quickopen/quickopen/__init__.py b/plugins/quickopen/quickopen/__init__.py
index 4844cca..e4772af 100644
--- a/plugins/quickopen/quickopen/__init__.py
+++ b/plugins/quickopen/quickopen/__init__.py
@@ -69,7 +69,7 @@ class QuickOpenPlugin(GObject.Object, Gedit.WindowActivatable):
         self._action_group = Gtk.ActionGroup(name="GeditQuickOpenPluginActions")
         self._action_group.add_actions([
             ("QuickOpen", Gtk.STOCK_OPEN, _("Quick open"),
-             '<Ctrl><Alt>O', _("Quickly open documents"),
+             '<Primary><Alt>o', _("Quickly open documents"),
              self.on_quick_open_activate)
         ])
 
diff --git a/plugins/snippets/snippets/library.py b/plugins/snippets/snippets/library.py
index fe48a6a..41f4b7e 100644
--- a/plugins/snippets/snippets/library.py
+++ b/plugins/snippets/snippets/library.py
@@ -458,23 +458,32 @@ class SnippetsSystemFile:
 
                 try:
                         f = open(self.path, "r")
+                except IOError:
+                        self.ok = False
+                        return
 
-                        while True:
+                while True:
+                        try:
                                 data = f.read(readsize)
+                        except IOError:
+                                self.ok = False
+                                break
 
-                                if not data:
-                                        break
+                        if not data:
+                                break
 
+                        try:
                                 parser.feed(data)
+                        except Exception:
+                                self.ok = False
+                                break
 
-                                for element in elements:
-                                        yield element
+                        for element in elements:
+                                yield element
 
-                                del elements[:]
+                        del elements[:]
 
-                        f.close()
-                except IOError:
-                        self.ok = False
+                f.close()
 
         def load(self):
                 if not self.ok:
diff --git a/plugins/spell/Makefile.am b/plugins/spell/Makefile.am
index 0fa8f54..21b4cf3 100644
--- a/plugins/spell/Makefile.am
+++ b/plugins/spell/Makefile.am
@@ -6,7 +6,8 @@ INCLUDES = 							\
 	$(GEDIT_CFLAGS) 					\
 	$(ENCHANT_CFLAGS)					\
 	$(WARN_CFLAGS)						\
-	$(DISABLE_DEPRECATED_CFLAGS)	
+	$(DISABLE_DEPRECATED_CFLAGS)				\
+	$(GTK_MAC_CFLAGS)
 
 BUILT_SOURCES = 					\
 	gedit-spell-marshal.c				\
@@ -34,6 +35,21 @@ libspell_la_SOURCES = \
 libspell_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS) 
 libspell_la_LIBADD  = $(GEDIT_LIBS) $(ENCHANT_LIBS)
 
+# Mac OSX convenience library and ldflags
+if OS_OSX
+noinst_LTLIBRARIES = libosx.la
+
+libosx_la_LDFLAGS = -framework Cocoa
+libosx_la_LIBADD = -lobjc
+libosx_la_CFLAGS = -xobjective-c
+
+libosx_la_SOURCES = 		\
+	gedit-spell-osx.c		\
+	gedit-spell-osx.h
+
+libspell_la_LIBADD += libosx.la  $(GTK_MAC_LIBS)
+endif
+
 uidir = $(GEDIT_PLUGINS_DATA_DIR)/spell
 ui_DATA = spell-checker.ui languages-dialog.ui
 
diff --git a/plugins/spell/gedit-spell-checker-language.c b/plugins/spell/gedit-spell-checker-language.c
index 73e27c3..261f904 100644
--- a/plugins/spell/gedit-spell-checker-language.c
+++ b/plugins/spell/gedit-spell-checker-language.c
@@ -37,7 +37,7 @@
 #endif
 
 #ifdef OS_OSX
-#include <ige-mac-bundle.h>
+#include <gtkosxapplication.h>
 #endif
 
 #include <string.h>
@@ -82,11 +82,14 @@ get_iso_codes_locale_dir ()
 				       NULL);
 #else
 #if OS_OSX
-	IgeMacBundle *bundle = ige_mac_bundle_get_default ();
-
-	if (ige_mac_bundle_get_is_app_bundle (bundle))
+	if (quartz_application_get_bundle_id ())
 	{
-		locale_dir = g_strdup (ige_mac_bundle_get_localedir (bundle));
+		const gchar *bundle_resource_dir = quartz_application_get_resource_path ();
+
+		locale_dir = g_build_filename (bundle_resource_dir,
+		                               "share",
+		                               "locale",
+		                               NULL);
 	}
 #endif
 	if (locale_dir == NULL)
@@ -118,11 +121,13 @@ get_iso_codes_xml_name (gint iso)
 				      NULL);
 #else
 #if OS_OSX
-	IgeMacBundle *bundle = ige_mac_bundle_get_default ();
-
-	if (ige_mac_bundle_get_is_app_bundle (bundle))
+	if (quartz_application_get_bundle_id ())
 	{
-		share_dir = g_strdup (ige_mac_bundle_get_datadir (bundle));
+		const gchar *bundle_resource_dir = quartz_application_get_resource_path ();
+
+		share_dir = g_build_filename (bundle_resource_dir,
+		                               "share",
+		                               NULL);
 	}
 #endif
 	if (share_dir == NULL)
diff --git a/plugins/spell/gedit-spell-checker.c b/plugins/spell/gedit-spell-checker.c
index b4c98eb..9f3e4e3 100644
--- a/plugins/spell/gedit-spell-checker.c
+++ b/plugins/spell/gedit-spell-checker.c
@@ -42,6 +42,10 @@
 #include "gedit-spell-utils.h"
 #include "gedit-spell-marshal.h"
 
+#ifdef OS_OSX
+#include "gedit-spell-osx.h"
+#endif
+
 struct _GeditSpellChecker
 {
 	GObject parent_instance;
@@ -250,6 +254,22 @@ lazy_init (GeditSpellChecker               *spell,
 		}
 	}
 
+#ifdef OS_OSX
+	if (spell->active_lang == NULL)
+	{
+		gchar *key;
+
+		key = gedit_spell_osx_get_preferred_spell_language ();
+		
+		if (key)
+		{
+			spell->active_lang = gedit_spell_checker_language_from_key (key);
+		}
+
+		g_free (key);
+	}
+#endif
+
 	/* Second try to get a default language */
 	if (spell->active_lang == NULL)
 		spell->active_lang = gedit_spell_checker_language_from_key ("en_US");
diff --git a/plugins/spell/gedit-spell-osx.c b/plugins/spell/gedit-spell-osx.c
new file mode 100644
index 0000000..2c322d7
--- /dev/null
+++ b/plugins/spell/gedit-spell-osx.c
@@ -0,0 +1,27 @@
+#include "gedit-spell-osx.h"
+#include <Cocoa/Cocoa.h>
+
+gchar *
+gedit_spell_osx_get_preferred_spell_language ()
+{
+	gchar *ret = NULL;
+	NSAutoreleasePool *pool;
+	
+	pool = [[NSAutoreleasePool alloc] init];
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
+	NSArray *langs;
+
+	langs = [[NSSpellChecker sharedSpellChecker] userPreferredLanguages];
+
+	if ([langs count] > 0)
+	{
+		ret = g_strdup ([[langs objectAtIndex:0] UTF8String]);
+	}
+#endif
+
+	[pool release];
+	return ret;
+}
+
+/* ex:set ts=8 noet: */
diff --git a/plugins/spell/gedit-spell-osx.h b/plugins/spell/gedit-spell-osx.h
new file mode 100644
index 0000000..9b87275
--- /dev/null
+++ b/plugins/spell/gedit-spell-osx.h
@@ -0,0 +1,14 @@
+#ifndef _GEDIT_SPELL_OSX_H
+#define _GEDIT_SPELL_OSX_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gchar *gedit_spell_osx_get_preferred_spell_language (void);
+
+G_END_DECLS
+
+#endif /* _GEDIT_SPELL_OSX_H */
+
+/* ex:set ts=8 noet: */
\ No newline at end of file



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]