diff options
author | Fernando Nasser <fnasser@redhat.com> | 2004-01-08 21:12:25 +0000 |
---|---|---|
committer | Fernando Nasser <fnasser@gcc.gnu.org> | 2004-01-08 21:12:25 +0000 |
commit | 06fe3d7df20f8da489987f23d298fae98fd6194c (patch) | |
tree | 240ed2d35f3bb8323d793e3af65083d1f6585530 /libjava/java | |
parent | d779bc04df45cfe9c5595bfcaeeddeaf66e7537c (diff) | |
download | gcc-06fe3d7df20f8da489987f23d298fae98fd6194c.zip gcc-06fe3d7df20f8da489987f23d298fae98fd6194c.tar.gz gcc-06fe3d7df20f8da489987f23d298fae98fd6194c.tar.bz2 |
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
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/awt/Dialog.java | 82 |
1 files changed, 77 insertions, 5 deletions
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(); } /*************************************************************************/ |