GtkDialogPeer.java (create()): Create a top-level GTK window.

2003-09-19  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GtkDialogPeer.java (create()): Create a
	top-level GTK window.
	(getArgs): Add "title" property.
	* gnu/java/awt/peer/gtk/GtkWindowPeer.java (setResizable): Use
	"allow_shrink" and "allow_grow" properties.
	* java/awt/Dialog.java: Initialize resizable to true and change
	comments accordingly.  Initialize visible to false in
	constructors.
	* java/awt/Frame.java (dispose): Remove method.
	* java/awt/Window.java (ownedWindows): New field.
	(Window(Window,GraphicsConfiguration)): Add a weak reference to
	owner's ownedWindows vector.
	(finalize): Remove method.
	(hide): Hide owned windows.
	(dispose): Dispose of owned windows.
	(getOwnedWindows): Implement.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Remove
	unused GtkArg code.
	(set(String,boolean)): Clamp gboolean parameter to g_object_set
	to TRUE or FALSE.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(create): Set window's size requisition.
	(connectHooks): Fix indentation.
	(setResizable): Remove function.
	(static setBounds): Likewise.
	(setBounds): Replace call to setBounds with GTK size requisition
	and resize calls.

From-SVN: r71585
This commit is contained in:
Thomas Fitzsimmons 2003-09-19 19:27:59 +00:00 committed by Thomas Fitzsimmons
parent 9e3bfa9b75
commit 5ec47f6049
9 changed files with 158 additions and 129 deletions

View file

@ -43,9 +43,13 @@ import java.awt.event.WindowFocusListener;
import java.awt.event.WindowListener;
import java.awt.event.WindowStateListener;
import java.awt.peer.WindowPeer;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.EventListener;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.Vector;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
@ -69,6 +73,9 @@ public class Window extends Container implements Accessible
/** @since 1.4 */
private boolean focusableWindowState = true;
// A list of other top-level windows owned by this window.
private transient Vector ownedWindows = new Vector();
private transient WindowListener windowListener;
private transient WindowFocusListener windowFocusListener;
private transient WindowStateListener windowStateListener;
@ -139,11 +146,13 @@ public class Window extends Container implements Accessible
if (owner == null)
throw new IllegalArgumentException ("owner must not be null");
this.parent = owner;
// FIXME: add to owner's "owned window" list
//owner.owned.add(this); // this should be a weak reference
parent = owner;
synchronized (owner.ownedWindows)
{
owner.ownedWindows.add(new WeakReference(this));
}
// FIXME: make this text visible in the window.
SecurityManager s = System.getSecurityManager();
if (s != null && ! s.checkTopLevelWindow(this))
@ -170,18 +179,6 @@ public class Window extends Container implements Accessible
return super.getGraphicsConfigurationImpl();
}
/**
* Disposes of the input methods and context, and removes the WeakReference
* which formerly pointed to this Window from the parent's owned Window list.
*
* @exception Throwable The Exception raised by this method.
*/
protected void finalize() throws Throwable
{
// FIXME: remove from owner's "owned window" list (Weak References)
super.finalize();
}
/**
* Creates the native peer for this window.
*/
@ -227,7 +224,23 @@ public class Window extends Container implements Accessible
public void hide()
{
// FIXME: call hide() on any "owned" children here.
synchronized (ownedWindows)
{
Iterator e = ownedWindows.iterator();
while(e.hasNext())
{
Window w = (Window)(((Reference) e.next()).get());
if (w != null)
w.hide();
else
// Remove null weak reference from ownedWindows.
// Unfortunately this can't be done in the Window's
// finalize method because there is no way to guarantee
// synchronous access to ownedWindows there.
e.remove();
}
}
super.hide();
}
@ -239,15 +252,26 @@ public class Window extends Container implements Accessible
}
/**
* Called to free any resource associated with this window.
* Destroys any resources associated with this window. This includes
* all components in the window and all owned top-level windows.
*/
public void dispose()
{
hide();
Window[] list = getOwnedWindows();
for (int i=0; i<list.length; i++)
list[i].dispose();
synchronized (ownedWindows)
{
Iterator e = ownedWindows.iterator();
while(e.hasNext())
{
Window w = (Window)(((Reference) e.next()).get());
if (w != null)
w.dispose();
else
// Remove null weak reference from ownedWindows.
e.remove();
}
}
for (int i = 0; i < ncomponents; ++i)
component[i].removeNotify();
@ -340,9 +364,33 @@ public class Window extends Container implements Accessible
/** @since 1.2 */
public Window[] getOwnedWindows()
{
// FIXME: return array containing all the windows this window currently
// owns.
return new Window[0];
Window [] trimmedList;
synchronized (ownedWindows)
{
// Windows with non-null weak references in ownedWindows.
Window [] validList = new Window [ownedWindows.size()];
Iterator e = ownedWindows.iterator();
int numValid = 0;
while (e.hasNext())
{
Window w = (Window)(((Reference) e.next()).get());
if (w != null)
validList[numValid++] = w;
else
// Remove null weak reference from ownedWindows.
e.remove();
}
if (numValid != validList.length)
{
trimmedList = new Window [numValid];
System.arraycopy (validList, 0, trimmedList, 0, numValid);
}
else
trimmedList = validList;
}
return trimmedList;
}
/**