[gtk/gtk-3-24] Disable Quartz Native Filechooser when running earlier than MacOS X 10.6



commit 21694949fce2040279af801542be38134612aa9f
Author: John Ralls <jralls ceridwen us>
Date:   Fri Mar 15 14:09:56 2019 -0700

    Disable Quartz Native Filechooser when running earlier than MacOS X 10.6
    
    Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1685

 gtk/gtkfilechoosernative.c        | 15 +++++++++++----
 gtk/gtkfilechoosernativeprivate.h |  5 +++++
 gtk/gtkfilechoosernativequartz.c  | 10 ++++++++++
 3 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkfilechoosernative.c b/gtk/gtkfilechoosernative.c
index 5801f4891a..b8e90adf57 100644
--- a/gtk/gtkfilechoosernative.c
+++ b/gtk/gtkfilechoosernative.c
@@ -40,6 +40,9 @@
 #include "gtklabel.h"
 #include "gtkfilechooserentry.h"
 #include "gtkfilefilterprivate.h"
+#ifdef GDK_WINDOWING_QUARTZ
+#include <gdk/quartz/gdkquartz.h>
+#endif
 
 /**
  * SECTION:gtkfilechoosernative
@@ -754,8 +757,10 @@ gtk_file_chooser_native_show (GtkNativeDialog *native)
     self->mode = MODE_WIN32;
 #endif
 
-#ifdef GDK_WINDOWING_QUARTZ
-  if (gtk_file_chooser_native_quartz_show (self))
+#if defined (GDK_WINDOWING_QUARTZ) && \
+  MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+    if (gdk_quartz_osx_version() >= GDK_OSX_SNOW_LEOPARD &&
+        gtk_file_chooser_native_quartz_show (self))
     self->mode = MODE_QUARTZ;
 #endif
 
@@ -783,8 +788,10 @@ gtk_file_chooser_native_hide (GtkNativeDialog *native)
 #endif
       break;
     case MODE_QUARTZ:
-#ifdef GDK_WINDOWING_QUARTZ
-      gtk_file_chooser_native_quartz_hide (self);
+#if defined (GDK_WINDOWING_QUARTZ) && \
+  MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+      if (gdk_quartz_osx_version() >= GDK_OSX_SNOW_LEOPARD)
+        gtk_file_chooser_native_quartz_hide (self);
 #endif
       break;
     case MODE_PORTAL:
diff --git a/gtk/gtkfilechoosernativeprivate.h b/gtk/gtkfilechoosernativeprivate.h
index 5749e663dc..2288f0f848 100644
--- a/gtk/gtkfilechoosernativeprivate.h
+++ b/gtk/gtkfilechoosernativeprivate.h
@@ -20,6 +20,9 @@
 #define __GTK_FILE_CHOOSER_NATIVE_PRIVATE_H__
 
 #include <gtk/gtkfilechoosernative.h>
+#ifdef GDK_WINDOWING_QUARTZ
+#include <AvailabilityMacros.h>
+#endif
 
 G_BEGIN_DECLS
 
@@ -58,8 +61,10 @@ struct _GtkFileChooserNative
 gboolean gtk_file_chooser_native_win32_show (GtkFileChooserNative *self);
 void gtk_file_chooser_native_win32_hide (GtkFileChooserNative *self);
 
+#if defined GDK_WINDOWING_QUARTZ && MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
 gboolean gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self);
 void gtk_file_chooser_native_quartz_hide (GtkFileChooserNative *self);
+#endif
 
 gboolean gtk_file_chooser_native_portal_show (GtkFileChooserNative *self);
 void gtk_file_chooser_native_portal_hide (GtkFileChooserNative *self);
diff --git a/gtk/gtkfilechoosernativequartz.c b/gtk/gtkfilechoosernativequartz.c
index 65f2579b90..c1b7225ca8 100644
--- a/gtk/gtkfilechoosernativequartz.c
+++ b/gtk/gtkfilechoosernativequartz.c
@@ -43,6 +43,7 @@
 
 #include "quartz/gdkquartz.h"
 
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
 typedef struct {
   GtkFileChooserNative *self;
 
@@ -451,6 +452,10 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
   GtkWidget *extra_widget = NULL;
   char *message = NULL;
 
+  /* Not supported before MacOS X 10.6 */
+  if (gdk_quartz_osx_version () < GDK_OSX_SNOW_LEOPARD)
+    return FALSE;
+
   extra_widget = gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (self));
   // if the extra_widget is a GtkLabel, then use its text to set the dialog message
   if (extra_widget != NULL)
@@ -562,6 +567,10 @@ gtk_file_chooser_native_quartz_hide (GtkFileChooserNative *self)
 {
   FileChooserQuartzData *data = self->mode_data;
 
+  /* Not supported before MacOS X 10.6 */
+  if (gdk_quartz_osx_version () < GDK_OSX_SNOW_LEOPARD)
+    return;
+
   /* This is always set while dialog visible */
   g_assert (data != NULL);
 
@@ -583,3 +592,4 @@ gtk_file_chooser_native_quartz_hide (GtkFileChooserNative *self)
   data->panel = NULL;
 }
 
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 */


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