<Swing Dev> Issue 5090726 - GTK L&F: Need new FileChooserUI to match native GTK 2.4 widget

Costantino Cerbo c.cerbo at gmail.com
Thu Nov 12 21:21:27 UTC 2009


Hallo Pavel

2009/11/12 Pavel Porvatov <Pavel.Porvatov at sun.com>:
> I run the demo and it looks good.
Thanks! I hope we can improve it so much to include it in the OpenJDK.

> Please take a look at my comments:
> 1. Gaps between components differ from the original FileChooser
Maybe do you refer to the Save Dialog? In the Open Dialog they are
quite similar (see the attached screenshot)

> 2. Some bitmaps differ from the original FileChooser
Do you mean the small preview icons near the filename?
This thumbs are in the folder /home/c.cerbo/.thumbnails/normal and
their name is the md5 of the file uri, for example:
  file:///home/c.cerbo/Documenti/Effective_Java.pdf   -->
6e1c7944eac7bc932b2b56c6ac94960f
The bug was that the uri must be encoded according rfc2396 (see
http://www.ietf.org/rfc/rfc2396.txt) and I didn't so, for example
  file:///home/c.cerbo/Documenti/Ciao Belli.pdf  becames
file:///home/c.cerbo/Documenti/Ciao%20Belli.pdf

The new code looks so like (eu.kostia.gtkjfilechooser.GtkStockIcon):
	private static File lookForThumbs(File file) {
		String thumbsFolder = System.getProperty("user.home") + "/.thumbnails/normal";
		String md5 = md5(toFileuri(file));

		File thumn = new File(thumbsFolder + "/" + md5 + ".png");

		if (!thumn.exists()) {
			return null;
		}
		return thumn;
	}

	static String toFileuri(File file) {
		return file.toURI().toASCIIString().replace("file:", "file://");
	}

Regarding the other icons, I get them directly from the actual
implementation in the JDK:
	private static Icon getFromStock(String name, Size size) {
		try {
			Class<?> gtkStockIconClass =
Class.forName("com.sun.java.swing.plaf.gtk.GTKStyle$GTKStockIcon");
			Constructor<?> constructor =
gtkStockIconClass.getDeclaredConstructor(String.class, int.class);
			constructor.setAccessible(true);
			return (Icon) constructor.newInstance(name, size.ordinal());
		} catch (Exception ex) {
			return null;
		}
	}


> 3. I got some errors (see attach)
How do you caused these exceptions? I cannot reproduce them.
Do the folders '/home/fritz/Documents' and '/home/fritz/Music' really exist?
They are some of the so-called "well known" user directories:

$ cat ~/.config/user-dirs.dirs
XDG_DESKTOP_DIR="$HOME/Scrivania"
XDG_DOWNLOAD_DIR="$HOME/Download"
XDG_TEMPLATES_DIR="$HOME/Modelli"
XDG_PUBLICSHARE_DIR="$HOME/Pubblici"
XDG_DOCUMENTS_DIR="$HOME/Documenti"
XDG_MUSIC_DIR="$HOME/Musica"
XDG_PICTURES_DIR="$HOME/Immagini"
XDG_VIDEOS_DIR="$HOME/Video"

Maybe did you manually delete them, but they are still in your ~/.gtk-bookmarks?
Could you check please the content of that file?

Thanks for your support!

Cheers,
Costantino

P.S.: Is there somebody else that may help to further test and improve
the new GtkFileChooser? Now that Java is open source it can become a
more important player in the desktop linux. Furthermore Gnome is also
the standard desktop environment under the Sun OS (Solaris). It's
really a pity, that the GTKLookAndFeel hasn't yet an updated
FileChooser.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot_Open.png
Type: image/png
Size: 118215 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20091112/9756bf02/Screenshot_Open.png>


More information about the swing-dev mailing list