Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / classpath / native / jni / gtk-peer / gnu_java_awt_peer_gtk_GtkFramePeer.c
blobc60f48f51bba038202d2ec4ca6f0b08db67a349a
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)
9 any later version.
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
19 02110-1301 USA.
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
24 combination.
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. */
38 #include "gtkpeer.h"
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)
45 void *ptr;
46 void *mptr;
47 void *fixed;
48 GList* children;
50 gdk_threads_enter ();
52 ptr = NSA_GET_PTR (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. */
63 if (children != NULL)
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
70 GTK. */
71 gtk_container_remove (GTK_CONTAINER (fixed), GTK_WIDGET (mptr));
74 gdk_threads_leave ();
77 JNIEXPORT void JNICALL
78 Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarPeer
79 (JNIEnv *env, jobject obj, jobject menubar)
81 void *ptr;
82 void *mptr;
83 void *fixed;
85 gdk_threads_enter ();
87 ptr = NSA_GET_PTR (env, obj);
89 if (menubar)
91 mptr = NSA_GET_PTR (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);
98 gdk_threads_leave ();
101 JNIEXPORT jint JNICALL
102 Java_gnu_java_awt_peer_gtk_GtkFramePeer_getMenuBarHeight
103 (JNIEnv *env, jobject obj __attribute__((unused)), jobject menubar)
105 GtkWidget *ptr;
106 GtkRequisition requisition;
108 gdk_threads_enter ();
110 ptr = NSA_GET_PTR (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)
135 GtkWidget *ptr;
136 GtkRequisition natural_req;
138 if (menubar)
140 ptr = NSA_GET_PTR (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)
156 void *ptr;
157 void *fixed;
159 gdk_threads_enter ();
161 ptr = NSA_GET_PTR (env, obj);
163 fixed = gtk_container_get_children (GTK_CONTAINER (ptr))->data;
165 if (visible)
166 gtk_widget_show (GTK_WIDGET (fixed));
167 else
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)
177 void *ptr;
178 GdkPixbuf *pixbuf = NULL;
180 gdk_threads_enter ();
182 pixbuf = cp_gtk_image_get_pixbuf (env, gtkimage);
183 g_assert (pixbuf != NULL);
185 ptr = NSA_GET_PTR (env, obj);
187 gtk_window_set_icon (GTK_WINDOW (ptr), pixbuf);
189 /* if the GtkImage is offscreen, this is a temporary pixbuf which should
190 be thrown out. */
191 if(cp_gtk_image_is_offscreen (env, gtkimage) == JNI_TRUE)
192 gdk_pixbuf_unref (pixbuf);
194 gdk_threads_leave ();