[gtk-osx] Create separate build chain for gtk3



commit 25b932712b327cf4a8bd285fc12fa9ce0e4a70f0
Author: John Ralls <jralls ceridwen us>
Date:   Thu Oct 27 11:38:55 2011 -0700

    Create separate build chain for gtk3
    
    
    This rather involved changeset separates out the dependencies needed for gtk2 and gtk3 (because of version differences) and creates new "meta-gtk-osx-gtk3" and "meta-gtk-osx-python-gtk3" meta-modules to build the correct set of dependencies.
    
    The gtk+-3.0 module, added earlier, now includes the patches that haven't been approved or weren't included in the 3.2 release at the beginning of October.
    
    While the two should be mutually installable (gtk2 and gtk3 and pygobject2 and pygobject3 have different-named installation directories and pkgconfig module names), several of the dependencies don't recognize that different versions are needed for each, so it's advisable to install into separate prefixes.

 modulesets-stable/gtk-osx-python.modules           |   34 +-
 modulesets-stable/gtk-osx.modules                  |   96 ++-
 ...82-GtkSelection-implementation-for-quartz.patch |  875 ++++++++++++++++++++
 ...8936-Minimal-change-to-pass-introspection.patch |   52 ++
 ...Directory-paths-for-resource-directories-.patch |  133 +++
 ...001-scanner-split-CC-environment-variable.patch |   31 +
 ...rtz-Bug-655057-Eliminate-Compiler-Warning.patch |   47 ++
 ...Write-to-released-memory-in-gtkdnd-quartz.patch |   52 ++
 ...767-Drag-and-Drop-NSEvent-capture-is-racy.patch |  106 +++
 9 files changed, 1400 insertions(+), 26 deletions(-)
---
diff --git a/modulesets-stable/gtk-osx-python.modules b/modulesets-stable/gtk-osx-python.modules
index 5e7e60b..7bc4047 100644
--- a/modulesets-stable/gtk-osx-python.modules
+++ b/modulesets-stable/gtk-osx-python.modules
@@ -25,8 +25,17 @@
     </dependencies>
   </metamodule>
 
+  <metamodule id="meta-gtk-osx-python-gtk3">
+    <dependencies>
+      <dep package="meta-gtk-osx-gtk3"/>
+      <dep package="pycairo-python2.6"/>
+      <dep package="pygobject3"/>
+      <dep package="gtk-mac-integration-python"/>
+    </dependencies>
+  </metamodule>
+
   <autotools id="berkeleydb" autogen-sh="dist/configure"
-         autogen-template="cd build_unix; ../%(autogen-sh)s --prefix %(prefix)s --libdir %(libdir)s %(autogenargs)s" makeargs="-C build_unix" 
+         autogen-template="cd build_unix; ../%(autogen-sh)s --prefix %(prefix)s --libdir %(libdir)s %(autogenargs)s" makeargs="-C build_unix"
          makeinstallargs="-C build_unix install">
 
     <branch module="berkeley-db/db-4.8.30.NC.tar.gz" version="4.8.30"
@@ -71,9 +80,8 @@
       <dep package="meta-gtk-osx-core"/>
     </after>
   </autotools>
-
-  <autotools id="pygobject" autogen-sh="configure"
-	     autogenargs="--disable-introspection">
+<!-- PyGObject 2.28 is the last series for Gtk+-2; for co-installation with later versions it installs as pygobject2 and PyGObject 3 installs as pygobject3. Introspection is disabled here, because gir-scanner isn't smart enough to co-install them. -->
+  <autotools id="pygobject" autogen-sh="configure" >
     <branch version="2.28.6" module="pygobject/2.28/pygobject-2.28.6.tar.bz2"
             hash="sha256:e4bfe017fa845940184c82a4d8949db3414cb29dfc84815fb763697dc85bdcee"/>
     <dependencies>
@@ -84,7 +92,18 @@
     </after>
   </autotools>
 
-  <autotools id="pygtk" autogen-sh="configure" 
+   <autotools id="pygobject3" autogen-sh="configure" >
+    <branch version="3.0.1" module="pygobject/3.0/pygobject-3.0.1.tar.bz2"
+            hash="sha256:c8548574ecd232eea90fc7cb647b9150273e9197b1e60129a4fb597825b5d7ad"/>
+    <dependencies>
+      <dep package="meta-gtk-osx-gtk3"/>
+    </dependencies>
+    <after>
+      <dep package="python"/>
+    </after>
+  </autotools>
+
+ <autotools id="pygtk" autogen-sh="configure" 
 	     autogenargs="CFLAGS=&quot;$CFLAGS -xobjective-c&quot; lt_cv_sys_global_symbol_pipe=&quot;'sed -n -e '\''s/^.*[ ]\([BCDEGRST][BCDEGRST]*\)[ ][ ]*_\([_A-Za-z][_A-Za-z0-9]*\)$/\1 _\2 \2/p'\'' | sed '\''/ __gnu_lto/d'\'''&quot;">
     <branch version="2.4.0" module="pygtk/2.24/pygtk-2.24.0.tar.bz2"
             hash="sha256:cd1c1ea265bd63ff669e92a2d3c2a88eb26bcd9e5363e0f82c896e649f206912">
@@ -105,8 +124,11 @@
             version="1.0.1"
 	    hash="sha256:417773d32be5304839f6f917a6ce4637d9a642829105ce8f9527f663830b8089"/>
     <dependencies>
-      <dep package="pygtk"/>
     </dependencies>
+    <after>
+      <dep package="pygtk"/>
+      <dep package="pygobject3"/>
+    </after>
   </autotools>
 
   <autotools id="pygtk-extras">
diff --git a/modulesets-stable/gtk-osx.modules b/modulesets-stable/gtk-osx.modules
index 7aec17f..4d823ef 100644
--- a/modulesets-stable/gtk-osx.modules
+++ b/modulesets-stable/gtk-osx.modules
@@ -54,6 +54,16 @@
     </after>
   </metamodule>
 
+  <metamodule id="meta-gtk-osx-gtk3">
+    <dependencies>
+      <dep package="gtk+-3.0"/>
+      <dep package="gtk-mac-integration"/>
+    </dependencies>
+    <after>
+      <dep package="meta-gtk-osx-bootstrap"/>
+    </after>
+  </metamodule>
+
   <autotools id="glib" autogen-sh="configure">
     <branch module="glib/2.28/glib-2.28.8.tar.bz2"  version="2.28.8"
             hash="sha256:222f3055d6c413417b50901008c654865e5a311c73f0ae918b0a9978d1f9466f"/>
@@ -63,7 +73,16 @@
     </after>
   </autotools>
 
-  <autotools id="libffi">
+  <autotools id="glib-gtk3" autogen-sh="configure">
+    <branch module="glib/2.30/glib-2.30.1.tar.bz2"  version="2.30.1"
+            hash="sha256:4e560319450f31d85b6cdb2b530c3324a510ca04817e360943d0774327d21804"/>
+    <after>
+      <dep package="meta-gtk-osx-bootstrap"/>
+      <dep package="gtk-doc"/>
+    </after>
+  </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"/>
   </autotools>
@@ -82,7 +101,21 @@
     </dependencies>
   </autotools>
 
-<!-- PangoFt2 and hence freetype and fontconfig are required by WebKitGtk -->
+  <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/0001-scanner-split-CC-environment-variable.patch"; strip="1"/>
+    </branch>
+    <dependencies>
+      <dep package="glib-gtk3"/>
+      <dep package="cairo"/>
+     <dep package="libffi"/>
+    </dependencies>
+  </autotools>
+
+<!-- PangoFt2 and hence freetype and fontconfig are required by WebKitGtk.  -->
   <autotools id="pango"  autogen-sh="configure"
              autogenargs="--without-x --with-included-modules=basic-atsui"
              makeargs="-k -C modules; make">
