From 06fe3d7df20f8da489987f23d298fae98fd6194c Mon Sep 17 00:00:00 2001 From: Fernando Nasser Date: Thu, 8 Jan 2004 21:12:25 +0000 Subject: GtkFileDialogPeer.java (nativeSetFile): New name for the former setFile native method. * gnu/java/awt/peer/gtk/GtkFileDialogPeer.java (nativeSetFile): New name for the former setFile native method. (setFile): New method. (setDirectory): Implemented. (connectSignals): New native method. (setFilenameFilter): Improve comment. (getGraphics): Comment. (gtkHideFileDialog): New method. (gtkDisposeFileDialog): New method. (gtkSetFilename): New method. * java/awt/Dialog.java (show): Block on modal dialogs, but only for FileDialog for now. (hide): New method. (dispose): New method. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c (Java_gnu_java_awt_peer_gtk_GtkFileDialog_create): Replace deprecated creation functions. Make dialog modal. Add it to the window group. (Java_gnu_java_awt_peer_gtk_GtkFileDialog_connectSignals): New function. (Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_gtkFileSelectionSetFilename): Rename to... (Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeSetFile): New name. (window_closed): New function. (ok_clicked): New function. (cancel_clicked): New function. From-SVN: r75557 --- libjava/java/awt/Dialog.java | 82 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 5 deletions(-) (limited to 'libjava/java') diff --git a/libjava/java/awt/Dialog.java b/libjava/java/awt/Dialog.java index ac2e6ed..fd1eb4f 100644 --- a/libjava/java/awt/Dialog.java +++ b/libjava/java/awt/Dialog.java @@ -78,10 +78,15 @@ private boolean resizable = true; */ private String title; - /** - * This field indicates whether the dialog is undecorated or not. - */ - private boolean undecorated = false; +/** + * This field indicates whether the dialog is undecorated or not. + */ +private boolean undecorated = false; + +/** + * Indicates that we are blocked for modality in show + */ +private boolean blocked = false; /*************************************************************************/ @@ -380,11 +385,78 @@ addNotify() /** * Makes this dialog visible and brings it to the front. + * If the dialog is modal and is not already visible, this call will not + * return until the dialog is hidden by someone calling hide or dispose. + * If this is the event dispatching thread we must ensure that another event + * thread runs while the one which invoked this method is blocked. */ -public void +public synchronized void show() { super.show(); + if (isModal()) + { + // If already shown (and blocked) just return + if (blocked) + return; + + /* FIXME: Currently this thread may block forever if it called from + the event dispatch thread, so we only do this for FileDialog which + only depends on a signal which is delivered in the Gtk thread. + Remove this test when we add code to start another event + dispatch thread. */ + if ((Thread.currentThread () instanceof EventDispatchThread) && + !(this instanceof FileDialog)) + return; + + try + { + blocked = true; + wait (); + blocked = false; + } + catch (InterruptedException e) + { + blocked = false; + return; + } + } +} + +/*************************************************************************/ + +/** + * Hides the Dialog and then + * causes show() to return if it is currently blocked. + */ + +public synchronized void +hide () +{ + if (blocked) + { + notifyAll (); + } + + super.hide(); +} + +/*************************************************************************/ + +/** + * Disposes the Dialog and then causes show() to return + * if it is currently blocked. + */ + +public synchronized void +dispose () +{ + if (blocked) + { + notifyAll (); + } + + super.dispose(); } /*************************************************************************/ -- cgit v1.1