This file includes a patch to support switching between native and generic
application information interfaces.

The native interface is used for Quartz-based builds of GTK+ and uses
application bundle information, while the generic interface is the freedesktop
implementation working with standard .desktop files.

Both options are mutually exclusive, as glib (so far) only supports one
specific implementation that must be compiled and linked statically into the
shared library at build time.

For X11 builds of glib (our default), we want to support .desktop files.

See: https://trac.macports.org/ticket/53911
See: https://bugzilla.gnome.org/show_bug.cgi?id=781548
--- configure.ac.orig	2018-03-12 15:49:26.000000000 -0500
+++ configure.ac	2018-03-15 16:22:00.000000000 -0500
@@ -1803,6 +1803,31 @@
 ])
 AC_SUBST(XATTR_LIBS)
 
+dnl ***********************************************
+dnl *** Check for gappinfo implementation (GIO) ***
+dnl ***********************************************
+AC_ARG_WITH(appinfo-impl,
+           [AS_HELP_STRING([--appinfo-impl=@<:@native/generic@:>@],
+                           [use appinfo implementation [native]])],
+           [],
+           [with_appinfo_impl='native'])
+
+if test "$with_appinfo_impl" != "native" && test "$with_appinfo_impl" != "generic"; then
+  with_appinfo_impl="native"
+fi
+
+AM_CONDITIONAL(APPINFO_IMPL_NATIVE, [test "$with_appinfo_impl" = "native"])
+AM_CONDITIONAL(APPINFO_IMPL_GENERIC, [test "$with_appinfo_impl" = "generic"])
+
+case $with_appinfo_impl in
+  native)
+    AC_DEFINE(USE_APPINFO_NATIVE, 1, [Prefer the native application information implementation])
+    ;;
+  generic)
+    AC_DEFINE(USE_APPINFO_GENERIC, 1, [Prefer the generic (freedesktop-based) application information implementation])
+    ;;
+esac
+
 dnl ************************
 dnl *** check for libelf ***
 dnl ************************
--- gio/Makefile.am.orig	2018-03-16 05:24:56.000000000 -0500
+++ gio/Makefile.am	2018-03-18 20:20:48.000000000 -0500
@@ -255,9 +255,13 @@
 if OS_UNIX
 platform_libadd += xdgmime/libxdgmime.la
 platform_deps += xdgmime/libxdgmime.la
-if !OS_COCOA
+if OS_COCOA
+if APPINFO_IMPL_NATIVE
+appinfo_headers += gosxappinfo.h
+else
 appinfo_headers += gdesktopappinfo.h
 endif
+endif
 
 
 unix_sources = \
@@ -300,7 +304,7 @@
 	gunixinputstream.h 	\
 	gunixoutputstream.h 	\
 	gunixsocketaddress.h	\
-	$(appinfo_headers) \
+	$(appinfo_headers)	\
 	$(NULL)
 
 if HAVE_NETLINK
@@ -348,7 +352,13 @@
 	win32/gwin32filemonitor.c
 
 if OS_WIN32
-appinfo_sources += gwin32appinfo.c gwin32appinfo.h
+if APPINFO_IMPL_NATIVE
+appinfo_headers += gwin32appinfo.h
+appinfo_sources += gwin32appinfo.c
+else
+appinfo_headers += gdesktopappinfo.h
+appinfo_sources += gdesktopappinfo.c
+endif
 contenttype_sources += gcontenttype-win32.c
 platform_libadd += -lshlwapi -lws2_32 -ldnsapi -liphlpapi
 win32_sources = $(win32_actual_sources)
@@ -357,6 +367,7 @@
 giowin32include_HEADERS = \
 	gwin32inputstream.h \
 	gwin32outputstream.h \
+	$(appinfo_headers) \
 	$(NULL)
 
 endif
@@ -396,7 +407,12 @@
 	$(NULL)
 
 if OS_UNIX
-if !OS_COCOA
+if OS_COCOA
+if !APPINFO_IMPL_NATIVE
+contenttype_sources += gcontenttype.c
+appinfo_sources += gdesktopappinfo.c
+endif
+else
 contenttype_sources += gcontenttype.c
 appinfo_sources += gdesktopappinfo.c
 endif
@@ -609,10 +625,12 @@
 libgio_objc_2_0_la_CPPFLAGS = $(libgio_2_0_la_CPPFLAGS)
 libgio_objc_2_0_la_LDFLAGS = $(libgio_2_0_la_LDFLAGS) -Wl,-framework,Foundation -Wl,-framework,AppKit
 libgio_objc_2_0_la_SOURCES = \
-	gnextstepsettingsbackend.c \
+	gnextstepsettingsbackend.c
+if APPINFO_IMPL_NATIVE
+libgio_objc_2_0_la_SOURCES += \
 	gosxcontenttype.c \
-	gosxappinfo.c \
-	gosxappinfo.h
+	gosxappinfo.c
+endif
 if MAC_OS_X_9
 libgio_objc_2_0_la_SOURCES += \
 	gcocoanotificationbackend.c
--- gio/giomodule.c.orig	2018-01-22 14:28:02.000000000 -0600
+++ gio/giomodule.c	2018-02-16 05:55:21.000000000 -0600
@@ -43,12 +43,13 @@
 #endif
 #include <glib/gstdio.h>
 
-#if defined(G_OS_UNIX) && !defined(HAVE_COCOA)
+#if defined(G_OS_UNIX)
+#if !defined(HAVE_COCOA) || defined(USE_APPINFO_GENERIC)
 #include "gdesktopappinfo.h"
-#endif
-#ifdef HAVE_COCOA
+#elif defined(HAVE_COCOA)
 #include "gosxappinfo.h"
 #endif
+#endif
 
 #ifdef HAVE_COCOA
 #include <AvailabilityMacros.h>
@@ -1011,7 +1012,7 @@
     {
       registered_extensions = TRUE;
       
-#if defined(G_OS_UNIX) && !defined(HAVE_COCOA)
+#if defined(G_OS_UNIX) && (!defined(HAVE_COCOA) || defined(USE_APPINFO_GENERIC))
 #if !GLIB_CHECK_VERSION (3, 0, 0)
       ep = g_io_extension_point_register (G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME);
       G_GNUC_BEGIN_IGNORE_DEPRECATIONS
@@ -1152,8 +1153,10 @@
 #endif
 #ifdef HAVE_COCOA
       g_type_ensure (g_nextstep_settings_backend_get_type ());
+#ifndef USE_APPINFO_GENERIC
       g_type_ensure (g_osx_app_info_get_type ());
 #endif
+#endif
 #ifdef G_OS_UNIX
       g_type_ensure (_g_unix_volume_monitor_get_type ());
       g_type_ensure (g_fdo_notification_backend_get_type ());
