summaryrefslogtreecommitdiff
path: root/libjava/jni
diff options
context:
space:
mode:
authorkho <kho@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-27 19:29:57 +0000
committerkho <kho@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-27 19:29:57 +0000
commit55e7bb5cc5290004556654cd1a4b310229835883 (patch)
treea3afb43550d8b4af2eb0c9d58281277ebf3e398d /libjava/jni
parentf005e0cbd6972f817361b053bdda8cc308b11a98 (diff)
downloadgcc-55e7bb5cc5290004556654cd1a4b310229835883.tar.gz
2004-01-27 Kim Ho <kho@redhat.com>
* gnu/java/awt/peer/gtk/GtkFramePeer.java (removeMenuBarPeer): Remove MenuBarPeer argument. * gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java (dispose): Call native method. * java/awt/Frame.java (setMenuBar): Create and remove MenuBar peers only if the Frame has a peer. (addNotify): Create the MenuBar peer if one exists. (removeNotify): Remove MenuBar peer if one exists. * java/awt/Menu.java: Fix imports. (addNotify): Don't use full class name. (removeNotify): Call removeNotify on all children. * java/awt/MenuBar.java (removeNotify): Call removeNotify on all children. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c (removeMenuBarPeer): Remove MenuBarPeer argument. Iterate through children to find the Frame's MenuBar. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c New file. (dispose): Remove references to the MenuComponent. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@76740 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/jni')
-rw-r--r--libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c56
-rw-r--r--libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c23
2 files changed, 77 insertions, 2 deletions
diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c
new file mode 100644
index 00000000000..c30ac29c9c0
--- /dev/null
+++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c
@@ -0,0 +1,56 @@
+/* gtkmenucomponentpeer.c -- Native implementation of GtkMenuComponentPeer
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+#include "gtkpeer.h"
+#include "gnu_java_awt_peer_gtk_GtkMenuComponentPeer.h"
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuComponentPeer_dispose
+ (JNIEnv *env, jobject obj)
+{
+ /* For MenuComponents and its subclasses, the widgets are
+ automatically destroyed by Gtk when the parent MenuBar
+ is removed from the Frame. So we avoid the widget
+ destruction in GtkGenericPeer dispose() by overriding
+ it here. */
+
+ /* However, references to the Java objects still exist in the
+ state tables, so we still have to remove those. */
+
+ NSA_DEL_GLOBAL_REF (env, obj);
+ NSA_DEL_PTR (env, obj);
+}
diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
index 970380683ba..fb82aed82f5 100644
--- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
@@ -376,18 +376,37 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBounds
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkFramePeer_removeMenuBarPeer
- (JNIEnv *env, jobject obj, jobject menubar)
+ (JNIEnv *env, jobject obj)
{
void *wptr;
GtkWidget *box;
GtkWidget *mptr;
+ GList* children;
wptr = NSA_GET_PTR (env, obj);
- mptr = NSA_GET_PTR (env, menubar);
gdk_threads_enter ();
box = GTK_BIN (wptr)->child;
+
+ children = gtk_container_get_children (GTK_CONTAINER (box));
+
+ while (children != NULL && !GTK_IS_MENU_SHELL (children->data))
+ {
+ children = children->next;
+ }
+
+ /* If there isn't a MenuBar in this Frame's list of children
+ then we can just return. */
+ if (!GTK_IS_MENU_SHELL (children->data))
+ return;
+ else
+ mptr = children->data;
+
+ /* This will actually destroy the MenuBar. By removing it from
+ its parent, the reference count for the MenuBar widget will
+ decrement to 0. The widget will be automatically destroyed
+ by Gtk. */
gtk_container_remove (GTK_CONTAINER (box), GTK_WIDGET (mptr));
gdk_threads_leave();