@@ -94,42 +127,54 @@
   <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/pangoatsui-fontname.patch"; strip="1"/>
     </branch>
     <dependencies>
-      <dep package="glib"/>
       <dep package="cairo"/>
-<!--      <dep package="gobject-introspection"/> -->
       <dep package="fontconfig"/>
-      <dep package="freetype"/>
     </dependencies>
     <after>
+      <dep package="glib"/>
+      <dep package="glib-gtk3"/>
+      <dep package="gobject-introspection"/>
+      <dep package="gobject-introspection-gtk3"/>
       <dep package="meta-gtk-osx-bootstrap"/>
     </after>
   </autotools>
 
- <autotools id="atk" autogen-sh="configure">
-    <branch module="atk/1.33/atk-1.33.6.tar.bz2" version="1.33.6"
-            hash="sha256:e61c9a7bb2605a6ba698285f5593590c90818592f3d122101b9d42697fd2b0b6"/>
+  <autotools id="pango-gtk3"  autogen-sh="configure"
+             autogenargs="--without-x --with-included-modules=basic-atsui"
+             makeargs="-k -C modules; make">
+    <!-- The last version that will build on Tiger is 1.24.5 -->
+    <branch version="1.29.4" module="pango/1.29/pango-1.29.4.tar.bz2"
+            hash="sha256:f15deecaecf1e9dcb7db0e4947d12b5bcff112586434f8d30a5afd750747ff2b">
+<!--    <branch version="1.24.5" module="pango/1.24/pango-1.24.5.tar.bz2"
+            hash="sha256:0f733d1ec3e8dafcae152d7ac58f1090bee1fd856176c8fee0e81b0e42392f4e">-->
+  <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/pangoatsui-fontname.patch"; strip="1"/>
+    </branch>
     <dependencies>
-      <dep package="glib"/>
+      <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="atk2" autogen-sh="configure">
-    <branch module="atk/2.0/atk-2.0.1.tar.bz2" version="2.0.1"
-            hash="sha256:3d81c7d70fc66e5b129567a7706b6f8ff5db18281a818b29d4dd5bcefa3d4a17"/>
+ <autotools id="atk" autogen-sh="configure">
+    <branch module="atk/2.2/atk-2.2.0.tar.bz2" version="2.2.0"
+            hash="sha256:d201e3f5808aef0b1aec2277bfa61074f68863e405428adb57a73aab5c838450"/>
     <dependencies>
-      <dep package="glib"/>
     </dependencies>
     <after>
+      <dep package="glib"/>
+      <dep package="glib-gtk3"/>
       <dep package="meta-gtk-osx-bootstrap"/>
     </after>
   </autotools>
 
   <autotools id="gdk-pixbuf">
-    <branch module="gdk-pixbuf/2.23/gdk-pixbuf-2.23.0.tar.bz2" version="2.23.0"
-            hash="sha256:e17081abe08e62491e25ce972eaf8f6325307289b9ab55111ccaf64ad058e2d0"/>
+    <branch module="gdk-pixbuf/2.24/gdk-pixbuf-2.24.0.tar.bz2" version="2.24.0"
+            hash="sha256:38d2630314e6d91976bffd833236f84fefa440a9038f86dc422820a39f2e3700"/>
     <after>
       <dep package="pango"/>
     </after>
@@ -142,7 +187,7 @@
             hash="sha256:6f45bdbf9ea27eb3b5f977d7ee2365dede0d0ce454985680c26e5210163bbf37">
       <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0001-Backport-acf1345-Fix-refresh-of-static-autorelease_p.patch"; strip="1"/>
       <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0002-Bug-628396-Gtk-build-fails-because-of-objective-c-el.patch"; strip="1"/>
-      <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0003-Bug-658772-Implement-relocatable-paths-for-quartz-si.patch"; strip="1"/>
+      <Patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0003-Bug-658772-Implement-relocatable-paths-for-quartz-si.patch"; strip="1"/>
       <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0004-Bug-571582-GtkSelection-implementation-for-quartz.patch"; strip="1"/>
       <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0005-Bug-657770-Write-to-released-memory-in-gtkdnd-quartz.patch"; strip="1"/>
       <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/0006-Bug-658722-Drag-and-Drop-sometimes-stops-working.patch"; strip="1"/>
@@ -158,24 +203,34 @@
       <patch file="http://git.gnome.org/browse/gtk-osx/plain/patches/gtk+-Bug-655065-autotestkeywords-ldadd.patch"; strip="1"/>
     </branch>
     <dependencies>
+      <dep package="glib"/>
       <dep package="pango"/>
       <dep package="atk"/>
       <dep package="gdk-pixbuf"/>
+      <dep package="gobject-introspection"/>
     </dependencies>
     <after>
       <dep package="meta-gtk-osx-bootstrap"/>
     </after>
   </autotools>
 
-  <autotools id="gtk+-3" autogen-sh="configure"
-             autogenargs="--enable-quartz-backend --disable-colord">
+  <autotools id="gtk+-3.0" autogen-sh="configure"
+             autogenargs="--enable-quartz-backend">
     <branch module="gtk+/3.2/gtk+-3.2.0.tar.bz2" version="3.2.0"
             hash="sha256:b285074ffefb4ff4364f6dd50fe68c7e85b11293e0c1dd3bdeac56052344dadb">
+      <patch file="http://git.gnome.org/browse/gtk-osx/plain/0001-Bug-628936-Minimal-change-to-pass-introspection.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gtk-osx/plain/0001-Bug-658772-Directory-paths-for-resource-directories-.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gtk-osx/plain/0002-Quartz-Bug-655057-Eliminate-Compiler-Warning.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gtk-osx/plain/0003-Bug-657770-Write-to-released-memory-in-gtkdnd-quartz.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gtk-osx/plain/0004-Bug-658767-Drag-and-Drop-NSEvent-capture-is-racy.patch"; strip="1"/>
+      <patch file="http://git.gnome.org/browse/gtk-osx/plain/0001-Bug-571582-GtkSelection-implementation-for-quartz.patch"; strip="1"/>
     </branch>
     <dependencies>
-      <dep package="pango"/>
+      <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"/>
@@ -213,9 +268,10 @@
             hash="sha256:417773d32be5304839f6f917a6ce4637d9a642829105ce8f9527f663830b8089">
     </branch>
     <dependencies>
-      <dep package="gtk+"/>
     </dependencies>
     <after>
+      <dep package="gtk+"/>
+      <dep package="gtk+-3.0"/>
       <dep package="meta-gtk-osx-bootstrap"/>
     </after>
   </autotools>
