From dcc737282de36d8fd19d81221a37a7f4f5cd7f95 Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Wed, 7 Jul 2010 14:20:22 +0400 Subject: [PATCH] 6959174: Need to introduce sun.awt.disableGtkFileDialogs system property Reviewed-by: art, anthony --- jdk/src/share/classes/sun/awt/SunToolkit.java | 23 ++++++++++++-- .../solaris/classes/sun/awt/X11/XToolkit.java | 30 ++++++++++++------- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/jdk/src/share/classes/sun/awt/SunToolkit.java b/jdk/src/share/classes/sun/awt/SunToolkit.java index 1768caeefb6..984cb11cc69 100644 --- a/jdk/src/share/classes/sun/awt/SunToolkit.java +++ b/jdk/src/share/classes/sun/awt/SunToolkit.java @@ -1944,6 +1944,25 @@ public abstract class SunToolkit extends Toolkit return (Window)comp; } + /** + * Returns the value of the system property indicated by the specified key. + */ + public static String getSystemProperty(final String key) { + return (String)AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty(key); + } + }); + } + + /** + * Returns the boolean value of the system property indicated by the specified key. + */ + protected static Boolean getBooleanSystemProperty(String key) { + return Boolean.valueOf(AccessController. + doPrivileged(new GetBooleanAction(key))); + } + private static Boolean sunAwtDisableMixing = null; /** @@ -1952,9 +1971,7 @@ public abstract class SunToolkit extends Toolkit */ public synchronized static boolean getSunAwtDisableMixing() { if (sunAwtDisableMixing == null) { - sunAwtDisableMixing = Boolean.valueOf( - AccessController.doPrivileged( - new GetBooleanAction("sun.awt.disableMixing"))); + sunAwtDisableMixing = getBooleanSystemProperty("sun.awt.disableMixing"); } return sunAwtDisableMixing.booleanValue(); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java index 3b98cb032fb..fd8622bd694 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -1053,10 +1053,28 @@ public final class XToolkit extends UNIXToolkit implements Runnable { return peer; } + private static Boolean sunAwtDisableGtkFileDialogs = null; + + /** + * Returns the value of "sun.awt.disableGtkFileDialogs" property. Default + * value is {@code false}. + */ + public synchronized static boolean getSunAwtDisableGtkFileDialogs() { + if (sunAwtDisableGtkFileDialogs == null) { + sunAwtDisableGtkFileDialogs = + getBooleanSystemProperty("sun.awt.disableGtkFileDialogs"); + } + return sunAwtDisableGtkFileDialogs.booleanValue(); + } + public FileDialogPeer createFileDialog(FileDialog target) { + FileDialogPeer peer = null; // The current GtkFileChooser is available from GTK+ 2.4 - FileDialogPeer peer = checkGtkVersion(2, 4, 0) ? new GtkFileDialogPeer( - target) : new XFileDialogPeer(target); + if (!getSunAwtDisableGtkFileDialogs() && checkGtkVersion(2, 4, 0)) { + peer = new GtkFileDialogPeer(target); + } else { + peer = new XFileDialogPeer(target); + } targetCreatedPeer(target, peer); return peer; } @@ -1201,14 +1219,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable { } } - static String getSystemProperty(final String name) { - return (String)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return System.getProperty(name); - } - }); - } - public PrintJob getPrintJob(final Frame frame, final String doctitle, final Properties props) {