1 /* gtkframepeer.c -- Native implementation of GtkFramePeer
2 Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 #include "gnu_java_awt_peer_gtk_GtkFramePeer.h"
41 JNIEXPORT void JNICALL
42 Java_gnu_java_awt_peer_gtk_GtkFramePeer_removeMenuBarPeer
43 (JNIEnv *env, jobject obj)
52 ptr = gtkpeer_get_widget (env, obj);
54 fixed = gtk_container_get_children (GTK_CONTAINER (ptr))->data;
55 children = gtk_container_get_children (GTK_CONTAINER (fixed));
57 while (children != NULL && !GTK_IS_MENU_SHELL (children->data))
59 children = children->next;
62 /* If there's a menu bar, remove it. */
65 mptr = children->data;
67 /* This will actually destroy the MenuBar. By removing it from
68 its parent, the reference count for the MenuBar widget will
69 decrement to 0. The widget will be automatically destroyed by
71 gtk_container_remove (GTK_CONTAINER (fixed), GTK_WIDGET (mptr));
77 JNIEXPORT void JNICALL
78 Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarPeer
79 (JNIEnv *env, jobject obj, jobject menubar)
87 ptr = gtkpeer_get_widget (env, obj);
91 mptr = gtkpeer_get_widget (env, menubar);
93 fixed = gtk_container_get_children (GTK_CONTAINER (ptr))->data;
94 gtk_fixed_put (GTK_FIXED (fixed), mptr, 0, 0);
95 gtk_widget_show (mptr);
101 JNIEXPORT jint JNICALL
102 Java_gnu_java_awt_peer_gtk_GtkFramePeer_getMenuBarHeight
103 (JNIEnv *env, jobject obj __attribute__((unused)), jobject menubar)
106 GtkRequisition requisition;
108 gdk_threads_enter ();
110 ptr = gtkpeer_get_widget (env, menubar);
112 gtk_widget_size_request (ptr, &requisition);
114 gdk_threads_leave ();
116 return requisition.height;
119 JNIEXPORT void JNICALL
120 Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidth
121 (JNIEnv *env, jobject obj, jobject menubar, jint width)
123 gdk_threads_enter ();
125 Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidthUnlocked
126 (env, obj, menubar, width);
128 gdk_threads_leave ();
131 JNIEXPORT void JNICALL
132 Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidthUnlocked
133 (JNIEnv *env, jobject obj __attribute__((unused)), jobject menubar, jint width)
136 GtkRequisition natural_req;
140 ptr = gtkpeer_get_widget (env, menubar);
142 /* Get the menubar's natural size request. */
143 gtk_widget_set_size_request (GTK_WIDGET (ptr), -1, -1);
144 gtk_widget_size_request (GTK_WIDGET (ptr), &natural_req);
146 /* Set the menubar's size request to width by natural_req.height. */
147 gtk_widget_set_size_request (GTK_WIDGET (ptr),
148 width, natural_req.height);
152 JNIEXPORT void JNICALL
153 Java_gnu_java_awt_peer_gtk_GtkFramePeer_gtkFixedSetVisible
154 (JNIEnv *env, jobject obj, jboolean visible)
159 gdk_threads_enter ();
161 ptr = gtkpeer_get_widget (env, obj);
163 fixed = gtk_container_get_children (GTK_CONTAINER (ptr))->data;
166 gtk_widget_show (GTK_WIDGET (fixed));
168 gtk_widget_hide (GTK_WIDGET (fixed));
170 gdk_threads_leave ();
173 JNIEXPORT void JNICALL
174 Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImage
175 (JNIEnv *env, jobject obj, jobject gtkimage)
178 GdkPixbuf *pixbuf = NULL;
180 gdk_threads_enter ();
182 pixbuf = cp_gtk_image_get_pixbuf (env, gtkimage);
183 g_assert (pixbuf != NULL);
185 ptr = gtkpeer_get_widget (env, obj);
187 gtk_window_set_icon (GTK_WINDOW (ptr), pixbuf);
189 gdk_threads_leave ();
192 JNIEXPORT void JNICALL
193 Java_gnu_java_awt_peer_gtk_GtkFramePeer_maximize
194 (JNIEnv *env, jobject obj)
197 gdk_threads_enter ();
198 ptr = gtkpeer_get_widget (env, obj);
199 gtk_window_maximize (GTK_WINDOW (ptr));
200 gdk_threads_leave ();
203 JNIEXPORT void JNICALL
204 Java_gnu_java_awt_peer_gtk_GtkFramePeer_unmaximize
205 (JNIEnv *env, jobject obj)
208 gdk_threads_enter ();
209 ptr = gtkpeer_get_widget (env, obj);
210 gtk_window_unmaximize (GTK_WINDOW (ptr));
211 gdk_threads_leave ();
214 JNIEXPORT void JNICALL
215 Java_gnu_java_awt_peer_gtk_GtkFramePeer_iconify
216 (JNIEnv *env, jobject obj)
219 gdk_threads_enter ();
220 ptr = gtkpeer_get_widget (env, obj);
221 gtk_window_iconify (GTK_WINDOW (ptr));
222 gdk_threads_leave ();
225 JNIEXPORT void JNICALL
226 Java_gnu_java_awt_peer_gtk_GtkFramePeer_deiconify
227 (JNIEnv *env, jobject obj)
230 gdk_threads_enter ();
231 ptr = gtkpeer_get_widget (env, obj);
232 gtk_window_deiconify (GTK_WINDOW (ptr));
233 gdk_threads_leave ();