diff --git a/patches/0001-Bug-571582-GtkSelection-implementation-for-quartz.patch b/patches/0001-Bug-571582-GtkSelection-implementation-for-quartz.patch
new file mode 100644
index 0000000..5a2293e
--- /dev/null
+++ b/patches/0001-Bug-571582-GtkSelection-implementation-for-quartz.patch
@@ -0,0 +1,875 @@
+From 7385087cae85e14bce61f8effba0f04aab070592 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sun, 11 Sep 2011 16:08:22 -0700
+Subject: [PATCH] Bug 571582: GtkSelection implementation for quartz.
+
+---
+ gdk/quartz/gdkselection-quartz.c |   22 +-
+ gtk/Makefile.am                  |    4 +-
+ gtk/gtkselection-quartz.c        |  674 ++++++++++++++++++++++++++++++++++++++
+ gtk/gtkselection.c               |   14 +-
+ 4 files changed, 701 insertions(+), 13 deletions(-)
+ create mode 100644 gtk/gtkselection-quartz.c
+
+diff --git a/gdk/quartz/gdkselection-quartz.c b/gdk/quartz/gdkselection-quartz.c
+index 3accf32..f6048c8 100644
+--- a/gdk/quartz/gdkselection-quartz.c
++++ b/gdk/quartz/gdkselection-quartz.c
+@@ -32,7 +32,8 @@ _gdk_quartz_display_set_selection_owner (GdkDisplay *display,
+                                          guint32     time,
+                                          gint        send_event)
+ {
+-  /* FIXME: Implement */
++  g_warning ("Not a valid interface on Quartz. Use GtkSelection.\n");
++  g_return_val_if_reached(TRUE);
+   return TRUE;
+ }
+ 
+@@ -40,7 +41,7 @@ GdkWindow*
+ _gdk_quartz_display_get_selection_owner (GdkDisplay *display,
+                                          GdkAtom     selection)
+ {
+-  /* FIXME: Implement */
++ /* Quartz doesn't have an X-selection, so it doesn't have a gdk_selection. */
+   return NULL;
+ }
+ 
+@@ -51,7 +52,9 @@ _gdk_quartz_display_convert_selection (GdkDisplay *display,
+                                        GdkAtom     target,
+                                        guint32     time)
+ {
+-  /* FIXME: Implement */
++  g_warning ("Not a valid interface on Quartz. Use GtkSelection.\n");
++  g_return_if_reached();
++
+ }
+ 
+ gint
+@@ -61,7 +64,8 @@ _gdk_quartz_display_get_selection_property (GdkDisplay *display,
+                                             GdkAtom    *ret_type,
+                                             gint       *ret_format)
+ {
+-  /* FIXME: Implement */
++  g_warning ("Quartz windows do not support properties.\n");
++  g_return_val_if_reached (-1);
+   return 0;
+ }
+ 
+@@ -69,8 +73,8 @@ gchar *
+ _gdk_quartz_display_utf8_to_string_target (GdkDisplay  *display,
+                                            const gchar *str)
+ {
+-  /* FIXME: Implement */
+-  return NULL;
++  /* UTF8 is the standard string on OSX */
++  return g_strdup (str);
+ }
+ 
+ static gint
+@@ -90,7 +94,7 @@ make_list (const gchar  *text,
+   while (p < text + length)
+     {
+       gchar *str;
+-      
++
+       q = p;
+       while (*q && q < text + length)
+ 	q++;
+@@ -123,6 +127,8 @@ make_list (const gchar  *text,
+   if (list)
+     *list = g_new0 (gchar *, n_strings + 1);
+ 
++  (*list)[n_strings] = NULL;
++
+   i = n_strings;
+   tmp_list = strings;
+   while (tmp_list)
+@@ -163,7 +169,7 @@ _gdk_quartz_display_text_property_to_utf8_list (GdkDisplay    *display,
+     {
+       gchar *enc_name = gdk_atom_name (encoding);
+ 
+-      g_warning ("gdk_text_property_to_utf8_list_for_display: encoding %s not handled\n", enc_name);
++      g_warning ("gdk_text_property_to_utf8_list: encoding %s not handled\n", enc_name);
+       g_free (enc_name);
+ 
+       if (list)
+diff --git a/gtk/Makefile.am b/gtk/Makefile.am
+index 55d7f22..de81d57 100644
+--- a/gtk/Makefile.am
++++ b/gtk/Makefile.am
+@@ -798,7 +798,9 @@ if USE_QUARTZ
+ gtk_clipboard_dnd_c_sources = 	\
+ 	gtkclipboard-quartz.c	\
+ 	gtkdnd-quartz.c		\
+-	gtkquartz.c
++	gtkquartz.c		\
++	gtkselection-quartz.c
++
+ gtk_clipboard_dnd_h_sources = gtkquartz.h
+ else
+ gtk_clipboard_dnd_c_sources = gtkclipboard.c gtkdnd.c
+diff --git a/gtk/gtkselection-quartz.c b/gtk/gtkselection-quartz.c
+new file mode 100644
+index 0000000..1e948ad
+--- /dev/null
++++ b/gtk/gtkselection-quartz.c
+@@ -0,0 +1,674 @@
++/* GTK - The GIMP Toolkit
++ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2 of the License, or (at your option) any later version.
++ *
++ * This library 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the
++ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
++ * Boston, MA 02111-1307, USA.
++ */
++
++/* This file implements most of the work of the ICCCM selection protocol.
++ * The code was written after an intensive study of the equivalent part
++ * of John Ousterhout's Tk toolkit, and does many things in much the
++ * same way.
++ *
++ * The one thing in the ICCCM that isn't fully supported here (or in Tk)
++ * is side effects targets. For these to be handled properly, MULTIPLE
++ * targets need to be done in the order specified. This cannot be
++ * guaranteed with the way we do things, since if we are doing INCR
++ * transfers, the order will depend on the timing of the requestor.
++ *
++ * By Owen Taylor <owt1 cornell edu>	      8/16/97
++ */
++
++/* Terminology note: when not otherwise specified, the term "incr" below
++ * refers to the _sending_ part of the INCR protocol. The receiving
++ * portion is referred to just as "retrieval". (Terminology borrowed
++ * from Tk, because there is no good opposite to "retrieval" in English.
++ * "send" can't be made into a noun gracefully and we're already using
++ * "emission" for something else ....)
++ */
++
++/* The MOTIF entry widget seems to ask for the TARGETS target, then
++   (regardless of the reply) ask for the TEXT target. It's slightly
++   possible though that it somehow thinks we are responding negatively
++   to the TARGETS request, though I don't really think so ... */
++
++/*
++ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
++ * file for a list of people on the GTK+ Team.  See the ChangeLog
++ * files for a list of changes.  These files are distributed with
++ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
++ */
++
++#include "config.h"
++#include <stdarg.h>
++#include <string.h>
++#include "gdk.h"
++
++#include "gtkmain.h"
++#include "gtkselection.h"
++#include "gtkselectionprivate.h"
++#include "gtktextbufferrichtext.h"
++#include "gtkintl.h"
++#include "gdk-pixbuf/gdk-pixbuf.h"
++#include "gtkclipboard.h"
++
++#import <Cocoa/Cocoa.h>
++
++#undef DEBUG_SELECTION
++/*
++ * DON'T USE THIS INTERFACE: USE GTKCLIPBOARD INSTEAD!
++ *
++ * This is the Quartz version of gtkselection. Unlike the other
++ * versions, it was written in 2010, after most code was rewritten to
++ * use GtkClipboard. Quartz, unlike X11, is not a remote-capable
++ * display system, so most of ICCCM is pointless. This implementation
++ * can therefore be much simpler than the X11 implementation. Text is
++ * a lot simpler, too. It's UTF8. No compound text, no legacy
++ * charsets.  There's also only one display, so instead of passing it
++ * around, we'll generally just use gdk_display_get_default() when we
++ * need it.
++ *
++ * There are two constraints: The existing code in various GtkWidgets
++ * which uses GDK_SELECTION_CLIPBOARD (which gtkclipboard-quartz sets
++ * to generalPasteboard) for <ctrl>c copies and GDK_SELECTION_PRIMARY
++ * (for which gtkclipboard-quartz creates a separate pasteboard) for
++ * X-style selection transfers, and Apple's X11 Quartz implementation
++ * which by default puts both on the generalPasteboard. We need to
++ * operate with both.
++ *
++ * IMPORTANT: There is no X11 magic in quartz. If you insist on using
++ * this interface (and you really shouldn't), your MUST connect to
++ * selection-get, selection-received, and selection-clear-event for
++ * your widget.
++ */
++
++/* Maximum size of a sent chunk, in bytes. Also the default size of
++   our buffers */
++
++
++#define IDLE_ABORT_TIME 30
++
++enum {
++  INCR,
++  MULTIPLE,
++  TARGETS,
++  TIMESTAMP,
++  SAVE_TARGETS,
++  LAST_ATOM
++};
++
++typedef struct _GtkSelectionInfo GtkSelectionInfo;
++
++struct _GtkSelectionInfo
++{
++  GdkAtom	 selection;
++  GtkWidget	*owner;	/* widget that owns selection */
++  guint32	 time;		/* time used to acquire selection */
++};
++
++
++/* Local Functions */
++static void gtk_selection_get_cb            (GtkClipboard     *clipboard,
++					     GtkSelectionData *data,
++					     guint             info,
++					     gpointer          widget);
++static void gtk_selection_clear_cb          (GtkClipboard     *clipboard,
++					     gpointer 	       widget);
++static void gtk_selection_default_handler   (GtkWidget        *widget,
++					     GtkSelectionData *data);
++static int  gtk_selection_bytes_per_item    (gint              format);
++static GtkSelectionInfo *gtk_selection_info_get (GdkAtom selection);
++static void gtk_selection_info_remove		(GdkAtom selection,
++						 GtkWidget *owner);
++static void gtk_selection_info_append 		(GdkAtom selection,
++						 GtkWidget *owner,
++						 guint32 time);
++static void gtk_selection_info_clear		(GtkWidget *owner);
++static GtkTargetList *gtk_selection_target_list_get (GtkWidget    *widget,
++						     GdkAtom       selection);
++static void gtk_selection_target_list_remove 	    (GtkWidget *widget);
++
++/* Local Data */
++static gint initialize = TRUE;
++static GList *current_selections = NULL;
++
++static GdkAtom gtk_selection_atoms[LAST_ATOM];
++static const char gtk_selection_handler_key[] = "gtk-selection-handlers";
++
++static GtkTargetEntry default_target = {"UTF8_STRING", 0, 1};
++
++/**
++ * gtk_selection_owner_set_for_display:
++ * @display: the #Gdkdisplay where the selection is set
++ * @widget: (allow-none): new selection owner (a #GdkWidget), or %NULL.
++ * @selection: an interned atom representing the selection to claim.
++ * @time_: timestamp with which to claim the selection
++ *
++ * Claim ownership of a given selection for a particular widget, or,
++ * if @widget is %NULL, release ownership of the selection.
++ *
++ * Return value: TRUE if the operation succeeded
++ *
++ * Since: 2.2
++ */
++gboolean
++gtk_selection_owner_set_for_display (GdkDisplay   *display,
++				     GtkWidget    *widget,
++				     GdkAtom       selection,
++				     guint32       time)
++{
++  GObject *old_owner;
++  GtkClipboard *clip = gtk_clipboard_get (selection);
++  GtkTargetEntry *targets = &default_target;
++  gint num_targets = 1;
++  GtkTargetList *tlist;
++
++  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
++  g_return_val_if_fail (selection != GDK_NONE, FALSE);
++
++  old_owner = gtk_clipboard_get_owner (clip);
++  if (old_owner)
++    gtk_selection_info_remove (selection, GTK_WIDGET(old_owner));
++
++  if (widget == NULL)
++    return TRUE;
++
++  g_return_val_if_fail (gtk_widget_get_display (widget) == display, FALSE);
++
++  if ((tlist = gtk_selection_target_list_get (widget, selection)) != NULL)
++      targets = gtk_target_table_new_from_list (tlist, &num_targets);
++
++  if (gtk_clipboard_set_with_owner (clip, targets, num_targets,
++				    gtk_selection_get_cb,
++				    gtk_selection_clear_cb,
++				    G_OBJECT (widget)))
++    {
++      gtk_selection_info_append (selection, widget, GDK_CURRENT_TIME);
++      return TRUE;
++    }
++  return FALSE;
++}
++
++
++typedef struct _GtkSelectionTargetList GtkSelectionTargetList;
++
++struct _GtkSelectionTargetList {
++  GdkAtom selection;
++  GtkTargetList *list;
++};
++
++/**
++ * gtk_selection_remove_all:
++ * @widget: a #GtkWidget
++ *
++ * Removes all handlers and unsets ownership of all
++ * selections for a widget. Called when widget is being
++ * destroyed. This function will not generally be
++ * called by applications.
++ **/
++void
++gtk_selection_remove_all (GtkWidget *widget)
++{
++  g_return_if_fail(widget == NULL || GTK_IS_WIDGET(widget));
++  gtk_selection_info_clear (widget);
++  /* Remove all selection lists */
++  gtk_selection_target_list_remove (widget);
++}
++
++
++/**
++ * gtk_selection_convert:
++ * @widget: The widget which acts as requestor
++ * @selection: Which selection to get
++ * @target: Form of information desired (e.g., STRING)
++ * @time_: Time of request (usually of triggering event)
++       In emergency, you could use #GDK_CURRENT_TIME
++ *
++ * Requests the contents of a selection. When received,
++ * a "selection-received" signal will be generated.
++ *
++ * Return value: %TRUE if requested succeeded. %FALSE if we could not process
++ *          request. (e.g., there was already a request in process for
++ *          this widget).
++ **/
++gboolean
++gtk_selection_convert (GtkWidget *widget,
++		       GdkAtom	  selection,
++		       GdkAtom	  target,
++		       guint32	  time_)
++{
++  GtkClipboard *clip = gtk_clipboard_get (selection);
++  GtkSelectionData *data;
++
++  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
++  g_return_val_if_fail (selection != GDK_NONE, FALSE);
++
++  data = gtk_clipboard_wait_for_contents (clip, target);
++  if (data == NULL)
++    return FALSE;
++
++  g_signal_emit_by_name (widget, "selection-received", data, time);
++
++  return TRUE;
++}
++
++
++/**
++ * _gtk_selection_clear:
++ * @widget: a #GtkWidget
++ * @event: the event
++ *
++ * The default handler for the #GtkWidget::selection-clear-event
++ * signal.
++ *
++ * Return value: %TRUE if the event was handled, otherwise false
++ **/
++gboolean
++_gtk_selection_clear (GtkWidget         *widget,
++		     GdkEventSelection *event)
++{
++  gtk_selection_clear_targets (widget, event->selection);
++  return FALSE;
++}
++
++
++/*************************************************************
++ * _gtk_selection_request:
++ *     Handler for "selection_request_event"
++ *   arguments:
++ *     widget:
++ *     event:
++ *   results:
++ *************************************************************/
++
++gboolean
++_gtk_selection_request (GtkWidget *widget,
++			GdkEventSelection *event)
++{
++  g_print ("Selection Request Events should not occur in quartz\n");
++  return TRUE;
++}
++
++/*************************************************************
++ * _gtk_selection_incr_event:
++ *     Called whenever an PropertyNotify event occurs for an
++ *     GdkWindow with user_data == NULL. These will be notifications
++ *     that a window we are sending the selection to via the
++ *     INCR protocol has deleted a property and is ready for
++ *     more data.
++ *
++ *   arguments:
++ *     window:	the requestor window
++ *     event:	the property event structure
++ *
++ *   results:
++ *************************************************************/
++
++gboolean
++_gtk_selection_incr_event (GdkWindow	   *window,
++			   GdkEventProperty *event)
++{
++  g_print ("Selection_INCR_Events should not occur in quartz\n");
++  return TRUE;
++}
++
++/*************************************************************
++ * _gtk_selection_notify:
++ *     Handler for "selection-notify-event" signals on windows
++ *     where a retrieval is currently in process. The selection
++ *     owner has responded to our conversion request.
++ *   arguments:
++ *     widget:		Widget getting signal
++ *     event:		Selection event structure
++ *     info:		Information about this retrieval
++ *   results:
++ *     was event handled?
++ *************************************************************/
++
++gboolean
++_gtk_selection_notify (GtkWidget	       *widget,
++		       GdkEventSelection *event)
++{
++  g_print ("Selection_Notifications should not occur in quartz\n");
++
++  return TRUE;
++}
++
++/*************************************************************
++ * _gtk_selection_property_notify:
++ *     Handler for "property-notify-event" signals on windows
++ *     where a retrieval is currently in process. The selection
++ *     owner has added more data.
++ *   arguments:
++ *     widget:		Widget getting signal
++ *     event:		Property event structure
++ *     info:		Information about this retrieval
++ *   results:
++ *     was event handled?
++ *************************************************************/
++
++gboolean
++_gtk_selection_property_notify (GtkWidget	*widget,
++				GdkEventProperty *event)
++{
++  g_print ("Selection_Property_Notifications should not occur in quartz\n");
++  return TRUE;
++}
++
++
++/*************************************************************
++ * gtk_selection_get_cb()
++ * @clipboard: The clipboard requesting the data
++ * @data: Pass to selection-get signal; handlers should put requested
++ * data in the structure pointed to.
++ * @info: DND uses this on Windows and X11. It can be ignored for
++ * normal selection use.
++ * @owner: The window to which the information request is sent; it's
++ * the owner set with gtk_selection_owner_set_for_display.
++ *
++ * Emits a signal to the owner window to fill in the provided data structure.
++ *************************************************************/
++/* GtkClipboardGetFunc */
++static void
++gtk_selection_get_cb (GtkClipboard* clipboard,
++		      GtkSelectionData *data,
++		      guint info,
++		      gpointer owner)
++{
++  GtkTargetList *target_list;
++  GtkWidget *widget = GTK_WIDGET (owner);
++
++
++  g_return_if_fail (widget != NULL);
++
++  target_list = gtk_selection_target_list_get (widget, data->selection);
++
++  if ( data->target == gtk_selection_atoms[TIMESTAMP] ||
++       data->target == gtk_selection_atoms[TARGETS] ||
++       data->target == gtk_selection_atoms[SAVE_TARGETS])
++    {
++      gtk_selection_default_handler (widget, data);
++      return;
++    }
++  if (target_list &&
++      gtk_target_list_find (target_list, data->target, &info))
++    {
++      g_signal_emit_by_name (widget,
++			     "selection-get",
++			     data,
++			     info, time);
++    }
++}
++
++static void
++gtk_selection_clear_cb (GtkClipboard* clipboard,
++			gpointer owner)
++{
++  GtkWidget *widget = GTK_WIDGET (owner);
++  GdkEventSelection event;
++  event.type = GDK_SELECTION_CLEAR;
++  event.selection = GDK_SELECTION_PRIMARY;
++  event.window = gtk_widget_get_window(widget);
++  g_signal_emit_by_name (widget,
++			 "selection-clear-event",
++			 &event,
++			 NULL);
++}
++
++/*************************************************************
++ * gtk_selection_default_handler:
++ *     Handles some default targets that exist for any widget
++ *     If it can't fit results into buffer, returns -1. This
++ *     won't happen in any conceivable case, since it would
++ *     require 1000 selection targets!
++ *
++ *   arguments:
++ *     widget:	    selection owner
++ *     data:	    selection data [INOUT]
++ *
++ *************************************************************/
++
++static void
++gtk_selection_default_handler (GtkWidget	*widget,
++			       GtkSelectionData *data)
++{
++  if (data->target == gtk_selection_atoms[TIMESTAMP])
++    {
++      /* Time which was used to obtain selection */
++      GList *tmp_list;
++      GtkSelectionInfo *selection_info;
++
++      tmp_list = current_selections;
++      while (tmp_list)
++	{
++	  selection_info = (GtkSelectionInfo *)tmp_list->data;
++	  if ((selection_info->owner == widget) &&
++	      (selection_info->selection == data->selection))
++	    {
++	      gulong time = selection_info->time;
++
++	      gtk_selection_data_set (data,
++				      GDK_SELECTION_TYPE_INTEGER,
++				      32,
++				      (guchar *)&time,
++				      sizeof (time));
++	      return;
++	    }
++
++	  tmp_list = tmp_list->next;
++	}
++
++      data->length = -1;
++    }
++  else if (data->target == gtk_selection_atoms[TARGETS])
++    {
++      /* List of all targets supported for this widget/selection pair */
++      GdkAtom *p;
++      guint count;
++      GList *tmp_list;
++      GtkTargetList *target_list;
++      GtkTargetPair *pair;
++
++      target_list = gtk_selection_target_list_get (widget,
++						   data->selection);
++      count = g_list_length (target_list->list) + 3;
++
++      data->type = GDK_SELECTION_TYPE_ATOM;
++      data->format = 32;
++      data->length = count * sizeof (GdkAtom);
++
++      /* selection data is always terminated by a trailing \0
++       */
++      p = g_malloc (data->length + 1);
++      data->data = (guchar *)p;
++      data->data[data->length] = '\0';
++
++      *p++ = gtk_selection_atoms[TIMESTAMP];
++      *p++ = gtk_selection_atoms[TARGETS];
++      *p++ = gtk_selection_atoms[MULTIPLE];
++
++      tmp_list = target_list->list;
++      while (tmp_list)
++	{
++	  pair = (GtkTargetPair *)tmp_list->data;
++	  *p++ = pair->target;
++
++	  tmp_list = tmp_list->next;
++	}
++    }
++  else if (data->target == gtk_selection_atoms[SAVE_TARGETS])
++    {
++      gtk_selection_data_set (data,
++			      gdk_atom_intern_static_string ("NULL"),
++			      32, NULL, 0);
++    }
++  else
++    {
++      data->length = -1;
++    }
++}
++
++static GtkSelectionInfo *
++gtk_selection_info_get (GdkAtom selection)
++{
++  GList *tmp_list;
++  GList *next;
++  GtkSelectionInfo *selection_info;
++
++  tmp_list = current_selections;
++  while (tmp_list)
++    {
++      next = tmp_list->next;
++      selection_info = (GtkSelectionInfo *)tmp_list->data;
++
++      if (selection_info->selection == selection)
++	{
++	  return selection_info;
++	}
++
++      tmp_list = next;
++    }
++  return NULL;
++}
++
++static void
++gtk_selection_info_remove (GdkAtom selection, GtkWidget *owner)
++{
++  GList *tmp_list;
++  GList *next;
++  GtkSelectionInfo *selection_info;
++
++  g_return_if_fail (GTK_IS_WIDGET (owner));
++
++  tmp_list = current_selections;
++  while (tmp_list)
++    {
++      next = tmp_list->next;
++      selection_info = (GtkSelectionInfo *)tmp_list->data;
++
++      if (selection_info->selection == selection &&
++	  selection_info->owner == owner)
++	{
++	  /* Clear the clipboard; this will send a changedOwner to the
++	     pasteboard so that it won't try to retrieve the
++	     still-pending types later when the window isn't around to
++	     provide them. */
++	  GtkClipboard *clip = gtk_clipboard_get(selection_info->selection);
++	  gtk_clipboard_clear(clip);
++	  current_selections = g_list_remove_link (current_selections,
++						   tmp_list);
++	  g_list_free (tmp_list);
++	  g_slice_free (GtkSelectionInfo, selection_info);
++	  return;
++	}
++
++      tmp_list = next;
++    }
++}
++static void
++gtk_selection_info_append (GdkAtom selection, GtkWidget *owner, guint32 time)
++{
++  GtkSelectionInfo *selection_info;
++
++  g_return_if_fail (GTK_IS_WIDGET (owner));
++
++  selection_info = g_slice_new (GtkSelectionInfo);
++  selection_info->selection = selection;
++  selection_info->owner = owner;
++  selection_info->time = time;
++  current_selections = g_list_prepend (current_selections,
++				       selection_info);
++}
++
++static void
++gtk_selection_info_clear (GtkWidget *owner)
++{
++  GList *tmp_list;
++  GList *next;
++  GtkSelectionInfo *selection_info;
++
++  g_return_if_fail (GTK_IS_WIDGET (owner));
++
++  tmp_list = current_selections;
++  while (tmp_list)
++    {
++      next = tmp_list->next;
++      selection_info = (GtkSelectionInfo *)tmp_list->data;
++
++      if (selection_info->owner == owner)
++	{
++	  current_selections = g_list_remove_link (current_selections,
++						   tmp_list);
++	  g_list_free (tmp_list);
++	  g_slice_free (GtkSelectionInfo, selection_info);
++	}
++
++      tmp_list = next;
++    }
++}
++
++static GtkTargetList *
++gtk_selection_target_list_get (GtkWidget    *widget,
++			       GdkAtom       selection)
++{
++  GtkSelectionTargetList *sellist;
++  GList *tmp_list;
++  GList *lists;
++
++  lists = g_object_get_data (G_OBJECT (widget), gtk_selection_handler_key);
++
++  tmp_list = lists;
++  while (tmp_list)
++    {
++      sellist = tmp_list->data;
++      if (sellist->selection == selection)
++	return sellist->list;
++      tmp_list = tmp_list->next;
++    }
++
++  sellist = g_slice_new (GtkSelectionTargetList);
++  sellist->selection = selection;
++  sellist->list = gtk_target_list_new (NULL, 0);
++
++  lists = g_list_prepend (lists, sellist);
++  g_object_set_data (G_OBJECT (widget), I_(gtk_selection_handler_key), lists);
++
++  return sellist->list;
++}
++
++static void
++gtk_selection_target_list_remove (GtkWidget *widget)
++{
++  GtkSelectionTargetList *sellist;
++  GList *tmp_list;
++  GList *lists;
++
++  lists = g_object_get_data (G_OBJECT (widget), gtk_selection_handler_key);
++
++  tmp_list = lists;
++  while (tmp_list)
++    {
++      sellist = tmp_list->data;
++
++      gtk_target_list_unref (sellist->list);
++
++      g_slice_free (GtkSelectionTargetList, sellist);
++      tmp_list = tmp_list->next;
++    }
++
++  g_list_free (lists);
++  g_object_set_data (G_OBJECT (widget), I_(gtk_selection_handler_key), NULL);
++}
++
+diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c
+index 9e2295f..77bb934 100644
+--- a/gtk/gtkselection.c
++++ b/gtk/gtkselection.c
+@@ -661,6 +661,7 @@ gtk_target_table_free (GtkTargetEntry *targets,
+   g_free (targets);
+ }
+ 
++#ifndef GDK_WINDOWING_QUARTZ /* Quartz handled by gtkselection-quartz.c */
+ /**
+  * gtk_selection_owner_set_for_display:
+  * @display: the #Gdkdisplay where the selection is set
+@@ -763,7 +764,7 @@ gtk_selection_owner_set_for_display (GdkDisplay   *display,
+   else
+     return FALSE;
+ }
+-
++#endif /* GDK_WINDOWING_QUARTZ */
+ /**
+  * gtk_selection_owner_set:
+  * @widget: (allow-none):  a #GtkWidget, or %NULL.
+@@ -965,7 +966,7 @@ gtk_selection_add_targets (GtkWidget            *widget,
+ #endif
+ }
+ 
+-
++#ifndef GDK_WINDOWING_QUARTZ /* Quartz is handled in gtkselection-quartz.c */
+ /**
+  * gtk_selection_remove_all:
+  * @widget: a #GtkWidget 
+@@ -1026,8 +1027,9 @@ gtk_selection_remove_all (GtkWidget *widget)
+   /* Remove all selection lists */
+   gtk_selection_target_list_remove (widget);
+ }
++#endif /* GDK_WINDOWING_QUARTZ */
+ 
+-
++#ifndef GDK_WINDOWING_QUARTZ /* Quartz is handled in gtkselection-quartz.c */
+ /**
+  * gtk_selection_convert:
+  * @widget: The widget which acts as requestor
+@@ -1138,7 +1140,7 @@ gtk_selection_convert (GtkWidget *widget,
+   
+   return TRUE;
+ }
+-
++#endif /* GDK_WINDOWING_QUARTZ */
+ /**
+  * gtk_selection_data_get_selection:
+  * @selection_data: a pointer to a #GtkSelectionData structure.
+@@ -2232,6 +2234,7 @@ gtk_selection_init (void)
+   initialize = FALSE;
+ }
+ 
++#ifndef GDK_WINDOWING_QUARTZ /* Quartz handled by gtkselection-quartz.c */
+ /**
+  * _gtk_selection_clear:
+  * @widget: a #GtkWidget
+@@ -2652,6 +2655,7 @@ _gtk_selection_incr_event (GdkWindow	   *window,
+   
+   return TRUE;
+ }
++#endif /* GDK_WINDOWING_QUARTZ */
+ 
+ /*************************************************************
+  * gtk_selection_incr_timeout:
+@@ -2706,6 +2710,7 @@ gtk_selection_incr_timeout (GtkIncrInfo *info)
+   return retval;
+ }
+ 
++#ifndef GDK_WINDOWING_QUARTZ /* Quartz handled by gtkselection-quartz.c */
+ /*************************************************************
+  * _gtk_selection_notify:
+  *     Handler for "selection-notify-event" signals on windows
+@@ -2904,6 +2909,7 @@ _gtk_selection_property_notify (GtkWidget	*widget,
+   
+   return TRUE;
+ }
++#endif /* GDK_WINDOWING_QUARTZ */
+ 
+ /*************************************************************
+  * gtk_selection_retrieval_timeout:
+-- 
+1.7.6.3.dirty
+
diff --git a/patches/0001-Bug-628936-Minimal-change-to-pass-introspection.patch b/patches/0001-Bug-628936-Minimal-change-to-pass-introspection.patch
new file mode 100644
index 0000000..7841ec8
--- /dev/null
+++ b/patches/0001-Bug-628936-Minimal-change-to-pass-introspection.patch
@@ -0,0 +1,52 @@
+From a628761838ff382c5955209a64256469d5b1c1c3 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sun, 21 Nov 2010 13:06:57 -0800
+Subject: [PATCH] Bug 628936: Minimal change to pass introspection.
+
+gobject_introspection's G-ir-scanner doesn't like the -xobjective-c
+option needed to compile ObjectiveC features in quartz implementations
+of certain gtk functions. This rearranges the compiler flag environment
+variables in Makefile so that G-ir-scanner doesn't see them.
+---
+ gtk/Makefile.am |   10 +++-------
+ 1 files changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/gtk/Makefile.am b/gtk/Makefile.am
+index 8a11903..c3370e8 100644
+--- a/gtk/Makefile.am
++++ b/gtk/Makefile.am
+@@ -54,7 +54,6 @@ AM_CPPFLAGS =						\
+ 	-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED		\
+ 	$(GTK_DEBUG_FLAGS)				\
+ 	$(GTK_DEP_CFLAGS)				\
+-	$(gtk_clipboard_dnd_c_sources_CFLAGS)		\
+ 	$(INCLUDED_IMMODULE_DEFINE)
+ 
+ if PLATFORM_WIN32
+@@ -792,7 +791,8 @@ if USE_QUARTZ
+ gtk_private_h_sources += 	\
+ 	gtksearchenginequartz.h
+ gtk_c_sources += $(gtk_use_quartz_c_sources)
+-gtk_use_quartz_c_sources_CFLAGS = "-xobjective-c"
++libgtk_3_la_CFLAGS = "-xobjective-c"
++
+ else
+ gtk_c_sources += $(gtk_use_stub_c_sources)
+ endif
+@@ -805,12 +805,8 @@ gtk_clipboard_dnd_c_sources = 	\
+ 	gtkdnd-quartz.c		\
+ 	gtkquartz.c
+ gtk_clipboard_dnd_h_sources = gtkquartz.h
+-gtk_clipboard_dnd_c_sources_CFLAGS = "-xobjective-c"
+ else
+-gtk_clipboard_dnd_c_sources = 	\
+-	gtkclipboard.c		\
+-	gtkdnd.c
+-gtk_clipboard_dnd_c_sources_CFLAGS =
++gtk_clipboard_dnd_c_sources = gtkclipboard.c gtkdnd.c
+ endif
+ EXTRA_DIST += gtkquartz.h
+ 
+-- 
+1.7.6.3.dirty
+
diff --git a/patches/0001-Bug-658772-Directory-paths-for-resource-directories-.patch b/patches/0001-Bug-658772-Directory-paths-for-resource-directories-.patch
new file mode 100644
index 0000000..87cf9d7
--- /dev/null
+++ b/patches/0001-Bug-658772-Directory-paths-for-resource-directories-.patch
@@ -0,0 +1,133 @@
+From 48791fd51402dac48fd577f0072f58e835f1dee6 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sun, 11 Sep 2011 16:45:06 -0700
+Subject: [PATCH 1/4] Bug 658772: Directory paths for resource directories are
+ hard coded.
+
+Provide dynamic path discovery functions as are provided for win32.
+---
+ configure.ac     |    9 +++++++
+ gtk/gtkprivate.h |    3 +-
+ gtk/gtkquartz.c  |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 79 insertions(+), 1 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index a6726a1..b5ff718 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -318,6 +318,11 @@ if test -z "$backend_set"; then
+   fi
+ fi
+ 
++AC_ARG_ENABLE(quartz-relocation,
++              [AS_HELP_STRING([--enable-quartz-relocation],
++                              [enable bundle-based relocation functions])],
++                              [quartz_relocation=yes])
++
+ cairo_backends=
+ backend_immodules=
+ GDK_BACKENDS=
+@@ -360,6 +365,10 @@ if test "x$enable_quartz_backend" = xyes; then
+ #define GDK_WINDOWING_QUARTZ"
+   GDK_EXTRA_LIBS="$GDK_EXTRA_LIBS -framework Cocoa"
+   AM_CONDITIONAL(USE_QUARTZ, true)
++  if test "x$quartz_relocation" = xyes; then
++    AC_DEFINE([QUARTZ_RELOCATION], [1], [Use NSBundle functions to determine load paths for libraries, translations, etc.])
++  fi
++
+ else
+   AM_CONDITIONAL(USE_QUARTZ, false)
+ fi
+diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h
+index 58aded6..42ae5fb 100644
+--- a/gtk/gtkprivate.h
++++ b/gtk/gtkprivate.h
+@@ -33,7 +33,8 @@
+ 
+ G_BEGIN_DECLS
+ 
+-#ifdef G_OS_WIN32
++#if defined G_OS_WIN32 \
++  || (defined GDK_WINDOWING_QUARTZ && defined QUARTZ_RELOCATION)
+ 
+ const gchar *_gtk_get_datadir ();
+ const gchar *_gtk_get_libdir ();
+diff --git a/gtk/gtkquartz.c b/gtk/gtkquartz.c
+index b9ea2ec..e15890e 100644
+--- a/gtk/gtkquartz.c
++++ b/gtk/gtkquartz.c
+@@ -310,3 +310,71 @@ _gtk_quartz_set_selection_data_for_pasteboard (NSPasteboard     *pasteboard,
+                                        freeWhenDone:NO]
+                                             forType:type];
+ }
++
++/*
++ * Bundle-based functions for various directories. These almost work
++ * even when the application isn't in a bundle, becuase mainBundle
++ * paths point to the bin directory in that case. It's a simple matter
++ * to test for that and remove the last element.
++ */
++
++static gchar *
++get_bundle_path()
++{
++  gchar *base, *path;
++  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
++  gchar *resource_path = g_strdup([[[NSBundle mainBundle] resourcePath] UTF8String]);
++  [pool drain];
++  base = g_path_get_basename(resource_path);
++  if (strcmp(base, "bin") == 0) 
++    path = g_path_get_dirname(resource_path);
++  else
++    path = strdup(resource_path);
++  g_free(resource_path);
++  g_free(base);
++  return path;
++}
++
++const gchar *
++_gtk_get_datadir (void)
++{
++  gchar *resource_dir = get_bundle_path();
++  gchar *retval = g_build_filename(resource_dir, "share", NULL);
++  g_free(resource_dir);
++  return retval;
++}
++
++const gchar *
++_gtk_get_libdir (void)
++{
++  gchar *resource_dir = get_bundle_path();
++  gchar *retval = g_build_filename(resource_dir, "lib", NULL);
++  g_free(resource_dir);
++  return retval;
++}
++
++const gchar *
++_gtk_get_localedir (void)
++{
++
++  gchar *resource_dir = get_bundle_path();
++  gchar *retval = g_build_filename(resource_dir, "share", "locale", NULL);
++  g_free(resource_dir);
++  return retval;
++}
++
++const gchar *
++_gtk_get_sysconfdir (void)
++{
++  gchar *resource_dir = get_bundle_path();
++  gchar *retval = g_build_filename(resource_dir, "etc", NULL);
++  g_free(resource_dir);
++  return retval;
++}
++
++const gchar *
++_gtk_get_data_prefix (void)
++{
++  return get_bundle_path();
++}
++
+-- 
+1.7.6.3.dirty
+
diff --git a/patches/0001-scanner-split-CC-environment-variable.patch b/patches/0001-scanner-split-CC-environment-variable.patch
new file mode 100644
index 0000000..0857e89
--- /dev/null
+++ b/patches/0001-scanner-split-CC-environment-variable.patch
@@ -0,0 +1,31 @@
+From 33293e16045cb1667c0be8c13cb60daeec0594a9 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa alpinelinux org>
+Date: Mon, 10 Oct 2011 13:37:55 +0000
+Subject: [PATCH] scanner: split CC environment variable
+
+This fixes compilation where CC="ccache gcc" and similar.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=660160
+
+Signed-off-by: Natanael Copa <ncopa alpinelinux org>
+---
+ giscanner/sourcescanner.py |    3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py
+index 5f0ec2d..1e61ecf 100644
+--- a/giscanner/sourcescanner.py
++++ b/giscanner/sourcescanner.py
+@@ -274,7 +274,8 @@ class SourceScanner(object):
+ 
+         defines = ['__GI_SCANNER__']
+         undefs = []
+-        cpp_args = [os.environ.get('CC', 'cc'), '-E', '-C', '-I.', '-']
++        cpp_args = os.environ.get('CC', 'cc').split()
++        cpp_args += ['-E', '-C', '-I.', '-']
+ 
+         cpp_args += self._cpp_options
+         proc = subprocess.Popen(cpp_args,
+-- 
+1.7.6.3.dirty
+
diff --git a/patches/0002-Quartz-Bug-655057-Eliminate-Compiler-Warning.patch b/patches/0002-Quartz-Bug-655057-Eliminate-Compiler-Warning.patch
new file mode 100644
index 0000000..46a8806
--- /dev/null
+++ b/patches/0002-Quartz-Bug-655057-Eliminate-Compiler-Warning.patch
@@ -0,0 +1,47 @@
+From 9aa26f0d6404bed1fccd0995f92030ad98d56afe Mon Sep 17 00:00:00 2001
+From: Alex Corrado <alexander corrado gmail com>
+Date: Sun, 9 Oct 2011 09:52:14 -0700
+Subject: [PATCH 2/4] Quartz, Bug 655057: Eliminate Compiler Warning
+
+When compiled with older SDKs, the original change for this bug caused a
+compiler warning about NSWindow not being able to handle a setStyleMask
+message. This tricks the compiler into thinking that it can.
+---
+ gdk/quartz/gdkwindow-quartz.c |   12 ++++++++++--
+ 1 files changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
+index 9bd104d..82e79dc 100644
+--- a/gdk/quartz/gdkwindow-quartz.c
++++ b/gdk/quartz/gdkwindow-quartz.c
+@@ -2530,9 +2530,17 @@ gdk_quartz_window_get_frame_extents (GdkWindow    *window,
+   rect->height = ns_rect.size.height;
+ }
+ 
++/* Fake protocol to make gcc think that it's OK to call setStyleMask
++   even if it isn't. We check to make sure before actually calling
++   it. */
++
++ protocol CanSetStyleMask
++- (void)setStyleMask:(int)mask;
++ end
++
+ static void
+ gdk_quartz_window_set_decorations (GdkWindow       *window,
+-                                   GdkWMDecoration  decorations)
++			    GdkWMDecoration  decorations)
+ {
+   GdkWindowImplQuartz *impl;
+   NSUInteger old_mask, new_mask;
+@@ -2589,7 +2597,7 @@ gdk_quartz_window_set_decorations (GdkWindow       *window,
+        */
+       if ([impl->toplevel respondsToSelector:@selector(setStyleMask:)])
+         {
+-          [impl->toplevel setStyleMask:new_mask];
++          [(id<CanSetStyleMask>)impl->toplevel setStyleMask:new_mask];
+         }
+       else
+         {
+-- 
+1.7.6.3.dirty
+
diff --git a/patches/0003-Bug-657770-Write-to-released-memory-in-gtkdnd-quartz.patch b/patches/0003-Bug-657770-Write-to-released-memory-in-gtkdnd-quartz.patch
new file mode 100644
index 0000000..9160584
--- /dev/null
+++ b/patches/0003-Bug-657770-Write-to-released-memory-in-gtkdnd-quartz.patch
@@ -0,0 +1,52 @@
+From 436547a80e5f21751d354db1379893ecde3be2c8 Mon Sep 17 00:00:00 2001
+From: Kristian Rietveld <kris gtk org>
+Date: Sat, 24 Sep 2011 17:32:21 -0700
+Subject: [PATCH 3/4] Bug 657770 - Write to released memory in gtkdnd-quartz.c
+
+Clear the Drag paste board just before the info->context is released.
+This way the GtkDragSourceOwner is released just before the drag context
+is and thus can pasteboard:provideDataForType: not accidentally access
+an already released drag context
+---
+ gtk/gtkdnd-quartz.c |   14 ++++++++++++++
+ 1 files changed, 14 insertions(+), 0 deletions(-)
+
+diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
+index b577bb6..6d4e709 100644
+--- a/gtk/gtkdnd-quartz.c
++++ b/gtk/gtkdnd-quartz.c
+@@ -1777,6 +1777,9 @@ gtk_drag_set_icon_default (GdkDragContext    *context)
+ static void
+ gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
+ {
++  NSPasteboard *pasteboard;
++  NSAutoreleasePool *pool;
++
+   if (info->icon_pixbuf)
+     g_object_unref (info->icon_pixbuf);
+ 
+@@ -1791,10 +1794,21 @@ gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
+ 
+   gtk_target_list_unref (info->target_list);
+ 
++  pool = [[NSAutoreleasePool alloc] init];
++
++  /* Empty the pasteboard, so that it will not accidentally access
++   * info->context after it has been destroyed.
++   */
++  pasteboard = [NSPasteboard pasteboardWithName: NSDragPboard];
++  [pasteboard declareTypes: nil owner: nil];
++
++  [pool relase];
++
+   gtk_drag_clear_source_info (info->context);
+   g_object_unref (info->context);
+ 
+   g_free (info);
++  info = NULL;
+ }
+ 
+ static gboolean
+-- 
+1.7.6.3.dirty
+
diff --git a/patches/0004-Bug-658767-Drag-and-Drop-NSEvent-capture-is-racy.patch b/patches/0004-Bug-658767-Drag-and-Drop-NSEvent-capture-is-racy.patch
new file mode 100644
index 0000000..038056c
--- /dev/null
+++ b/patches/0004-Bug-658767-Drag-and-Drop-NSEvent-capture-is-racy.patch
@@ -0,0 +1,106 @@
+From 68135b53fc9aa679d00244304fb6d67400e9b0f3 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Sat, 24 Sep 2011 18:19:56 -0700
+Subject: [PATCH 4/4] Bug 658767 - Drag and Drop NSEvent capture is racy
+
+Create a synthetic NSMouseLeftDown to store in the GtkQuartzDragSourceInfo
+rather than relying on the NSWindow's latest event being the right one (or the
+right kind).
+---
+ gtk/gtkdnd-quartz.c |   56 +++++++++++++++++++++++++++++++++++++++++---------
+ 1 files changed, 46 insertions(+), 10 deletions(-)
+
+diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
+index 6d4e709..0653261 100644
+--- a/gtk/gtkdnd-quartz.c
++++ b/gtk/gtkdnd-quartz.c
+@@ -1100,6 +1100,13 @@ gtk_drag_begin_idle (gpointer arg)
+ 
+   return FALSE;
+ }
++/* Fake protocol to let us call GdkNSView gdkWindow without including
++ * gdk/GdkNSView.h (which we can't because it pulls in the internal-only
++ * gdkwindow.h).
++ */
++ protocol GdkNSView
++- (GdkWindow *)gdkWindow;
++ end
+ 
+ static GdkDragContext *
+ gtk_drag_begin_internal (GtkWidget         *widget,
+@@ -1110,14 +1117,47 @@ gtk_drag_begin_internal (GtkWidget         *widget,
+ 			 GdkEvent          *event)
+ {
+   GtkDragSourceInfo *info;
+-  GdkDragContext *context;
+   GdkDevice *pointer;
+-  NSWindow *nswindow;
+-
+-  context = gdk_drag_begin (gtk_widget_get_window (widget), NULL);
++  GdkWindow *window;
++  GdkDragContext *context = gdk_drag_begin (gtk_widget_get_window (widget),
++					    NULL);
++  NSWindow *nswindow = get_toplevel_nswindow (widget);
++  NSPoint point = {0, 0};
++  gdouble x, y;
++  double time = (double)g_get_real_time ();
++  NSEvent *nsevent;
++  NSTimeInterval nstime;
++
++  if (event)
++    {
++      if (gdk_event_get_coords (event, &x, &y))
++        {
++          point.x = x;
++          point.y = y;
++        }
++      time = (double)gdk_event_get_time (event);
++    }
++  nstime = [[NSDate dateWithTimeIntervalSince1970: time / 1000] timeIntervalSinceReferenceDate];
++  nsevent = [NSEvent mouseEventWithType: NSLeftMouseDown
++        	      location: point
++		      modifierFlags: 0
++	              timestamp: nstime
++		      windowNumber: [nswindow windowNumber]
++		      context: [nswindow graphicsContext]
++		      eventNumber: 0
++		      clickCount: 1
++	              pressure: 0.0 ];
++
++  window = [(id<GdkNSView>)[nswindow contentView] gdkWindow];
++  g_return_val_if_fail(nsevent != NULL, NULL);
++
++  context = gdk_drag_begin (window, NULL);
++  g_return_val_if_fail( context != NULL, NULL);
+ 
+   info = gtk_drag_get_source_info (context, TRUE);
+-  
++  info->nsevent = nsevent;
++  [info->nsevent retain];
++
+   info->source_widget = g_object_ref (widget);
+   info->widget = g_object_ref (widget);
+   info->target_list = target_list;
+@@ -1160,10 +1200,6 @@ gtk_drag_begin_internal (GtkWidget         *widget,
+ 	  }
+     }
+ 
+-  nswindow = get_toplevel_nswindow (widget);
+-  info->nsevent = [nswindow currentEvent];
+-  [info->nsevent retain];
+-
+   /* drag will begin in an idle handler to avoid nested run loops */
+ 
+   g_idle_add_full (G_PRIORITY_HIGH_IDLE, gtk_drag_begin_idle, context, NULL);
+@@ -1802,7 +1838,7 @@ gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
+   pasteboard = [NSPasteboard pasteboardWithName: NSDragPboard];
+   [pasteboard declareTypes: nil owner: nil];
+ 
+-  [pool relase];
++  [pool release];
+ 
+   gtk_drag_clear_source_info (info->context);
+   g_object_unref (info->context);
+-- 
+1.7.6.3.dirty
+



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