< prev index next >

src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -50,11 +50,12 @@
 
 /**
  * @author Scott Violet
  */
 public class GTKLookAndFeel extends SynthLookAndFeel {
-    private static final boolean IS_22;
+    private static boolean IS_22;
+    private static boolean IS_3;
 
     /**
      * Whether or not text is drawn antialiased.  This keys off the
      * desktop property 'gnome.Xft/Antialias' and 'gnome.Xft/RGBA'
      * We should assume ON - or some variation of ON as no GTK desktop

@@ -103,20 +104,10 @@
      * Cached theme name. Used by GTKGraphicsUtils
      */
     private static String gtkThemeName = "Default";
 
     static {
-        // Backup for specifying the version, this isn't currently documented.
-        // If you pass in anything but 2.2 you got the 2.0 colors/look.
-        String version = AccessController.doPrivileged(
-               new GetPropertyAction("swing.gtk.version"));
-        if (version != null) {
-            IS_22 = version.equals("2.2");
-        }
-        else {
-            IS_22 = true;
-        }
 
         String language = Locale.getDefault().getLanguage();
         boolean cjkLocale =
             (Locale.CHINESE.getLanguage().equals(language) ||
              Locale.JAPANESE.getLanguage().equals(language) ||

@@ -154,10 +145,14 @@
         // need to get the major/minor/micro version from the .so.
         // Refer to bug 4912613 for details.
         return IS_22;
     }
 
+    static boolean is3() {
+        return IS_3;
+    }
+
     /**
      * Maps a swing constant to a GTK constant.
      */
     static PositionType SwingOrientationConstantToGTK(int side) {
         switch (side) {

@@ -543,11 +538,11 @@
                 this.region = region;
             }
             public Object createValue(UIDefaults table) {
                 GTKStyleFactory factory = (GTKStyleFactory)getStyleFactory();
                 GTKStyle style = (GTKStyle)factory.getStyle(null, region);
-                return style.getFontForState(null);
+                return style.getDefaultFont();
             }
         }
 
         Object[] defaults = new Object[] {
             "ArrowButton.size", Integer.valueOf(13),

@@ -1455,10 +1450,23 @@
             !((UNIXToolkit)toolkit).loadGTK())
         {
             throw new InternalError("Unable to load native GTK libraries");
         }
 
+        if (UNIXToolkit.getGtkVersion() == UNIXToolkit.GtkVersions.GTK2) {
+            String version = AccessController.doPrivileged(
+                    new GetPropertyAction("jdk.gtk.version"));
+            if (version != null) {
+                IS_22 = version.equals("2.2");
+            } else {
+                IS_22 = true;
+            }
+        } else if (UNIXToolkit.getGtkVersion() ==
+                                UNIXToolkit.GtkVersions.GTK3) {
+            IS_3 = true;
+        }
+
         super.initialize();
         inInitialize = true;
         loadStyles();
         inInitialize = false;
 
< prev index next >