<AWT Dev> Bug 6913179, FileDialog uses native GTK under Linux: first patch

Costantino Cerbo c.cerbo at gmail.com
Wed Jan 27 14:48:28 PST 2010

Hi Peter,

2010/1/26 Peter Zhelezniakov <Peter.Zhelezniakov at sun.com>
> - We're going to have two functions that check version of GTK. Does it
> make sense to refactor UNIXToolkit to use the new one? And get rid of
> the old one completely?
Yes, it makes sense. The old method hard codes the version number
2.2.0 and can be fully replaced. But I would address this subject in a
separate issue.

> - Why would you bother with returning a String from
> native_gtk_check_version()? It is effectively ignored later, so you
> could as well return a boolean value from the native function.
Sometime modifying native code may be annoying, therefore I return the
same output as the original C function "gtk_check_version(..)" for the
case that in the future we need these additional information also in
our java Toolkit.
Anyway if you find this disturbing, I can return in the java method a
string as well as in the C function.

> - Most gtk2_interface functions are named gtk2_XXX. However silly this
> is, i believe gtk_file_chooser_load() is better renamed, just for
> consistency =)
No problem ;-)

> - Note that g_thread_get_initialized() is available since glib-2.20
> only. Is there a way to enable the new filechooser on older systems?
I missed that particular... We could use "g_thread_supported()" that
does exactly the same and exists longer.
But it's a macro, not a function and I wasn't able to dynamically load
it with dlsym.
Do you know if it's possible to do that?
In the GTK+ source code there is a comment that let suppose the contrary:
  /* Checks if thread support is initialized.  Identical to the
   * g_thread_supported macro but provided for language bindings.
  gboolean g_thread_get_initialized (void);

Alternatively, we could check the GTK version before to call this
function and for the older versions the shortcut "Search" will

> - Load/unload calls in GtkFileDialogPeer.c seems unbalanced to me. Consider:
> Do you really want to load GTK each time a file dialog is shown? This is pretty expensive. Unloading will also break GTK LAF.
You are right. We can completly remove the calls to "gtk2_load()" and
"gtk2_unload()" in GtkFileDialogPeer.c, because "gtk2_load()" was
already invoked when we return an instance of GtkFileDialogPeer in
XToolkit#createFileDialog and precisely in UNIXToolkit#checkGtkVersion
  public boolean checkGtkVersion(int major, int minor, int micro) {
	if(loadGTK()) {
		return gtkCheckVersionImpl(major, minor, micro) == null;
	return false;

I'll send a new patch after you next comments.


More information about the awt-dev mailing list