[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [albireo-dev] AwtEnvironment & customizability

Gordon,

> What happens if the l&f class has been explicitly set by the user through
> the system property, or though the Swing APIs?

Among that the system properties that UIManager looks at:

  swing.defaultlaf
  swing.auxiliarylaf
  swing.plaf.multiplexinglaf
  swing.installedlafs
  swing.disablenavaids

our setLookAndFeel() call interferes only with the first one.

> It would be better if we did not override the l&f in that  
> case.

Good point. I'm adding the patch below.

> > The reason is that on the Linux system I happen to be using (openSUSE with KDE
> > desktop), the Gtk look&feel of Swing is not well supported: At the beginning
> > I get an error message in the console:
> > /opt/gnome/share/themes/Qt/gtk-2.0/gtkrc:5: Engine "qtengine" is unsupported, ignoring
> 
> I've seen this message before, and it depends on the window manager 
> used, but there's nothing (reasonable) we can do to detect this situation.

But what is your motivation for forcing the Gtk look&feel in the first place?
It does not the look the same as JFace, so it's no clear win compared to
Metal. And it's very ugly in some cases, which Metal isn't.

> > In view of the bug that you found and reported
> >   https://bugs.eclipse.org/bugs/show_bug.cgi?id=126931
> > I think we must even make it
> >   LAFChoiceNativeSystemAvoidGtk
> > when running under JDK 1.6.
> 
> Yes, ideally, this should be the default under 1.6.

OK, applying the second patch below.

Bruno

Index: src/org/eclipse/albireo/core/LookAndFeelHandler.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/core/LookAndFeelHandler.java,v
retrieving revision 1.1
diff -c -3 -r1.1 LookAndFeelHandler.java
*** src/org/eclipse/albireo/core/LookAndFeelHandler.java        25 Jan 2008 15:39:58 -0000      1.1
--- src/org/eclipse/albireo/core/LookAndFeelHandler.java        25 Jan 2008 20:59:24 -0000
***************
*** 115,120 ****
--- 115,126 ----
                 UnsupportedLookAndFeelException {
          assert EventQueue.isDispatchThread(); // On AWT event thread
  
+         // If the user has specified the Swing look&feel through the
+         // system property, and the application has also specified the
+         // look&feel, obey the user. The user is always right.
+         if (System.getProperty("swing.defaultlaf") != null)
+             return;
+ 
          String laf = getLAFChoice();
          if (LAFChoiceSwingDefault.equals(laf)) {
              return;


Index: src/org/eclipse/albireo/core/LookAndFeelHandler.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/core/LookAndFeelHandler.java,v
retrieving revision 1.2
diff -c -3 -r1.2 LookAndFeelHandler.java
*** src/org/eclipse/albireo/core/LookAndFeelHandler.java        25 Jan 2008 21:00:22 -0000      1.2
--- src/org/eclipse/albireo/core/LookAndFeelHandler.java        25 Jan 2008 21:16:27 -0000
***************
*** 70,76 ****
       */
      public static final String LAFChoiceNativeSystemNoGtk = "swing.systemlaf-gtk";
  
!     private String lafChoice = LAFChoiceNativeSystemForceGtk;
  
      /**
       * Returns the look&feel choice. It can be a class name or one
--- 70,91 ----
       */
      public static final String LAFChoiceNativeSystemNoGtk = "swing.systemlaf-gtk";
  
!     private String lafChoice;
!     // Set the default look&feel choice.
!     {
!         // On JDK 1.6, we have to avoid the Swing Gtk look&feel, to work around
!         // https://bugs.eclipse.org/bugs/show_bug.cgi?id=126931
!         String javaVersion = System.getProperty("java.version");
!         if (!(javaVersion.startsWith("1.3")
!               || javaVersion.startsWith("1.4")
!               || javaVersion.startsWith("1.5"))) {
!             lafChoice = LAFChoiceNativeSystemNoGtk;
!         } else {
!             // Gordon prefers LAFChoiceNativeSystemForceGtk here.
!             // Bruno prefers LAFChoiceNativeSystem here.
!             lafChoice = LAFChoiceNativeSystemForceGtk;
!         }
!     }
  
      /**
       * Returns the look&feel choice. It can be a class name or one