author | anthony |
Tue, 30 Nov 2010 17:36:56 +0300 | |
changeset 7243 | 4678eab93673 |
parent 6513 | 83264865df37 |
child 8513 | 101b3095ff5a |
permissions | -rw-r--r-- |
2 | 1 |
/* |
6513
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
#include <dlfcn.h> |
|
26 |
#include <setjmp.h> |
|
27 |
#include <X11/Xlib.h> |
|
28 |
#include <limits.h> |
|
29 |
#include <stdio.h> |
|
30 |
#include <string.h> |
|
31 |
#include "gtk2_interface.h" |
|
32 |
#include "java_awt_Transparency.h" |
|
33 |
||
34 |
#define GTK2_LIB "libgtk-x11-2.0.so.0" |
|
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
35 |
#define GTHREAD_LIB "libgthread-2.0.so.0" |
2 | 36 |
|
37 |
#define G_TYPE_INVALID G_TYPE_MAKE_FUNDAMENTAL (0) |
|
38 |
#define G_TYPE_NONE G_TYPE_MAKE_FUNDAMENTAL (1) |
|
39 |
#define G_TYPE_INTERFACE G_TYPE_MAKE_FUNDAMENTAL (2) |
|
40 |
#define G_TYPE_CHAR G_TYPE_MAKE_FUNDAMENTAL (3) |
|
41 |
#define G_TYPE_UCHAR G_TYPE_MAKE_FUNDAMENTAL (4) |
|
42 |
#define G_TYPE_BOOLEAN G_TYPE_MAKE_FUNDAMENTAL (5) |
|
43 |
#define G_TYPE_INT G_TYPE_MAKE_FUNDAMENTAL (6) |
|
44 |
#define G_TYPE_UINT G_TYPE_MAKE_FUNDAMENTAL (7) |
|
45 |
#define G_TYPE_LONG G_TYPE_MAKE_FUNDAMENTAL (8) |
|
46 |
#define G_TYPE_ULONG G_TYPE_MAKE_FUNDAMENTAL (9) |
|
47 |
#define G_TYPE_INT64 G_TYPE_MAKE_FUNDAMENTAL (10) |
|
48 |
#define G_TYPE_UINT64 G_TYPE_MAKE_FUNDAMENTAL (11) |
|
49 |
#define G_TYPE_ENUM G_TYPE_MAKE_FUNDAMENTAL (12) |
|
50 |
#define G_TYPE_FLAGS G_TYPE_MAKE_FUNDAMENTAL (13) |
|
51 |
#define G_TYPE_FLOAT G_TYPE_MAKE_FUNDAMENTAL (14) |
|
52 |
#define G_TYPE_DOUBLE G_TYPE_MAKE_FUNDAMENTAL (15) |
|
53 |
#define G_TYPE_STRING G_TYPE_MAKE_FUNDAMENTAL (16) |
|
54 |
#define G_TYPE_POINTER G_TYPE_MAKE_FUNDAMENTAL (17) |
|
55 |
#define G_TYPE_BOXED G_TYPE_MAKE_FUNDAMENTAL (18) |
|
56 |
#define G_TYPE_PARAM G_TYPE_MAKE_FUNDAMENTAL (19) |
|
57 |
#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20) |
|
58 |
||
59 |
#define GTK_TYPE_BORDER ((*fp_gtk_border_get_type)()) |
|
60 |
||
61 |
#define G_TYPE_FUNDAMENTAL_SHIFT (2) |
|
62 |
#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT)) |
|
63 |
#define MIN(a, b) (((a) < (b)) ? (a) : (b)) |
|
64 |
||
65 |
#define CONV_BUFFER_SIZE 128 |
|
66 |
||
67 |
#define NO_SYMBOL_EXCEPTION 1 |
|
68 |
||
69 |
/* SynthConstants */ |
|
70 |
const gint ENABLED = 1 << 0; |
|
71 |
const gint MOUSE_OVER = 1 << 1; |
|
72 |
const gint PRESSED = 1 << 2; |
|
73 |
const gint DISABLED = 1 << 3; |
|
74 |
const gint FOCUSED = 1 << 8; |
|
75 |
const gint SELECTED = 1 << 9; |
|
76 |
const gint DEFAULT = 1 << 10; |
|
77 |
||
78 |
static void *gtk2_libhandle = NULL; |
|
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
79 |
static void *gthread_libhandle = NULL; |
5471
0b3ae448170e
6953275: Many Swing tests are failing because of a GTK lib
anthony
parents:
5444
diff
changeset
|
80 |
static gboolean flag_g_thread_get_initialized = FALSE; |
2 | 81 |
static jmp_buf j; |
82 |
||
83 |
/* Widgets */ |
|
84 |
static GtkWidget *gtk2_widget = NULL; |
|
85 |
static GtkWidget *gtk2_window = NULL; |
|
86 |
static GtkFixed *gtk2_fixed = NULL; |
|
87 |
||
88 |
/* Paint system */ |
|
89 |
static GdkPixmap *gtk2_white_pixmap = NULL; |
|
90 |
static GdkPixmap *gtk2_black_pixmap = NULL; |
|
91 |
static GdkPixbuf *gtk2_white_pixbuf = NULL; |
|
92 |
static GdkPixbuf *gtk2_black_pixbuf = NULL; |
|
93 |
static int gtk2_pixbuf_width = 0; |
|
94 |
static int gtk2_pixbuf_height = 0; |
|
95 |
||
96 |
/* Static buffer for conversion from java.lang.String to UTF-8 */ |
|
97 |
static char convertionBuffer[CONV_BUFFER_SIZE]; |
|
98 |
||
2487
f1744cd208ba
6804221: Three tests for JTabbedPane produce VM crash on rhel3
peterz
parents:
715
diff
changeset
|
99 |
static gboolean new_combo = TRUE; |
2 | 100 |
const char ENV_PREFIX[] = "GTK_MODULES="; |
101 |
||
102 |
/*******************/ |
|
103 |
enum GtkWidgetType |
|
104 |
{ |
|
105 |
_GTK_ARROW_TYPE, |
|
106 |
_GTK_BUTTON_TYPE, |
|
107 |
_GTK_CHECK_BUTTON_TYPE, |
|
108 |
_GTK_CHECK_MENU_ITEM_TYPE, |
|
109 |
_GTK_COLOR_SELECTION_DIALOG_TYPE, |
|
110 |
_GTK_COMBO_BOX_TYPE, |
|
111 |
_GTK_COMBO_BOX_ARROW_BUTTON_TYPE, |
|
112 |
_GTK_COMBO_BOX_TEXT_FIELD_TYPE, |
|
113 |
_GTK_CONTAINER_TYPE, |
|
114 |
_GTK_ENTRY_TYPE, |
|
115 |
_GTK_FRAME_TYPE, |
|
116 |
_GTK_HANDLE_BOX_TYPE, |
|
117 |
_GTK_HPANED_TYPE, |
|
118 |
_GTK_HPROGRESS_BAR_TYPE, |
|
119 |
_GTK_HSCALE_TYPE, |
|
120 |
_GTK_HSCROLLBAR_TYPE, |
|
121 |
_GTK_HSEPARATOR_TYPE, |
|
122 |
_GTK_IMAGE_TYPE, |
|
123 |
_GTK_MENU_TYPE, |
|
124 |
_GTK_MENU_BAR_TYPE, |
|
125 |
_GTK_MENU_ITEM_TYPE, |
|
126 |
_GTK_NOTEBOOK_TYPE, |
|
127 |
_GTK_LABEL_TYPE, |
|
128 |
_GTK_RADIO_BUTTON_TYPE, |
|
129 |
_GTK_RADIO_MENU_ITEM_TYPE, |
|
130 |
_GTK_SCROLLED_WINDOW_TYPE, |
|
131 |
_GTK_SEPARATOR_MENU_ITEM_TYPE, |
|
132 |
_GTK_SEPARATOR_TOOL_ITEM_TYPE, |
|
133 |
_GTK_SPIN_BUTTON_TYPE, |
|
134 |
_GTK_TEXT_VIEW_TYPE, |
|
135 |
_GTK_TOGGLE_BUTTON_TYPE, |
|
136 |
_GTK_TOOLBAR_TYPE, |
|
137 |
_GTK_TOOLTIP_TYPE, |
|
138 |
_GTK_TREE_VIEW_TYPE, |
|
139 |
_GTK_VIEWPORT_TYPE, |
|
140 |
_GTK_VPANED_TYPE, |
|
141 |
_GTK_VPROGRESS_BAR_TYPE, |
|
142 |
_GTK_VSCALE_TYPE, |
|
143 |
_GTK_VSCROLLBAR_TYPE, |
|
144 |
_GTK_VSEPARATOR_TYPE, |
|
145 |
_GTK_WINDOW_TYPE, |
|
146 |
_GTK_DIALOG_TYPE, |
|
147 |
_GTK_WIDGET_TYPE_SIZE |
|
148 |
}; |
|
149 |
||
150 |
||
151 |
static GtkWidget *gtk2_widgets[_GTK_WIDGET_TYPE_SIZE]; |
|
152 |
||
153 |
/************************* |
|
154 |
* Glib function pointers |
|
155 |
*************************/ |
|
156 |
||
157 |
static gboolean (*fp_g_main_context_iteration)(GMainContext *context, |
|
158 |
gboolean may_block); |
|
159 |
||
160 |
static GValue* (*fp_g_value_init)(GValue *value, GType g_type); |
|
161 |
static gboolean (*fp_g_type_is_a)(GType type, GType is_a_type); |
|
162 |
static gboolean (*fp_g_value_get_boolean)(const GValue *value); |
|
163 |
static gchar (*fp_g_value_get_char)(const GValue *value); |
|
164 |
static guchar (*fp_g_value_get_uchar)(const GValue *value); |
|
165 |
static gint (*fp_g_value_get_int)(const GValue *value); |
|
166 |
static guint (*fp_g_value_get_uint)(const GValue *value); |
|
167 |
static glong (*fp_g_value_get_long)(const GValue *value); |
|
168 |
static gulong (*fp_g_value_get_ulong)(const GValue *value); |
|
169 |
static gint64 (*fp_g_value_get_int64)(const GValue *value); |
|
170 |
static guint64 (*fp_g_value_get_uint64)(const GValue *value); |
|
171 |
static gfloat (*fp_g_value_get_float)(const GValue *value); |
|
172 |
static gdouble (*fp_g_value_get_double)(const GValue *value); |
|
173 |
static const gchar* (*fp_g_value_get_string)(const GValue *value); |
|
174 |
static gint (*fp_g_value_get_enum)(const GValue *value); |
|
175 |
static guint (*fp_g_value_get_flags)(const GValue *value); |
|
176 |
static GParamSpec* (*fp_g_value_get_param)(const GValue *value); |
|
177 |
static gpointer* (*fp_g_value_get_boxed)(const GValue *value); |
|
178 |
static gpointer* (*fp_g_value_get_pointer)(const GValue *value); |
|
179 |
static GObject* (*fp_g_value_get_object)(const GValue *value); |
|
180 |
static GParamSpec* (*fp_g_param_spec_int)(const gchar *name, |
|
181 |
const gchar *nick, const gchar *blurb, |
|
182 |
gint minimum, gint maximum, gint default_value, |
|
183 |
GParamFlags flags); |
|
184 |
static void (*fp_g_object_get)(gpointer object, |
|
185 |
const gchar* fpn, ...); |
|
186 |
static void (*fp_g_object_set)(gpointer object, |
|
187 |
const gchar *first_property_name, |
|
188 |
...); |
|
189 |
/************************ |
|
190 |
* GDK function pointers |
|
191 |
************************/ |
|
192 |
static GdkPixmap *(*fp_gdk_pixmap_new)(GdkDrawable *drawable, |
|
193 |
gint width, gint height, gint depth); |
|
194 |
static GdkGC *(*fp_gdk_gc_new)(GdkDrawable*); |
|
195 |
static void (*fp_gdk_rgb_gc_set_foreground)(GdkGC*, guint32); |
|
196 |
static void (*fp_gdk_draw_rectangle)(GdkDrawable*, GdkGC*, gboolean, |
|
197 |
gint, gint, gint, gint); |
|
198 |
static GdkPixbuf *(*fp_gdk_pixbuf_new)(GdkColorspace colorspace, |
|
199 |
gboolean has_alpha, int bits_per_sample, int width, int height); |
|
200 |
static GdkPixbuf *(*fp_gdk_pixbuf_get_from_drawable)(GdkPixbuf *dest, |
|
201 |
GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y, |
|
202 |
int dest_x, int dest_y, int width, int height); |
|
203 |
static void (*fp_gdk_drawable_get_size)(GdkDrawable *drawable, |
|
204 |
gint* width, gint* height); |
|
205 |
||
206 |
/************************ |
|
207 |
* Gtk function pointers |
|
208 |
************************/ |
|
209 |
static gboolean (*fp_gtk_init_check)(int* argc, char** argv); |
|
210 |
||
211 |
/* Painting */ |
|
212 |
static void (*fp_gtk_paint_hline)(GtkStyle* style, GdkWindow* window, |
|
213 |
GtkStateType state_type, GdkRectangle* area, GtkWidget* widget, |
|
214 |
const gchar* detail, gint x1, gint x2, gint y); |
|
215 |
static void (*fp_gtk_paint_vline)(GtkStyle* style, GdkWindow* window, |
|
216 |
GtkStateType state_type, GdkRectangle* area, GtkWidget* widget, |
|
217 |
const gchar* detail, gint y1, gint y2, gint x); |
|
218 |
static void (*fp_gtk_paint_shadow)(GtkStyle* style, GdkWindow* window, |
|
219 |
GtkStateType state_type, GtkShadowType shadow_type, |
|
220 |
GdkRectangle* area, GtkWidget* widget, const gchar* detail, |
|
221 |
gint x, gint y, gint width, gint height); |
|
222 |
static void (*fp_gtk_paint_arrow)(GtkStyle* style, GdkWindow* window, |
|
223 |
GtkStateType state_type, GtkShadowType shadow_type, |
|
224 |
GdkRectangle* area, GtkWidget* widget, const gchar* detail, |
|
225 |
GtkArrowType arrow_type, gboolean fill, gint x, gint y, |
|
226 |
gint width, gint height); |
|
227 |
static void (*fp_gtk_paint_diamond)(GtkStyle* style, GdkWindow* window, |
|
228 |
GtkStateType state_type, GtkShadowType shadow_type, |
|
229 |
GdkRectangle* area, GtkWidget* widget, const gchar* detail, |
|
230 |
gint x, gint y, gint width, gint height); |
|
231 |
static void (*fp_gtk_paint_box)(GtkStyle* style, GdkWindow* window, |
|
232 |
GtkStateType state_type, GtkShadowType shadow_type, |
|
233 |
GdkRectangle* area, GtkWidget* widget, const gchar* detail, |
|
234 |
gint x, gint y, gint width, gint height); |
|
235 |
static void (*fp_gtk_paint_flat_box)(GtkStyle* style, GdkWindow* window, |
|
236 |
GtkStateType state_type, GtkShadowType shadow_type, |
|
237 |
GdkRectangle* area, GtkWidget* widget, const gchar* detail, |
|
238 |
gint x, gint y, gint width, gint height); |
|
239 |
static void (*fp_gtk_paint_check)(GtkStyle* style, GdkWindow* window, |
|
240 |
GtkStateType state_type, GtkShadowType shadow_type, |
|
241 |
GdkRectangle* area, GtkWidget* widget, const gchar* detail, |
|
242 |
gint x, gint y, gint width, gint height); |
|
243 |
static void (*fp_gtk_paint_option)(GtkStyle* style, GdkWindow* window, |
|
244 |
GtkStateType state_type, GtkShadowType shadow_type, |
|
245 |
GdkRectangle* area, GtkWidget* widget, const gchar* detail, |
|
246 |
gint x, gint y, gint width, gint height); |
|
247 |
static void (*fp_gtk_paint_box_gap)(GtkStyle* style, GdkWindow* window, |
|
248 |
GtkStateType state_type, GtkShadowType shadow_type, |
|
249 |
GdkRectangle* area, GtkWidget* widget, const gchar* detail, |
|
250 |
gint x, gint y, gint width, gint height, |
|
251 |
GtkPositionType gap_side, gint gap_x, gint gap_width); |
|
252 |
static void (*fp_gtk_paint_extension)(GtkStyle* style, GdkWindow* window, |
|
253 |
GtkStateType state_type, GtkShadowType shadow_type, |
|
254 |
GdkRectangle* area, GtkWidget* widget, const gchar* detail, |
|
255 |
gint x, gint y, gint width, gint height, GtkPositionType gap_side); |
|
256 |
static void (*fp_gtk_paint_focus)(GtkStyle* style, GdkWindow* window, |
|
257 |
GtkStateType state_type, GdkRectangle* area, GtkWidget* widget, |
|
258 |
const gchar* detail, gint x, gint y, gint width, gint height); |
|
259 |
static void (*fp_gtk_paint_slider)(GtkStyle* style, GdkWindow* window, |
|
260 |
GtkStateType state_type, GtkShadowType shadow_type, |
|
261 |
GdkRectangle* area, GtkWidget* widget, const gchar* detail, |
|
262 |
gint x, gint y, gint width, gint height, GtkOrientation orientation); |
|
263 |
static void (*fp_gtk_paint_handle)(GtkStyle* style, GdkWindow* window, |
|
264 |
GtkStateType state_type, GtkShadowType shadow_type, |
|
265 |
GdkRectangle* area, GtkWidget* widget, const gchar* detail, |
|
266 |
gint x, gint y, gint width, gint height, GtkOrientation orientation); |
|
267 |
static void (*fp_gtk_paint_expander)(GtkStyle* style, GdkWindow* window, |
|
268 |
GtkStateType state_type, GdkRectangle* area, GtkWidget* widget, |
|
269 |
const gchar* detail, gint x, gint y, GtkExpanderStyle expander_style); |
|
270 |
static void (*fp_gtk_style_apply_default_background)(GtkStyle* style, |
|
271 |
GdkWindow* window, gboolean set_bg, GtkStateType state_type, |
|
272 |
GdkRectangle* area, gint x, gint y, gint width, gint height); |
|
273 |
||
274 |
/* Widget creation */ |
|
275 |
static GtkWidget* (*fp_gtk_arrow_new)(GtkArrowType arrow_type, |
|
276 |
GtkShadowType shadow_type); |
|
277 |
static GtkWidget* (*fp_gtk_button_new)(); |
|
278 |
static GtkWidget* (*fp_gtk_check_button_new)(); |
|
279 |
static GtkWidget* (*fp_gtk_check_menu_item_new)(); |
|
280 |
static GtkWidget* (*fp_gtk_color_selection_dialog_new)(const gchar* title); |
|
281 |
static GtkWidget* (*fp_gtk_combo_box_new)(); |
|
282 |
static GtkWidget* (*fp_gtk_combo_box_entry_new)(); |
|
283 |
static GtkWidget* (*fp_gtk_entry_new)(); |
|
284 |
static GtkWidget* (*fp_gtk_fixed_new)(); |
|
285 |
static GtkWidget* (*fp_gtk_handle_box_new)(); |
|
286 |
static GtkWidget* (*fp_gtk_hpaned_new)(); |
|
287 |
static GtkWidget* (*fp_gtk_vpaned_new)(); |
|
288 |
static GtkWidget* (*fp_gtk_hscale_new)(GtkAdjustment* adjustment); |
|
289 |
static GtkWidget* (*fp_gtk_vscale_new)(GtkAdjustment* adjustment); |
|
290 |
static GtkWidget* (*fp_gtk_hscrollbar_new)(GtkAdjustment* adjustment); |
|
291 |
static GtkWidget* (*fp_gtk_vscrollbar_new)(GtkAdjustment* adjustment); |
|
292 |
static GtkWidget* (*fp_gtk_hseparator_new)(); |
|
293 |
static GtkWidget* (*fp_gtk_vseparator_new)(); |
|
294 |
static GtkWidget* (*fp_gtk_image_new)(); |
|
295 |
static GtkWidget* (*fp_gtk_label_new)(const gchar* str); |
|
296 |
static GtkWidget* (*fp_gtk_menu_new)(); |
|
297 |
static GtkWidget* (*fp_gtk_menu_bar_new)(); |
|
298 |
static GtkWidget* (*fp_gtk_menu_item_new)(); |
|
299 |
static GtkWidget* (*fp_gtk_notebook_new)(); |
|
300 |
static GtkWidget* (*fp_gtk_progress_bar_new)(); |
|
301 |
static GtkWidget* (*fp_gtk_progress_bar_set_orientation)( |
|
302 |
GtkProgressBar *pbar, |
|
303 |
GtkProgressBarOrientation orientation); |
|
304 |
static GtkWidget* (*fp_gtk_radio_button_new)(GSList *group); |
|
305 |
static GtkWidget* (*fp_gtk_radio_menu_item_new)(GSList *group); |
|
306 |
static GtkWidget* (*fp_gtk_scrolled_window_new)(GtkAdjustment *hadjustment, |
|
307 |
GtkAdjustment *vadjustment); |
|
308 |
static GtkWidget* (*fp_gtk_separator_menu_item_new)(); |
|
309 |
static GtkWidget* (*fp_gtk_separator_tool_item_new)(); |
|
310 |
static GtkWidget* (*fp_gtk_text_view_new)(); |
|
311 |
static GtkWidget* (*fp_gtk_toggle_button_new)(); |
|
312 |
static GtkWidget* (*fp_gtk_toolbar_new)(); |
|
313 |
static GtkWidget* (*fp_gtk_tree_view_new)(); |
|
314 |
static GtkWidget* (*fp_gtk_viewport_new)(GtkAdjustment *hadjustment, |
|
315 |
GtkAdjustment *vadjustment); |
|
316 |
static GtkWidget* (*fp_gtk_window_new)(GtkWindowType type); |
|
317 |
static GtkWidget* (*fp_gtk_dialog_new)(); |
|
318 |
static GtkWidget* (*fp_gtk_spin_button_new)(GtkAdjustment *adjustment, |
|
319 |
gdouble climb_rate, guint digits); |
|
320 |
static GtkWidget* (*fp_gtk_frame_new)(const gchar *label); |
|
321 |
||
322 |
/* Other widget operations */ |
|
323 |
static GtkObject* (*fp_gtk_adjustment_new)(gdouble value, |
|
324 |
gdouble lower, gdouble upper, gdouble step_increment, |
|
325 |
gdouble page_increment, gdouble page_size); |
|
326 |
static void (*fp_gtk_container_add)(GtkContainer *window, GtkWidget *widget); |
|
327 |
static void (*fp_gtk_menu_shell_append)(GtkMenuShell *menu_shell, |
|
328 |
GtkWidget *child); |
|
329 |
static void (*fp_gtk_menu_item_set_submenu)(GtkMenuItem *menu_item, |
|
330 |
GtkWidget *submenu); |
|
331 |
static void (*fp_gtk_widget_realize)(GtkWidget *widget); |
|
332 |
static GdkPixbuf* (*fp_gtk_widget_render_icon)(GtkWidget *widget, |
|
333 |
const gchar *stock_id, GtkIconSize size, const gchar *detail); |
|
334 |
static void (*fp_gtk_widget_set_name)(GtkWidget *widget, const gchar *name); |
|
411 | 335 |
static void (*fp_gtk_widget_set_parent)(GtkWidget *widget, GtkWidget *parent); |
2 | 336 |
static void (*fp_gtk_widget_set_direction)(GtkWidget *widget, |
337 |
GtkTextDirection direction); |
|
338 |
static void (*fp_gtk_widget_style_get)(GtkWidget *widget, |
|
339 |
const gchar *first_property_name, ...); |
|
340 |
static void (*fp_gtk_widget_class_install_style_property)( |
|
341 |
GtkWidgetClass* class, GParamSpec *pspec); |
|
342 |
static GParamSpec* (*fp_gtk_widget_class_find_style_property)( |
|
343 |
GtkWidgetClass* class, const gchar* property_name); |
|
344 |
static void (*fp_gtk_widget_style_get_property)(GtkWidget* widget, |
|
345 |
const gchar* property_name, GValue* value); |
|
346 |
static char* (*fp_pango_font_description_to_string)( |
|
347 |
const PangoFontDescription* fd); |
|
348 |
static GtkSettings* (*fp_gtk_settings_get_default)(); |
|
349 |
static GtkSettings* (*fp_gtk_widget_get_settings)(GtkWidget *widget); |
|
350 |
static GType (*fp_gtk_border_get_type)(); |
|
351 |
static void (*fp_gtk_arrow_set)(GtkWidget* arrow, |
|
352 |
GtkArrowType arrow_type, |
|
353 |
GtkShadowType shadow_type); |
|
354 |
static void (*fp_gtk_widget_size_request)(GtkWidget *widget, |
|
355 |
GtkRequisition *requisition); |
|
356 |
static GtkAdjustment* (*fp_gtk_range_get_adjustment)(GtkRange* range); |
|
357 |
||
358 |
/* Method bodies */ |
|
359 |
const char *getStrFor(JNIEnv *env, jstring val) |
|
360 |
{ |
|
361 |
int length = (*env)->GetStringLength(env, val); |
|
362 |
if (length > CONV_BUFFER_SIZE-1) |
|
363 |
{ |
|
364 |
length = CONV_BUFFER_SIZE-1; |
|
365 |
#ifdef INTERNAL_BUILD |
|
366 |
fprintf(stderr, "Note: Detail is too long: %d chars\n", length); |
|
367 |
#endif /* INTERNAL_BUILD */ |
|
368 |
} |
|
369 |
||
370 |
(*env)->GetStringUTFRegion(env, val, 0, length, convertionBuffer); |
|
371 |
return convertionBuffer; |
|
372 |
} |
|
373 |
||
6513
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
374 |
static void throw_exception(JNIEnv *env, const char* name, const char* message) |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
375 |
{ |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
376 |
jclass class = (*env)->FindClass(env, name); |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
377 |
|
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
378 |
if (class != NULL) |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
379 |
(*env)->ThrowNew(env, class, message); |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
380 |
|
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
381 |
(*env)->DeleteLocalRef(env, class); |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
382 |
} |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
383 |
|
2 | 384 |
/* This is a workaround for the bug: |
385 |
* http://sourceware.org/bugzilla/show_bug.cgi?id=1814 |
|
386 |
* (dlsym/dlopen clears dlerror state) |
|
387 |
* This bug is specific to Linux, but there is no harm in |
|
388 |
* applying this workaround on Solaris as well. |
|
389 |
*/ |
|
390 |
static void* dl_symbol(const char* name) |
|
391 |
{ |
|
392 |
void* result = dlsym(gtk2_libhandle, name); |
|
393 |
if (!result) |
|
394 |
longjmp(j, NO_SYMBOL_EXCEPTION); |
|
395 |
||
396 |
return result; |
|
397 |
} |
|
398 |
||
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
399 |
static void* dl_symbol_gthread(const char* name) |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
400 |
{ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
401 |
void* result = dlsym(gthread_libhandle, name); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
402 |
if (!result) |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
403 |
longjmp(j, NO_SYMBOL_EXCEPTION); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
404 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
405 |
return result; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
406 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
407 |
|
2 | 408 |
gboolean gtk2_check_version() |
409 |
{ |
|
410 |
if (gtk2_libhandle != NULL) { |
|
411 |
/* We've already successfully opened the GTK libs, so return true. */ |
|
412 |
return TRUE; |
|
413 |
} else { |
|
414 |
void *lib = NULL; |
|
415 |
gboolean result = FALSE; |
|
416 |
||
417 |
lib = dlopen(GTK2_LIB, RTLD_LAZY | RTLD_LOCAL); |
|
418 |
if (lib == NULL) { |
|
419 |
return FALSE; |
|
420 |
} |
|
421 |
||
422 |
fp_gtk_check_version = dlsym(lib, "gtk_check_version"); |
|
423 |
/* Check for GTK 2.2+ */ |
|
424 |
if (!fp_gtk_check_version(2, 2, 0)) { |
|
425 |
result = TRUE; |
|
426 |
} |
|
427 |
||
428 |
dlclose(lib); |
|
429 |
||
430 |
return result; |
|
431 |
} |
|
432 |
} |
|
433 |
||
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
434 |
/** |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
435 |
* Functions for sun_awt_X11_GtkFileDialogPeer.c |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
436 |
*/ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
437 |
void gtk2_file_chooser_load() |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
438 |
{ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
439 |
fp_gtk_file_chooser_get_filename = dl_symbol( |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
440 |
"gtk_file_chooser_get_filename"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
441 |
fp_gtk_file_chooser_dialog_new = dl_symbol("gtk_file_chooser_dialog_new"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
442 |
fp_gtk_file_chooser_set_current_folder = dl_symbol( |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
443 |
"gtk_file_chooser_set_current_folder"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
444 |
fp_gtk_file_chooser_set_filename = dl_symbol( |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
445 |
"gtk_file_chooser_set_filename"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
446 |
fp_gtk_file_filter_add_custom = dl_symbol("gtk_file_filter_add_custom"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
447 |
fp_gtk_file_chooser_set_filter = dl_symbol("gtk_file_chooser_set_filter"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
448 |
fp_gtk_file_chooser_get_type = dl_symbol("gtk_file_chooser_get_type"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
449 |
fp_gtk_file_filter_new = dl_symbol("gtk_file_filter_new"); |
5471
0b3ae448170e
6953275: Many Swing tests are failing because of a GTK lib
anthony
parents:
5444
diff
changeset
|
450 |
if (fp_gtk_check_version(2, 8, 0) == NULL) { |
0b3ae448170e
6953275: Many Swing tests are failing because of a GTK lib
anthony
parents:
5444
diff
changeset
|
451 |
fp_gtk_file_chooser_set_do_overwrite_confirmation = dl_symbol( |
0b3ae448170e
6953275: Many Swing tests are failing because of a GTK lib
anthony
parents:
5444
diff
changeset
|
452 |
"gtk_file_chooser_set_do_overwrite_confirmation"); |
0b3ae448170e
6953275: Many Swing tests are failing because of a GTK lib
anthony
parents:
5444
diff
changeset
|
453 |
} |
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
454 |
fp_gtk_file_chooser_set_select_multiple = dl_symbol( |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
455 |
"gtk_file_chooser_set_select_multiple"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
456 |
fp_gtk_file_chooser_get_current_folder = dl_symbol( |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
457 |
"gtk_file_chooser_get_current_folder"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
458 |
fp_gtk_file_chooser_get_filenames = dl_symbol( |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
459 |
"gtk_file_chooser_get_filenames"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
460 |
fp_gtk_g_slist_length = dl_symbol("g_slist_length"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
461 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
462 |
|
2 | 463 |
gboolean gtk2_load() |
464 |
{ |
|
465 |
gboolean result; |
|
466 |
int i; |
|
467 |
int (*handler)(); |
|
468 |
int (*io_handler)(); |
|
469 |
char *gtk_modules_env; |
|
470 |
||
471 |
gtk2_libhandle = dlopen(GTK2_LIB, RTLD_LAZY | RTLD_LOCAL); |
|
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
472 |
gthread_libhandle = dlopen(GTHREAD_LIB, RTLD_LAZY | RTLD_LOCAL); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
473 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
474 |
if (gtk2_libhandle == NULL || gthread_libhandle == NULL) |
2 | 475 |
return FALSE; |
476 |
||
477 |
if (setjmp(j) == 0) |
|
478 |
{ |
|
479 |
fp_gtk_check_version = dl_symbol("gtk_check_version"); |
|
480 |
/* Check for GTK 2.2+ */ |
|
481 |
if (fp_gtk_check_version(2, 2, 0)) { |
|
482 |
longjmp(j, NO_SYMBOL_EXCEPTION); |
|
483 |
} |
|
484 |
||
485 |
/* GLib */ |
|
486 |
fp_g_free = dl_symbol("g_free"); |
|
487 |
fp_g_object_unref = dl_symbol("g_object_unref"); |
|
488 |
||
489 |
fp_g_main_context_iteration = |
|
490 |
dl_symbol("g_main_context_iteration"); |
|
491 |
||
492 |
fp_g_value_init = dl_symbol("g_value_init"); |
|
493 |
fp_g_type_is_a = dl_symbol("g_type_is_a"); |
|
494 |
||
495 |
fp_g_value_get_boolean = dl_symbol("g_value_get_boolean"); |
|
496 |
fp_g_value_get_char = dl_symbol("g_value_get_char"); |
|
497 |
fp_g_value_get_uchar = dl_symbol("g_value_get_uchar"); |
|
498 |
fp_g_value_get_int = dl_symbol("g_value_get_int"); |
|
499 |
fp_g_value_get_uint = dl_symbol("g_value_get_uint"); |
|
500 |
fp_g_value_get_long = dl_symbol("g_value_get_long"); |
|
501 |
fp_g_value_get_ulong = dl_symbol("g_value_get_ulong"); |
|
502 |
fp_g_value_get_int64 = dl_symbol("g_value_get_int64"); |
|
503 |
fp_g_value_get_uint64 = dl_symbol("g_value_get_uint64"); |
|
504 |
fp_g_value_get_float = dl_symbol("g_value_get_float"); |
|
505 |
fp_g_value_get_double = dl_symbol("g_value_get_double"); |
|
506 |
fp_g_value_get_string = dl_symbol("g_value_get_string"); |
|
507 |
fp_g_value_get_enum = dl_symbol("g_value_get_enum"); |
|
508 |
fp_g_value_get_flags = dl_symbol("g_value_get_flags"); |
|
509 |
fp_g_value_get_param = dl_symbol("g_value_get_param"); |
|
510 |
fp_g_value_get_boxed = dl_symbol("g_value_get_boxed"); |
|
511 |
fp_g_value_get_pointer = dl_symbol("g_value_get_pointer"); |
|
512 |
fp_g_value_get_object = dl_symbol("g_value_get_object"); |
|
513 |
fp_g_param_spec_int = dl_symbol("g_param_spec_int"); |
|
514 |
fp_g_object_get = dl_symbol("g_object_get"); |
|
515 |
fp_g_object_set = dl_symbol("g_object_set"); |
|
516 |
||
517 |
/* GDK */ |
|
518 |
fp_gdk_pixmap_new = dl_symbol("gdk_pixmap_new"); |
|
519 |
fp_gdk_pixbuf_get_from_drawable = |
|
520 |
dl_symbol("gdk_pixbuf_get_from_drawable"); |
|
521 |
fp_gdk_gc_new = dl_symbol("gdk_gc_new"); |
|
522 |
fp_gdk_rgb_gc_set_foreground = |
|
523 |
dl_symbol("gdk_rgb_gc_set_foreground"); |
|
524 |
fp_gdk_draw_rectangle = dl_symbol("gdk_draw_rectangle"); |
|
525 |
fp_gdk_drawable_get_size = dl_symbol("gdk_drawable_get_size"); |
|
526 |
||
527 |
/* Pixbuf */ |
|
528 |
fp_gdk_pixbuf_new = dl_symbol("gdk_pixbuf_new"); |
|
529 |
fp_gdk_pixbuf_new_from_file = |
|
530 |
dl_symbol("gdk_pixbuf_new_from_file"); |
|
531 |
fp_gdk_pixbuf_get_width = dl_symbol("gdk_pixbuf_get_width"); |
|
532 |
fp_gdk_pixbuf_get_height = dl_symbol("gdk_pixbuf_get_height"); |
|
533 |
fp_gdk_pixbuf_get_pixels = dl_symbol("gdk_pixbuf_get_pixels"); |
|
534 |
fp_gdk_pixbuf_get_rowstride = |
|
535 |
dl_symbol("gdk_pixbuf_get_rowstride"); |
|
536 |
fp_gdk_pixbuf_get_has_alpha = |
|
537 |
dl_symbol("gdk_pixbuf_get_has_alpha"); |
|
538 |
fp_gdk_pixbuf_get_bits_per_sample = |
|
539 |
dl_symbol("gdk_pixbuf_get_bits_per_sample"); |
|
540 |
fp_gdk_pixbuf_get_n_channels = |
|
541 |
dl_symbol("gdk_pixbuf_get_n_channels"); |
|
542 |
||
543 |
/* GTK painting */ |
|
544 |
fp_gtk_init_check = dl_symbol("gtk_init_check"); |
|
545 |
fp_gtk_paint_hline = dl_symbol("gtk_paint_hline"); |
|
546 |
fp_gtk_paint_vline = dl_symbol("gtk_paint_vline"); |
|
547 |
fp_gtk_paint_shadow = dl_symbol("gtk_paint_shadow"); |
|
548 |
fp_gtk_paint_arrow = dl_symbol("gtk_paint_arrow"); |
|
549 |
fp_gtk_paint_diamond = dl_symbol("gtk_paint_diamond"); |
|
550 |
fp_gtk_paint_box = dl_symbol("gtk_paint_box"); |
|
551 |
fp_gtk_paint_flat_box = dl_symbol("gtk_paint_flat_box"); |
|
552 |
fp_gtk_paint_check = dl_symbol("gtk_paint_check"); |
|
553 |
fp_gtk_paint_option = dl_symbol("gtk_paint_option"); |
|
554 |
fp_gtk_paint_box_gap = dl_symbol("gtk_paint_box_gap"); |
|
555 |
fp_gtk_paint_extension = dl_symbol("gtk_paint_extension"); |
|
556 |
fp_gtk_paint_focus = dl_symbol("gtk_paint_focus"); |
|
557 |
fp_gtk_paint_slider = dl_symbol("gtk_paint_slider"); |
|
558 |
fp_gtk_paint_handle = dl_symbol("gtk_paint_handle"); |
|
559 |
fp_gtk_paint_expander = dl_symbol("gtk_paint_expander"); |
|
560 |
fp_gtk_style_apply_default_background = |
|
561 |
dl_symbol("gtk_style_apply_default_background"); |
|
562 |
||
563 |
/* GTK widgets */ |
|
564 |
fp_gtk_arrow_new = dl_symbol("gtk_arrow_new"); |
|
565 |
fp_gtk_button_new = dl_symbol("gtk_button_new"); |
|
566 |
fp_gtk_spin_button_new = dl_symbol("gtk_spin_button_new"); |
|
567 |
fp_gtk_check_button_new = dl_symbol("gtk_check_button_new"); |
|
568 |
fp_gtk_check_menu_item_new = |
|
569 |
dl_symbol("gtk_check_menu_item_new"); |
|
570 |
fp_gtk_color_selection_dialog_new = |
|
571 |
dl_symbol("gtk_color_selection_dialog_new"); |
|
572 |
fp_gtk_entry_new = dl_symbol("gtk_entry_new"); |
|
573 |
fp_gtk_fixed_new = dl_symbol("gtk_fixed_new"); |
|
574 |
fp_gtk_handle_box_new = dl_symbol("gtk_handle_box_new"); |
|
575 |
fp_gtk_image_new = dl_symbol("gtk_image_new"); |
|
576 |
fp_gtk_hpaned_new = dl_symbol("gtk_hpaned_new"); |
|
577 |
fp_gtk_vpaned_new = dl_symbol("gtk_vpaned_new"); |
|
578 |
fp_gtk_hscale_new = dl_symbol("gtk_hscale_new"); |
|
579 |
fp_gtk_vscale_new = dl_symbol("gtk_vscale_new"); |
|
580 |
fp_gtk_hscrollbar_new = dl_symbol("gtk_hscrollbar_new"); |
|
581 |
fp_gtk_vscrollbar_new = dl_symbol("gtk_vscrollbar_new"); |
|
582 |
fp_gtk_hseparator_new = dl_symbol("gtk_hseparator_new"); |
|
583 |
fp_gtk_vseparator_new = dl_symbol("gtk_vseparator_new"); |
|
584 |
fp_gtk_label_new = dl_symbol("gtk_label_new"); |
|
585 |
fp_gtk_menu_new = dl_symbol("gtk_menu_new"); |
|
586 |
fp_gtk_menu_bar_new = dl_symbol("gtk_menu_bar_new"); |
|
587 |
fp_gtk_menu_item_new = dl_symbol("gtk_menu_item_new"); |
|
588 |
fp_gtk_menu_item_set_submenu = |
|
589 |
dl_symbol("gtk_menu_item_set_submenu"); |
|
590 |
fp_gtk_notebook_new = dl_symbol("gtk_notebook_new"); |
|
591 |
fp_gtk_progress_bar_new = |
|
592 |
dl_symbol("gtk_progress_bar_new"); |
|
593 |
fp_gtk_progress_bar_set_orientation = |
|
594 |
dl_symbol("gtk_progress_bar_set_orientation"); |
|
595 |
fp_gtk_radio_button_new = |
|
596 |
dl_symbol("gtk_radio_button_new"); |
|
597 |
fp_gtk_radio_menu_item_new = |
|
598 |
dl_symbol("gtk_radio_menu_item_new"); |
|
599 |
fp_gtk_scrolled_window_new = |
|
600 |
dl_symbol("gtk_scrolled_window_new"); |
|
601 |
fp_gtk_separator_menu_item_new = |
|
602 |
dl_symbol("gtk_separator_menu_item_new"); |
|
603 |
fp_gtk_text_view_new = dl_symbol("gtk_text_view_new"); |
|
604 |
fp_gtk_toggle_button_new = |
|
605 |
dl_symbol("gtk_toggle_button_new"); |
|
606 |
fp_gtk_toolbar_new = dl_symbol("gtk_toolbar_new"); |
|
607 |
fp_gtk_tree_view_new = dl_symbol("gtk_tree_view_new"); |
|
608 |
fp_gtk_viewport_new = dl_symbol("gtk_viewport_new"); |
|
609 |
fp_gtk_window_new = dl_symbol("gtk_window_new"); |
|
7243 | 610 |
fp_gtk_window_present = dl_symbol("gtk_window_present"); |
2 | 611 |
fp_gtk_dialog_new = dl_symbol("gtk_dialog_new"); |
612 |
fp_gtk_frame_new = dl_symbol("gtk_frame_new"); |
|
613 |
||
614 |
fp_gtk_adjustment_new = dl_symbol("gtk_adjustment_new"); |
|
615 |
fp_gtk_container_add = dl_symbol("gtk_container_add"); |
|
616 |
fp_gtk_menu_shell_append = |
|
617 |
dl_symbol("gtk_menu_shell_append"); |
|
618 |
fp_gtk_widget_realize = dl_symbol("gtk_widget_realize"); |
|
619 |
fp_gtk_widget_destroy = dl_symbol("gtk_widget_destroy"); |
|
620 |
fp_gtk_widget_render_icon = |
|
621 |
dl_symbol("gtk_widget_render_icon"); |
|
622 |
fp_gtk_widget_set_name = |
|
623 |
dl_symbol("gtk_widget_set_name"); |
|
411 | 624 |
fp_gtk_widget_set_parent = |
625 |
dl_symbol("gtk_widget_set_parent"); |
|
2 | 626 |
fp_gtk_widget_set_direction = |
627 |
dl_symbol("gtk_widget_set_direction"); |
|
628 |
fp_gtk_widget_style_get = |
|
629 |
dl_symbol("gtk_widget_style_get"); |
|
630 |
fp_gtk_widget_class_install_style_property = |
|
631 |
dl_symbol("gtk_widget_class_install_style_property"); |
|
632 |
fp_gtk_widget_class_find_style_property = |
|
633 |
dl_symbol("gtk_widget_class_find_style_property"); |
|
634 |
fp_gtk_widget_style_get_property = |
|
635 |
dl_symbol("gtk_widget_style_get_property"); |
|
636 |
fp_pango_font_description_to_string = |
|
637 |
dl_symbol("pango_font_description_to_string"); |
|
638 |
fp_gtk_settings_get_default = |
|
639 |
dl_symbol("gtk_settings_get_default"); |
|
640 |
fp_gtk_widget_get_settings = |
|
641 |
dl_symbol("gtk_widget_get_settings"); |
|
642 |
fp_gtk_border_get_type = dl_symbol("gtk_border_get_type"); |
|
643 |
fp_gtk_arrow_set = dl_symbol("gtk_arrow_set"); |
|
644 |
fp_gtk_widget_size_request = |
|
645 |
dl_symbol("gtk_widget_size_request"); |
|
646 |
fp_gtk_range_get_adjustment = |
|
647 |
dl_symbol("gtk_range_get_adjustment"); |
|
648 |
||
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
649 |
fp_gtk_widget_hide = dl_symbol("gtk_widget_hide"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
650 |
fp_gtk_main_quit = dl_symbol("gtk_main_quit"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
651 |
fp_g_signal_connect_data = dl_symbol("g_signal_connect_data"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
652 |
fp_gtk_widget_show = dl_symbol("gtk_widget_show"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
653 |
fp_gtk_main = dl_symbol("gtk_main"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
654 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
655 |
/** |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
656 |
* GLib thread system |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
657 |
*/ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
658 |
fp_g_thread_init = dl_symbol_gthread("g_thread_init"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
659 |
fp_gdk_threads_init = dl_symbol("gdk_threads_init"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
660 |
fp_gdk_threads_enter = dl_symbol("gdk_threads_enter"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
661 |
fp_gdk_threads_leave = dl_symbol("gdk_threads_leave"); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
662 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
663 |
/** |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
664 |
* Functions for sun_awt_X11_GtkFileDialogPeer.c |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
665 |
*/ |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
666 |
if (fp_gtk_check_version(2, 4, 0) == NULL) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
667 |
// The current GtkFileChooser is available from GTK+ 2.4 |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
668 |
gtk2_file_chooser_load(); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
669 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
670 |
|
2 | 671 |
/* Some functions may be missing in pre-2.4 GTK. |
672 |
We handle them specially here. |
|
673 |
*/ |
|
674 |
fp_gtk_combo_box_new = dlsym(gtk2_libhandle, "gtk_combo_box_new"); |
|
675 |
if (fp_gtk_combo_box_new == NULL) { |
|
676 |
fp_gtk_combo_box_new = dl_symbol("gtk_combo_new"); |
|
677 |
} |
|
678 |
||
679 |
fp_gtk_combo_box_entry_new = |
|
680 |
dlsym(gtk2_libhandle, "gtk_combo_box_entry_new"); |
|
681 |
if (fp_gtk_combo_box_entry_new == NULL) { |
|
682 |
fp_gtk_combo_box_entry_new = dl_symbol("gtk_combo_new"); |
|
2487
f1744cd208ba
6804221: Three tests for JTabbedPane produce VM crash on rhel3
peterz
parents:
715
diff
changeset
|
683 |
new_combo = FALSE; |
2 | 684 |
} |
685 |
||
686 |
fp_gtk_separator_tool_item_new = |
|
687 |
dlsym(gtk2_libhandle, "gtk_separator_tool_item_new"); |
|
688 |
if (fp_gtk_separator_tool_item_new == NULL) { |
|
689 |
fp_gtk_separator_tool_item_new = |
|
690 |
dl_symbol("gtk_vseparator_new"); |
|
691 |
} |
|
692 |
} |
|
693 |
/* Now we have only one kind of exceptions: NO_SYMBOL_EXCEPTION |
|
694 |
* Otherwise we can check the return value of setjmp method. |
|
695 |
*/ |
|
696 |
else |
|
697 |
{ |
|
698 |
dlclose(gtk2_libhandle); |
|
699 |
gtk2_libhandle = NULL; |
|
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
700 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
701 |
dlclose(gthread_libhandle); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
702 |
gthread_libhandle = NULL; |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
703 |
|
2 | 704 |
return FALSE; |
705 |
} |
|
706 |
||
707 |
/* |
|
708 |
* Strip the AT-SPI GTK_MODULEs if present |
|
709 |
*/ |
|
710 |
gtk_modules_env = getenv ("GTK_MODULES"); |
|
711 |
||
712 |
if (gtk_modules_env && strstr (gtk_modules_env, "atk-bridge") || |
|
713 |
gtk_modules_env && strstr (gtk_modules_env, "gail")) |
|
714 |
{ |
|
715 |
/* the new env will be smaller than the old one */ |
|
716 |
gchar *s, *new_env = malloc (sizeof(ENV_PREFIX)+strlen (gtk_modules_env)); |
|
717 |
||
718 |
if (new_env != NULL ) |
|
719 |
{ |
|
720 |
/* careful, strtok modifies its args */ |
|
4270 | 721 |
gchar *tmp_env = strdup (gtk_modules_env); |
2 | 722 |
strcpy(new_env, ENV_PREFIX); |
723 |
||
724 |
/* strip out 'atk-bridge' and 'gail' */ |
|
725 |
size_t PREFIX_LENGTH = strlen(ENV_PREFIX); |
|
726 |
while (s = strtok(tmp_env, ":")) |
|
727 |
{ |
|
728 |
if ((!strstr (s, "atk-bridge")) && (!strstr (s, "gail"))) |
|
729 |
{ |
|
730 |
if (strlen (new_env) > PREFIX_LENGTH) { |
|
731 |
new_env = strcat (new_env, ":"); |
|
732 |
} |
|
733 |
new_env = strcat(new_env, s); |
|
734 |
} |
|
735 |
if (tmp_env) |
|
736 |
{ |
|
737 |
free (tmp_env); |
|
738 |
tmp_env = NULL; /* next call to strtok arg1==NULL */ |
|
739 |
} |
|
740 |
} |
|
741 |
putenv (new_env); |
|
742 |
free (new_env); |
|
743 |
} |
|
744 |
} |
|
745 |
||
746 |
/* |
|
747 |
* GTK should be initialized with gtk_init_check() before use. |
|
748 |
* |
|
749 |
* gtk_init_check installs its own error handlers. It is critical that |
|
750 |
* we preserve error handler set from AWT. Otherwise we'll crash on |
|
751 |
* BadMatch errors which we would normally ignore. The IO error handler |
|
752 |
* is preserved here, too, just for consistency. |
|
753 |
*/ |
|
754 |
handler = XSetErrorHandler(NULL); |
|
755 |
io_handler = XSetIOErrorHandler(NULL); |
|
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
756 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
757 |
if (fp_gtk_check_version(2, 2, 0) == NULL) { |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
758 |
// Init the thread system to use GLib in a thread-safe mode |
5471
0b3ae448170e
6953275: Many Swing tests are failing because of a GTK lib
anthony
parents:
5444
diff
changeset
|
759 |
if (!flag_g_thread_get_initialized) { |
0b3ae448170e
6953275: Many Swing tests are failing because of a GTK lib
anthony
parents:
5444
diff
changeset
|
760 |
flag_g_thread_get_initialized = TRUE; |
0b3ae448170e
6953275: Many Swing tests are failing because of a GTK lib
anthony
parents:
5444
diff
changeset
|
761 |
|
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
762 |
fp_g_thread_init(NULL); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
763 |
|
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
764 |
//According the GTK documentation, gdk_threads_init() should be |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
765 |
//called before gtk_init() or gtk_init_check() |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
766 |
fp_gdk_threads_init(); |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
767 |
} |
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
768 |
} |
2 | 769 |
result = (*fp_gtk_init_check)(NULL, NULL); |
770 |
||
771 |
XSetErrorHandler(handler); |
|
772 |
XSetIOErrorHandler(io_handler); |
|
773 |
||
774 |
/* Initialize widget array. */ |
|
775 |
for (i = 0; i < _GTK_WIDGET_TYPE_SIZE; i++) |
|
776 |
{ |
|
777 |
gtk2_widgets[i] = NULL; |
|
778 |
} |
|
779 |
||
780 |
return result; |
|
781 |
} |
|
782 |
||
783 |
int gtk2_unload() |
|
784 |
{ |
|
785 |
int i; |
|
786 |
char *gtk2_error; |
|
787 |
||
788 |
if (!gtk2_libhandle) |
|
789 |
return TRUE; |
|
790 |
||
791 |
/* Release painting objects */ |
|
792 |
if (gtk2_white_pixmap != NULL) { |
|
793 |
(*fp_g_object_unref)(gtk2_white_pixmap); |
|
794 |
(*fp_g_object_unref)(gtk2_black_pixmap); |
|
795 |
(*fp_g_object_unref)(gtk2_white_pixbuf); |
|
796 |
(*fp_g_object_unref)(gtk2_black_pixbuf); |
|
797 |
gtk2_white_pixmap = gtk2_black_pixmap = |
|
798 |
gtk2_white_pixbuf = gtk2_black_pixbuf = NULL; |
|
799 |
} |
|
800 |
gtk2_pixbuf_width = 0; |
|
801 |
gtk2_pixbuf_height = 0; |
|
802 |
||
803 |
if (gtk2_window != NULL) { |
|
804 |
/* Destroying toplevel widget will destroy all contained widgets */ |
|
805 |
(*fp_gtk_widget_destroy)(gtk2_window); |
|
806 |
||
807 |
/* Unset some static data so they get reinitialized on next load */ |
|
808 |
gtk2_window = NULL; |
|
809 |
} |
|
810 |
||
811 |
dlerror(); |
|
812 |
dlclose(gtk2_libhandle); |
|
5444
f7c5aeb82a14
6913179: The java.awt.FileDialog should use native GTK file chooser on linux distros
anthony
parents:
4270
diff
changeset
|
813 |
dlclose(gthread_libhandle); |
2 | 814 |
if ((gtk2_error = dlerror()) != NULL) |
815 |
{ |
|
816 |
return FALSE; |
|
817 |
} |
|
818 |
return TRUE; |
|
819 |
} |
|
820 |
||
821 |
/* Dispatch all pending events from the GTK event loop. |
|
822 |
* This is needed to catch theme change and update widgets' style. |
|
823 |
*/ |
|
824 |
void flush_gtk_event_loop() |
|
825 |
{ |
|
826 |
while( (*fp_g_main_context_iteration)(NULL, FALSE)); |
|
827 |
} |
|
828 |
||
829 |
/* |
|
830 |
* Initialize components of containment hierarchy. This creates a GtkFixed |
|
831 |
* inside a GtkWindow. All widgets get realized. |
|
832 |
*/ |
|
833 |
static void init_containers() |
|
834 |
{ |
|
835 |
if (gtk2_window == NULL) |
|
836 |
{ |
|
837 |
gtk2_window = (*fp_gtk_window_new)(GTK_WINDOW_TOPLEVEL); |
|
838 |
gtk2_fixed = (GtkFixed *)(*fp_gtk_fixed_new)(); |
|
839 |
(*fp_gtk_container_add)((GtkContainer*)gtk2_window, |
|
840 |
(GtkWidget *)gtk2_fixed); |
|
841 |
(*fp_gtk_widget_realize)(gtk2_window); |
|
842 |
(*fp_gtk_widget_realize)((GtkWidget *)gtk2_fixed); |
|
843 |
} |
|
844 |
} |
|
845 |
||
846 |
/* |
|
847 |
* Ensure everything is ready for drawing an element of the specified width |
|
848 |
* and height. |
|
849 |
* |
|
850 |
* We should somehow handle translucent images. GTK can draw to X Drawables |
|
851 |
* only, which don't support alpha. When we retrieve the image back from |
|
852 |
* the server, translucency information is lost. There're several ways to |
|
853 |
* work around this: |
|
854 |
* 1) Subclass GdkPixmap and cache translucent objects on client side. This |
|
855 |
* requires us to implement parts of X server drawing logic on client side. |
|
856 |
* Many X requests can potentially be "translucent"; e.g. XDrawLine with |
|
857 |
* fill=tile and a translucent tile is a "translucent" operation, whereas |
|
858 |
* XDrawLine with fill=solid is an "opaque" one. Moreover themes can (and some |
|
859 |
* do) intermix transparent and opaque operations which makes caching even |
|
860 |
* more problematic. |
|
861 |
* 2) Use Xorg 32bit ARGB visual when available. GDK has no native support |
|
862 |
* for it (as of version 2.6). Also even in JDS 3 Xorg does not support |
|
863 |
* these visuals by default, which makes optimizing for them pointless. |
|
864 |
* We can consider doing this at a later point when ARGB visuals become more |
|
865 |
* popular. |
|
866 |
* 3') GTK has plans to use Cairo as its graphical backend (presumably in |
|
867 |
* 2.8), and Cairo supports alpha. With it we could also get rid of the |
|
868 |
* unnecessary round trip to server and do all the drawing on client side. |
|
869 |
* 4) For now we draw to two different pixmaps and restore alpha channel by |
|
870 |
* comparing results. This can be optimized by using subclassed pixmap and |
|
871 |
* doing the second drawing only if necessary. |
|
872 |
*/ |
|
6513
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
873 |
void gtk2_init_painting(JNIEnv *env, gint width, gint height) |
2 | 874 |
{ |
875 |
GdkGC *gc; |
|
6513
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
876 |
GdkPixbuf *white, *black; |
2 | 877 |
|
878 |
init_containers(); |
|
879 |
||
880 |
if (gtk2_pixbuf_width < width || gtk2_pixbuf_height < height) |
|
881 |
{ |
|
6513
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
882 |
white = (*fp_gdk_pixbuf_new)(GDK_COLORSPACE_RGB, TRUE, 8, width, height); |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
883 |
black = (*fp_gdk_pixbuf_new)(GDK_COLORSPACE_RGB, TRUE, 8, width, height); |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
884 |
|
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
885 |
if (white == NULL || black == NULL) |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
886 |
{ |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
887 |
snprintf(convertionBuffer, CONV_BUFFER_SIZE, "Couldn't create pixbuf of size %dx%d", width, height); |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
888 |
throw_exception(env, "java/lang/RuntimeException", convertionBuffer); |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
889 |
fp_gdk_threads_leave(); |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
890 |
return; |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
891 |
} |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
892 |
|
2 | 893 |
if (gtk2_white_pixmap != NULL) { |
894 |
/* free old stuff */ |
|
895 |
(*fp_g_object_unref)(gtk2_white_pixmap); |
|
896 |
(*fp_g_object_unref)(gtk2_black_pixmap); |
|
897 |
(*fp_g_object_unref)(gtk2_white_pixbuf); |
|
898 |
(*fp_g_object_unref)(gtk2_black_pixbuf); |
|
899 |
} |
|
900 |
||
6513
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
901 |
gtk2_white_pixmap = (*fp_gdk_pixmap_new)(gtk2_window->window, width, height, -1); |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
902 |
gtk2_black_pixmap = (*fp_gdk_pixmap_new)(gtk2_window->window, width, height, -1); |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
903 |
|
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
904 |
gtk2_white_pixbuf = white; |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
905 |
gtk2_black_pixbuf = black; |
83264865df37
6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
malenkov
parents:
5506
diff
changeset
|
906 |
|
2 | 907 |
gtk2_pixbuf_width = width; |
908 |
gtk2_pixbuf_height = height; |
|
909 |
} |
|
910 |
||
911 |
/* clear the pixmaps */ |
|
912 |
gc = (*fp_gdk_gc_new)(gtk2_white_pixmap); |
|
913 |
(*fp_gdk_rgb_gc_set_foreground)(gc, 0xffffff); |
|
914 |
(*fp_gdk_draw_rectangle)(gtk2_white_pixmap, gc, TRUE, 0, 0, width, height); |
|
915 |
(*fp_g_object_unref)(gc); |
|
916 |
||
917 |
gc = (*fp_gdk_gc_new)(gtk2_black_pixmap); |
|
918 |
(*fp_gdk_rgb_gc_set_foreground)(gc, 0x000000); |
|
919 |
(*fp_gdk_draw_rectangle)(gtk2_black_pixmap, gc, TRUE, 0, 0, width, height); |
|
920 |
(*fp_g_object_unref)(gc); |
|
921 |
} |
|
922 |
||
923 |
/* |
|
924 |
* Restore image from white and black pixmaps and copy it into destination |
|
925 |
* buffer. This method compares two pixbufs taken from white and black |
|
926 |
* pixmaps and decodes color and alpha components. Pixbufs are RGB without |
|
927 |
* alpha, destination buffer is ABGR. |
|
928 |
* |
|
929 |
* The return value is the transparency type of the resulting image, either |
|
930 |
* one of java_awt_Transparency_OPAQUE, java_awt_Transparency_BITMASK, and |
|
931 |
* java_awt_Transparency_TRANSLUCENT. |
|
932 |
*/ |
|
933 |
gint gtk2_copy_image(gint *dst, gint width, gint height) |
|
934 |
{ |
|
935 |
gint i, j, r, g, b; |
|
936 |
guchar *white, *black; |
|
937 |
gint stride, padding; |
|
938 |
gboolean is_opaque = TRUE; |
|
939 |
gboolean is_bitmask = TRUE; |
|
940 |
||
941 |
(*fp_gdk_pixbuf_get_from_drawable)(gtk2_white_pixbuf, gtk2_white_pixmap, |
|
942 |
NULL, 0, 0, 0, 0, width, height); |
|
943 |
(*fp_gdk_pixbuf_get_from_drawable)(gtk2_black_pixbuf, gtk2_black_pixmap, |
|
944 |
NULL, 0, 0, 0, 0, width, height); |
|
945 |
||
946 |
white = (*fp_gdk_pixbuf_get_pixels)(gtk2_white_pixbuf); |
|
947 |
black = (*fp_gdk_pixbuf_get_pixels)(gtk2_black_pixbuf); |
|
948 |
stride = (*fp_gdk_pixbuf_get_rowstride)(gtk2_black_pixbuf); |
|
949 |
padding = stride - width * 4; |
|
950 |
||
951 |
for (i = 0; i < height; i++) { |
|
952 |
for (j = 0; j < width; j++) { |
|
953 |
int r1 = *white++; |
|
954 |
int r2 = *black++; |
|
955 |
int alpha = 0xff + r2 - r1; |
|
956 |
||
957 |
switch (alpha) { |
|
958 |
case 0: /* transparent pixel */ |
|
959 |
r = g = b = 0; |
|
960 |
black += 3; |
|
961 |
white += 3; |
|
962 |
is_opaque = FALSE; |
|
963 |
break; |
|
964 |
||
965 |
case 0xff: /* opaque pixel */ |
|
966 |
r = r2; |
|
967 |
g = *black++; |
|
968 |
b = *black++; |
|
969 |
black++; |
|
970 |
white += 3; |
|
971 |
break; |
|
972 |
||
973 |
default: /* translucent pixel */ |
|
974 |
r = 0xff * r2 / alpha; |
|
975 |
g = 0xff * *black++ / alpha; |
|
976 |
b = 0xff * *black++ / alpha; |
|
977 |
black++; |
|
978 |
white += 3; |
|
979 |
is_opaque = FALSE; |
|
980 |
is_bitmask = FALSE; |
|
981 |
break; |
|
982 |
} |
|
983 |
||
984 |
*dst++ = (alpha << 24 | r << 16 | g << 8 | b); |
|
985 |
} |
|
986 |
||
987 |
white += padding; |
|
988 |
black += padding; |
|
989 |
} |
|
990 |
return is_opaque ? java_awt_Transparency_OPAQUE : |
|
991 |
(is_bitmask ? java_awt_Transparency_BITMASK : |
|
992 |
java_awt_Transparency_TRANSLUCENT); |
|
993 |
} |
|
994 |
||
995 |
static void |
|
996 |
gtk2_set_direction(GtkWidget *widget, GtkTextDirection dir) |
|
997 |
{ |
|
998 |
/* |
|
999 |
* Some engines (inexplicably) look at the direction of the widget's |
|
1000 |
* parent, so we need to set the direction of both the widget and its |
|
1001 |
* parent. |
|
1002 |
*/ |
|
1003 |
(*fp_gtk_widget_set_direction)(widget, dir); |
|
1004 |
if (widget->parent != NULL) { |
|
1005 |
(*fp_gtk_widget_set_direction)(widget->parent, dir); |
|
1006 |
} |
|
1007 |
} |
|
1008 |
||
1009 |
/* |
|
1010 |
* Initializes the widget to correct state for some engines. |
|
1011 |
* This is a pure empirical method. |
|
1012 |
*/ |
|
1013 |
static void init_toggle_widget(WidgetType widget_type, gint synth_state) |
|
1014 |
{ |
|
1015 |
gboolean is_active = ((synth_state & SELECTED) != 0); |
|
1016 |
||
1017 |
if (widget_type == RADIO_BUTTON || |
|
1018 |
widget_type == CHECK_BOX || |
|
1019 |
widget_type == TOGGLE_BUTTON) { |
|
1020 |
((GtkToggleButton*)gtk2_widget)->active = is_active; |
|
1021 |
} |
|
1022 |
||
1023 |
if ((synth_state & FOCUSED) != 0) { |
|
1024 |
((GtkObject*)gtk2_widget)->flags |= GTK_HAS_FOCUS; |
|
1025 |
} else { |
|
1026 |
((GtkObject*)gtk2_widget)->flags &= ~GTK_HAS_FOCUS; |
|
1027 |
} |
|
1028 |
||
1029 |
if ((synth_state & MOUSE_OVER) != 0 && (synth_state & PRESSED) == 0 || |
|
1030 |
(synth_state & FOCUSED) != 0 && (synth_state & PRESSED) != 0) { |
|
1031 |
gtk2_widget->state = GTK_STATE_PRELIGHT; |
|
1032 |
} else if ((synth_state & DISABLED) != 0) { |
|
1033 |
gtk2_widget->state = GTK_STATE_INSENSITIVE; |
|
1034 |
} else { |
|
1035 |
gtk2_widget->state = is_active ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL; |
|
1036 |
} |
|
1037 |
} |
|
1038 |
||
1039 |
/* GTK state_type filter */ |
|
1040 |
static GtkStateType get_gtk_state_type(WidgetType widget_type, gint synth_state) |
|
1041 |
{ |
|
1042 |
GtkStateType result = GTK_STATE_NORMAL; |
|
1043 |
||
1044 |
if ((synth_state & DISABLED) != 0) { |
|
1045 |
result = GTK_STATE_INSENSITIVE; |
|
1046 |
} else if ((synth_state & PRESSED) != 0) { |
|
1047 |
result = GTK_STATE_ACTIVE; |
|
1048 |
} else if ((synth_state & MOUSE_OVER) != 0) { |
|
1049 |
result = GTK_STATE_PRELIGHT; |
|
1050 |
} |
|
1051 |
return result; |
|
1052 |
} |
|
1053 |
||
1054 |
/* GTK shadow_type filter */ |
|
1055 |
static GtkShadowType get_gtk_shadow_type(WidgetType widget_type, gint synth_state) |
|
1056 |
{ |
|
1057 |
GtkShadowType result = GTK_SHADOW_OUT; |
|
1058 |
||
1059 |
if ((synth_state & SELECTED) != 0) { |
|
1060 |
result = GTK_SHADOW_IN; |
|
1061 |
} |
|
1062 |
return result; |
|
1063 |
} |
|
1064 |
||
1065 |
||
1066 |
static GtkWidget* gtk2_get_arrow(GtkArrowType arrow_type, GtkShadowType shadow_type) |
|
1067 |
{ |
|
1068 |
GtkWidget *arrow = NULL; |
|
1069 |
if (NULL == gtk2_widgets[_GTK_ARROW_TYPE]) |
|
1070 |
{ |
|
1071 |
gtk2_widgets[_GTK_ARROW_TYPE] = (*fp_gtk_arrow_new)(arrow_type, shadow_type); |
|
1072 |
(*fp_gtk_container_add)((GtkContainer *)gtk2_fixed, gtk2_widgets[_GTK_ARROW_TYPE]); |
|
1073 |
(*fp_gtk_widget_realize)(gtk2_widgets[_GTK_ARROW_TYPE]); |
|
1074 |
} |
|
1075 |
arrow = gtk2_widgets[_GTK_ARROW_TYPE]; |
|
1076 |
||
1077 |
(*fp_gtk_arrow_set)(arrow, arrow_type, shadow_type); |
|
1078 |
return arrow; |
|
1079 |
} |
|
1080 |
||
1081 |
static GtkAdjustment* create_adjustment() |
|
1082 |
{ |
|
1083 |
return (GtkAdjustment *) |
|
1084 |
(*fp_gtk_adjustment_new)(50.0, 0.0, 100.0, 10.0, 20.0, 20.0); |
|
1085 |
} |
|
1086 |
||
1087 |
/** |
|
1088 |
* Returns a pointer to the cached native widget for the specified widget |
|
1089 |
* type. |
|
1090 |
*/ |
|
1091 |
static GtkWidget *gtk2_get_widget(WidgetType widget_type) |
|
1092 |
{ |
|
1093 |
gboolean init_result = FALSE; |
|
1094 |
GtkWidget *result = NULL; |
|
1095 |
switch (widget_type) |
|
1096 |
{ |
|
1097 |
case BUTTON: |
|
1098 |
case TABLE_HEADER: |
|
1099 |
if (init_result = (NULL == gtk2_widgets[_GTK_BUTTON_TYPE])) |
|
1100 |
{ |
|
1101 |
gtk2_widgets[_GTK_BUTTON_TYPE] = (*fp_gtk_button_new)(); |
|
1102 |
} |
|
1103 |
result = gtk2_widgets[_GTK_BUTTON_TYPE]; |
|
1104 |
break; |
|
1105 |
case CHECK_BOX: |
|
1106 |
if (init_result = (NULL == gtk2_widgets[_GTK_CHECK_BUTTON_TYPE])) |
|
1107 |
{ |
|
1108 |
gtk2_widgets[_GTK_CHECK_BUTTON_TYPE] = |
|
1109 |
(*fp_gtk_check_button_new)(); |
|
1110 |
} |
|
1111 |
result = gtk2_widgets[_GTK_CHECK_BUTTON_TYPE]; |
|
1112 |
break; |
|
1113 |
case CHECK_BOX_MENU_ITEM: |
|
1114 |
if (init_result = (NULL == gtk2_widgets[_GTK_CHECK_MENU_ITEM_TYPE])) |
|
1115 |
{ |
|
1116 |
gtk2_widgets[_GTK_CHECK_MENU_ITEM_TYPE] = |
|
1117 |
(*fp_gtk_check_menu_item_new)(); |
|
1118 |
} |
|
1119 |
result = gtk2_widgets[_GTK_CHECK_MENU_ITEM_TYPE]; |
|
1120 |
break; |
|
1121 |
/************************************************************ |
|
1122 |
* Creation a dedicated color chooser is dangerous because |
|
1123 |
* it deadlocks the EDT |
|
1124 |
************************************************************/ |
|
1125 |
/* case COLOR_CHOOSER: |
|
1126 |
if (init_result = |
|
1127 |
(NULL == gtk2_widgets[_GTK_COLOR_SELECTION_DIALOG_TYPE])) |
|
1128 |
{ |
|
1129 |
gtk2_widgets[_GTK_COLOR_SELECTION_DIALOG_TYPE] = |
|
1130 |
(*fp_gtk_color_selection_dialog_new)(NULL); |
|
1131 |
} |
|
1132 |
result = gtk2_widgets[_GTK_COLOR_SELECTION_DIALOG_TYPE]; |
|
1133 |
break;*/ |
|
1134 |
case COMBO_BOX: |
|
1135 |
if (init_result = (NULL == gtk2_widgets[_GTK_COMBO_BOX_TYPE])) |
|
1136 |
{ |
|
1137 |
gtk2_widgets[_GTK_COMBO_BOX_TYPE] = |
|
1138 |
(*fp_gtk_combo_box_new)(); |
|
1139 |
} |
|
1140 |
result = gtk2_widgets[_GTK_COMBO_BOX_TYPE]; |
|
1141 |
break; |
|
1142 |
case COMBO_BOX_ARROW_BUTTON: |
|
1143 |
if (init_result = |
|
1144 |
(NULL == gtk2_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE])) |
|
1145 |
{ |
|
1146 |
gtk2_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE] = |
|
411 | 1147 |
(*fp_gtk_toggle_button_new)(); |
2 | 1148 |
} |
1149 |
result = gtk2_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE]; |
|
1150 |
break; |
|
1151 |
case COMBO_BOX_TEXT_FIELD: |
|
1152 |
if (init_result = |
|
1153 |
(NULL == gtk2_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE])) |
|
1154 |
{ |
|
1155 |
result = gtk2_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE] = |
|
1156 |
(*fp_gtk_entry_new)(); |
|
1157 |
||
1158 |
GtkSettings* settings = fp_gtk_widget_get_settings(result); |
|
1159 |
fp_g_object_set(settings, "gtk-cursor-blink", FALSE, NULL); |
|
1160 |
} |
|
1161 |
result = gtk2_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE]; |
|
1162 |
break; |
|
1163 |
case DESKTOP_ICON: |
|
1164 |
case INTERNAL_FRAME_TITLE_PANE: |
|
1165 |
case LABEL: |
|
1166 |
if (init_result = (NULL == gtk2_widgets[_GTK_LABEL_TYPE])) |
|
1167 |
{ |
|
1168 |
gtk2_widgets[_GTK_LABEL_TYPE] = |
|
1169 |
(*fp_gtk_label_new)(NULL); |
|
1170 |
} |
|
1171 |
result = gtk2_widgets[_GTK_LABEL_TYPE]; |
|
1172 |
break; |
|
1173 |
case DESKTOP_PANE: |
|
1174 |
case PANEL: |
|
1175 |
case ROOT_PANE: |
|
1176 |
if (init_result = (NULL == gtk2_widgets[_GTK_CONTAINER_TYPE])) |
|
1177 |
{ |
|
1178 |
/* There is no constructor for a container type. I've |
|
1179 |
* choosen GtkFixed container since it has a default |
|
1180 |
* constructor. |
|
1181 |
*/ |
|
1182 |
gtk2_widgets[_GTK_CONTAINER_TYPE] = |
|
1183 |
(*fp_gtk_fixed_new)(); |
|
1184 |
} |
|
1185 |
result = gtk2_widgets[_GTK_CONTAINER_TYPE]; |
|
1186 |
break; |
|
1187 |
case EDITOR_PANE: |
|
1188 |
case TEXT_AREA: |
|
1189 |
case TEXT_PANE: |
|
1190 |
if (init_result = (NULL == gtk2_widgets[_GTK_TEXT_VIEW_TYPE])) |
|
1191 |
{ |
|
1192 |
gtk2_widgets[_GTK_TEXT_VIEW_TYPE] = |
|
1193 |
(*fp_gtk_text_view_new)(); |
|
1194 |
} |
|
1195 |
result = gtk2_widgets[_GTK_TEXT_VIEW_TYPE]; |
|
1196 |
break; |
|
1197 |
case FORMATTED_TEXT_FIELD: |
|
1198 |
case PASSWORD_FIELD: |
|
1199 |
case TEXT_FIELD: |
|
1200 |
if (init_result = (NULL == gtk2_widgets[_GTK_ENTRY_TYPE])) |
|
1201 |
{ |
|
1202 |
gtk2_widgets[_GTK_ENTRY_TYPE] = |
|
1203 |
(*fp_gtk_entry_new)(); |
|
1204 |
||
1205 |
GtkSettings* settings = |
|
1206 |
fp_gtk_widget_get_settings(gtk2_widgets[_GTK_ENTRY_TYPE]); |
|
1207 |
fp_g_object_set(settings, "gtk-cursor-blink", FALSE, NULL); |
|
1208 |
} |
|
1209 |
result = gtk2_widgets[_GTK_ENTRY_TYPE]; |
|
1210 |
break; |
|
1211 |
case HANDLE_BOX: |
|
1212 |
if (init_result = (NULL == gtk2_widgets[_GTK_HANDLE_BOX_TYPE])) |
|
1213 |
{ |
|
1214 |
gtk2_widgets[_GTK_HANDLE_BOX_TYPE] = |
|
1215 |
(*fp_gtk_handle_box_new)(); |
|
1216 |
} |
|
1217 |
result = gtk2_widgets[_GTK_HANDLE_BOX_TYPE]; |
|
1218 |
break; |
|
1219 |
case HSCROLL_BAR: |
|
1220 |
case HSCROLL_BAR_BUTTON_LEFT: |
|
1221 |
case HSCROLL_BAR_BUTTON_RIGHT: |
|
1222 |
case HSCROLL_BAR_TRACK: |
|
1223 |
case HSCROLL_BAR_THUMB: |
|
1224 |
if (init_result = (NULL == gtk2_widgets[_GTK_HSCROLLBAR_TYPE])) |
|
1225 |
{ |
|
1226 |
gtk2_widgets[_GTK_HSCROLLBAR_TYPE] = |
|
1227 |
(*fp_gtk_hscrollbar_new)(create_adjustment()); |
|
1228 |
} |
|
1229 |
result = gtk2_widgets[_GTK_HSCROLLBAR_TYPE]; |
|
1230 |
break; |
|
1231 |
case HSEPARATOR: |
|
1232 |
if (init_result = (NULL == gtk2_widgets[_GTK_HSEPARATOR_TYPE])) |
|
1233 |
{ |
|
1234 |
gtk2_widgets[_GTK_HSEPARATOR_TYPE] = |
|
1235 |
(*fp_gtk_hseparator_new)(); |
|
1236 |
} |
|
1237 |
result = gtk2_widgets[_GTK_HSEPARATOR_TYPE]; |
|
1238 |
break; |
|
1239 |
case HSLIDER: |
|
1240 |
case HSLIDER_THUMB: |
|
1241 |
case HSLIDER_TRACK: |
|
1242 |
if (init_result = (NULL == gtk2_widgets[_GTK_HSCALE_TYPE])) |
|
1243 |
{ |
|
1244 |
gtk2_widgets[_GTK_HSCALE_TYPE] = |
|
1245 |
(*fp_gtk_hscale_new)(NULL); |
|
1246 |
} |
|
1247 |
result = gtk2_widgets[_GTK_HSCALE_TYPE]; |
|
1248 |
break; |
|
1249 |
case HSPLIT_PANE_DIVIDER: |
|
1250 |
case SPLIT_PANE: |
|
1251 |
if (init_result = (NULL == gtk2_widgets[_GTK_HPANED_TYPE])) |
|
1252 |
{ |
|
1253 |
gtk2_widgets[_GTK_HPANED_TYPE] = (*fp_gtk_hpaned_new)(); |
|
1254 |
} |
|
1255 |
result = gtk2_widgets[_GTK_HPANED_TYPE]; |
|
1256 |
break; |
|
1257 |
case IMAGE: |
|
1258 |
if (init_result = (NULL == gtk2_widgets[_GTK_IMAGE_TYPE])) |
|
1259 |
{ |
|
1260 |
gtk2_widgets[_GTK_IMAGE_TYPE] = (*fp_gtk_image_new)(); |
|
1261 |
} |
|
1262 |
result = gtk2_widgets[_GTK_IMAGE_TYPE]; |
|
1263 |
break; |
|
1264 |
case INTERNAL_FRAME: |
|
1265 |
if (init_result = (NULL == gtk2_widgets[_GTK_WINDOW_TYPE])) |
|
1266 |
{ |
|
1267 |
gtk2_widgets[_GTK_WINDOW_TYPE] = |
|
1268 |
(*fp_gtk_window_new)(GTK_WINDOW_TOPLEVEL); |
|
1269 |
} |
|
1270 |
result = gtk2_widgets[_GTK_WINDOW_TYPE]; |
|
1271 |
break; |
|
1272 |
case TOOL_TIP: |
|
1273 |
if (init_result = (NULL == gtk2_widgets[_GTK_TOOLTIP_TYPE])) |
|
1274 |
{ |
|
1275 |
result = (*fp_gtk_window_new)(GTK_WINDOW_TOPLEVEL); |
|
1276 |
(*fp_gtk_widget_set_name)(result, "gtk-tooltips"); |
|
1277 |
gtk2_widgets[_GTK_TOOLTIP_TYPE] = result; |
|
1278 |
} |
|
1279 |
result = gtk2_widgets[_GTK_TOOLTIP_TYPE]; |
|
1280 |
break; |
|
1281 |
case LIST: |
|
1282 |
case TABLE: |
|
1283 |
case TREE: |
|
1284 |
case TREE_CELL: |
|
1285 |
if (init_result = (NULL == gtk2_widgets[_GTK_TREE_VIEW_TYPE])) |
|
1286 |
{ |
|
1287 |
gtk2_widgets[_GTK_TREE_VIEW_TYPE] = |
|
1288 |
(*fp_gtk_tree_view_new)(); |
|
1289 |
} |
|
1290 |
result = gtk2_widgets[_GTK_TREE_VIEW_TYPE]; |
|
1291 |
break; |
|
1292 |
case TITLED_BORDER: |
|
1293 |
if (init_result = (NULL == gtk2_widgets[_GTK_FRAME_TYPE])) |
|
1294 |
{ |
|
1295 |
gtk2_widgets[_GTK_FRAME_TYPE] = fp_gtk_frame_new(NULL); |
|
1296 |
} |
|
1297 |
result = gtk2_widgets[_GTK_FRAME_TYPE]; |
|
1298 |
break; |
|
1299 |
case POPUP_MENU: |
|
1300 |
if (init_result = (NULL == gtk2_widgets[_GTK_MENU_TYPE])) |
|
1301 |
{ |
|
1302 |
gtk2_widgets[_GTK_MENU_TYPE] = |
|
1303 |
(*fp_gtk_menu_new)(); |
|
1304 |
} |
|
1305 |
result = gtk2_widgets[_GTK_MENU_TYPE]; |
|
1306 |
break; |
|
1307 |
case MENU: |
|
1308 |
case MENU_ITEM: |
|
1309 |
case MENU_ITEM_ACCELERATOR: |
|
1310 |
if (init_result = (NULL == gtk2_widgets[_GTK_MENU_ITEM_TYPE])) |
|
1311 |
{ |
|
1312 |
gtk2_widgets[_GTK_MENU_ITEM_TYPE] = |
|
1313 |
(*fp_gtk_menu_item_new)(); |
|
1314 |
} |
|
1315 |
result = gtk2_widgets[_GTK_MENU_ITEM_TYPE]; |
|
1316 |
break; |
|
1317 |
case MENU_BAR: |
|
1318 |
if (init_result = (NULL == gtk2_widgets[_GTK_MENU_BAR_TYPE])) |
|
1319 |
{ |
|
1320 |
gtk2_widgets[_GTK_MENU_BAR_TYPE] = |
|
1321 |
(*fp_gtk_menu_bar_new)(); |
|
1322 |
} |
|
1323 |
result = gtk2_widgets[_GTK_MENU_BAR_TYPE]; |
|
1324 |
break; |
|
1325 |
case COLOR_CHOOSER: |
|
1326 |
case OPTION_PANE: |
|
1327 |
if (init_result = (NULL == gtk2_widgets[_GTK_DIALOG_TYPE])) |
|
1328 |
{ |
|
1329 |
gtk2_widgets[_GTK_DIALOG_TYPE] = |
|
1330 |
(*fp_gtk_dialog_new)(); |
|
1331 |
} |
|
1332 |
result = gtk2_widgets[_GTK_DIALOG_TYPE]; |
|
1333 |
break; |
|
1334 |
case POPUP_MENU_SEPARATOR: |
|
1335 |
if (init_result = |
|
1336 |
(NULL == gtk2_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE])) |
|
1337 |
{ |
|
1338 |
gtk2_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE] = |
|
1339 |
(*fp_gtk_separator_menu_item_new)(); |
|
1340 |
} |
|
1341 |
result = gtk2_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE]; |
|
1342 |
break; |
|
1343 |
case HPROGRESS_BAR: |
|
1344 |
if (init_result = (NULL == gtk2_widgets[_GTK_HPROGRESS_BAR_TYPE])) |
|
1345 |
{ |
|
1346 |
gtk2_widgets[_GTK_HPROGRESS_BAR_TYPE] = |
|
1347 |
(*fp_gtk_progress_bar_new)(); |
|
1348 |
} |
|
1349 |
result = gtk2_widgets[_GTK_HPROGRESS_BAR_TYPE]; |
|
1350 |
break; |
|
1351 |
case VPROGRESS_BAR: |
|
1352 |
if (init_result = (NULL == gtk2_widgets[_GTK_VPROGRESS_BAR_TYPE])) |
|
1353 |
{ |
|
1354 |
gtk2_widgets[_GTK_VPROGRESS_BAR_TYPE] = |
|
1355 |
(*fp_gtk_progress_bar_new)(); |
|
1356 |
/* |
|
1357 |
* Vertical JProgressBars always go bottom-to-top, |
|
1358 |
* regardless of the ComponentOrientation. |
|
1359 |
*/ |
|
1360 |
(*fp_gtk_progress_bar_set_orientation)( |
|
1361 |
(GtkProgressBar *)gtk2_widgets[_GTK_VPROGRESS_BAR_TYPE], |
|
1362 |
GTK_PROGRESS_BOTTOM_TO_TOP); |
|
1363 |
} |
|
1364 |
result = gtk2_widgets[_GTK_VPROGRESS_BAR_TYPE]; |
|
1365 |
break; |
|
1366 |
case RADIO_BUTTON: |
|
1367 |
if (init_result = (NULL == gtk2_widgets[_GTK_RADIO_BUTTON_TYPE])) |
|
1368 |
{ |
|
1369 |
gtk2_widgets[_GTK_RADIO_BUTTON_TYPE] = |
|
1370 |
(*fp_gtk_radio_button_new)(NULL); |
|
1371 |
} |
|
1372 |
result = gtk2_widgets[_GTK_RADIO_BUTTON_TYPE]; |
|
1373 |
break; |
|
1374 |
case RADIO_BUTTON_MENU_ITEM: |
|
1375 |
if (init_result = |
|
1376 |
(NULL == gtk2_widgets[_GTK_RADIO_MENU_ITEM_TYPE])) |
|
1377 |
{ |
|
1378 |
gtk2_widgets[_GTK_RADIO_MENU_ITEM_TYPE] = |
|
1379 |
(*fp_gtk_radio_menu_item_new)(NULL); |
|
1380 |
} |
|
1381 |
result = gtk2_widgets[_GTK_RADIO_MENU_ITEM_TYPE]; |
|
1382 |
break; |
|
1383 |
case SCROLL_PANE: |
|
1384 |
if (init_result = |
|
1385 |
(NULL == gtk2_widgets[_GTK_SCROLLED_WINDOW_TYPE])) |
|
1386 |
{ |
|
1387 |
gtk2_widgets[_GTK_SCROLLED_WINDOW_TYPE] = |
|
1388 |
(*fp_gtk_scrolled_window_new)(NULL, NULL); |
|
1389 |
} |
|
1390 |
result = gtk2_widgets[_GTK_SCROLLED_WINDOW_TYPE]; |
|
1391 |
break; |
|
1392 |
case SPINNER: |
|
1393 |
case SPINNER_ARROW_BUTTON: |
|
1394 |
case SPINNER_TEXT_FIELD: |
|
1395 |
if (init_result = (NULL == gtk2_widgets[_GTK_SPIN_BUTTON_TYPE])) |
|
1396 |
{ |
|
1397 |
result = gtk2_widgets[_GTK_SPIN_BUTTON_TYPE] = |
|
1398 |
(*fp_gtk_spin_button_new)(NULL, 0, 0); |
|
1399 |
||
1400 |
GtkSettings* settings = fp_gtk_widget_get_settings(result); |
|
1401 |
fp_g_object_set(settings, "gtk-cursor-blink", FALSE, NULL); |
|
1402 |
} |
|
1403 |
result = gtk2_widgets[_GTK_SPIN_BUTTON_TYPE]; |
|
1404 |
break; |
|
1405 |
case TABBED_PANE: |
|
1406 |
case TABBED_PANE_TAB_AREA: |
|
1407 |
case TABBED_PANE_CONTENT: |
|
1408 |
case TABBED_PANE_TAB: |
|
1409 |
if (init_result = (NULL == gtk2_widgets[_GTK_NOTEBOOK_TYPE])) |
|
1410 |
{ |
|
1411 |
gtk2_widgets[_GTK_NOTEBOOK_TYPE] = |
|
1412 |
(*fp_gtk_notebook_new)(NULL); |
|
1413 |
} |
|
1414 |
result = gtk2_widgets[_GTK_NOTEBOOK_TYPE]; |
|
1415 |
break; |
|
1416 |
case TOGGLE_BUTTON: |
|
1417 |
if (init_result = (NULL == gtk2_widgets[_GTK_TOGGLE_BUTTON_TYPE])) |
|
1418 |
{ |
|
1419 |
gtk2_widgets[_GTK_TOGGLE_BUTTON_TYPE] = |
|
1420 |
(*fp_gtk_toggle_button_new)(NULL); |
|
1421 |
} |
|
1422 |
result = gtk2_widgets[_GTK_TOGGLE_BUTTON_TYPE]; |
|
1423 |
break; |
|
1424 |
case TOOL_BAR: |
|
1425 |
case TOOL_BAR_DRAG_WINDOW: |
|
1426 |
if (init_result = (NULL == gtk2_widgets[_GTK_TOOLBAR_TYPE])) |
|
1427 |
{ |
|
1428 |
gtk2_widgets[_GTK_TOOLBAR_TYPE] = |
|
1429 |
(*fp_gtk_toolbar_new)(NULL); |
|
1430 |
} |
|
1431 |
result = gtk2_widgets[_GTK_TOOLBAR_TYPE]; |
|
1432 |
break; |
|
1433 |
case TOOL_BAR_SEPARATOR: |
|
1434 |
if (init_result = |
|
1435 |
(NULL == gtk2_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE])) |
|
1436 |
{ |
|
1437 |
gtk2_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE] = |
|
1438 |
(*fp_gtk_separator_tool_item_new)(); |
|
1439 |
} |
|
1440 |
result = gtk2_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE]; |
|
1441 |
break; |
|
1442 |
case VIEWPORT: |
|
1443 |
if (init_result = (NULL == gtk2_widgets[_GTK_VIEWPORT_TYPE])) |
|
1444 |
{ |
|
1445 |
GtkAdjustment *adjustment = create_adjustment(); |
|
1446 |
gtk2_widgets[_GTK_VIEWPORT_TYPE] = |
|
1447 |
(*fp_gtk_viewport_new)(adjustment, adjustment); |
|
1448 |
} |
|
1449 |
result = gtk2_widgets[_GTK_VIEWPORT_TYPE]; |
|
1450 |
break; |
|
1451 |
case VSCROLL_BAR: |
|
1452 |
case VSCROLL_BAR_BUTTON_UP: |
|
1453 |
case VSCROLL_BAR_BUTTON_DOWN: |
|
1454 |
case VSCROLL_BAR_TRACK: |
|
1455 |
case VSCROLL_BAR_THUMB: |
|
1456 |
if (init_result = (NULL == gtk2_widgets[_GTK_VSCROLLBAR_TYPE])) |
|
1457 |
{ |
|
1458 |
gtk2_widgets[_GTK_VSCROLLBAR_TYPE] = |
|
1459 |
(*fp_gtk_vscrollbar_new)(create_adjustment()); |
|
1460 |
} |
|
1461 |
result = gtk2_widgets[_GTK_VSCROLLBAR_TYPE]; |
|
1462 |
break; |
|
1463 |
case VSEPARATOR: |
|
1464 |
if (init_result = (NULL == gtk2_widgets[_GTK_VSEPARATOR_TYPE])) |
|
1465 |
{ |
|
1466 |
gtk2_widgets[_GTK_VSEPARATOR_TYPE] = |
|
1467 |
(*fp_gtk_vseparator_new)(); |
|
1468 |
} |
|
1469 |
result = gtk2_widgets[_GTK_VSEPARATOR_TYPE]; |
|
1470 |
break; |
|
1471 |
case VSLIDER: |
|
1472 |
case VSLIDER_THUMB: |
|
1473 |
case VSLIDER_TRACK: |
|
1474 |
if (init_result = (NULL == gtk2_widgets[_GTK_VSCALE_TYPE])) |
|
1475 |
{ |
|
1476 |
gtk2_widgets[_GTK_VSCALE_TYPE] = |
|
1477 |
(*fp_gtk_vscale_new)(NULL); |
|
1478 |
} |
|
1479 |
result = gtk2_widgets[_GTK_VSCALE_TYPE]; |
|
1480 |
/* |
|
1481 |
* Vertical JSliders start at the bottom, while vertical |
|
1482 |
* GtkVScale widgets start at the top (by default), so to fix |
|
1483 |
* this we set the "inverted" flag to get the Swing behavior. |
|
1484 |
*/ |
|
1485 |
((GtkRange*)result)->inverted = 1; |
|
1486 |
break; |
|
1487 |
case VSPLIT_PANE_DIVIDER: |
|
1488 |
if (init_result = (NULL == gtk2_widgets[_GTK_VPANED_TYPE])) |
|
1489 |
{ |
|
1490 |
gtk2_widgets[_GTK_VPANED_TYPE] = (*fp_gtk_vpaned_new)(); |
|
1491 |
} |
|
1492 |
result = gtk2_widgets[_GTK_VPANED_TYPE]; |
|
1493 |
break; |
|
1494 |
default: |
|
1495 |
result = NULL; |
|
1496 |
break; |
|
1497 |
} |
|
1498 |
||
1499 |
if (result != NULL && init_result) |
|
1500 |
{ |
|
1501 |
if (widget_type == RADIO_BUTTON_MENU_ITEM || |
|
1502 |
widget_type == CHECK_BOX_MENU_ITEM || |
|
1503 |
widget_type == MENU_ITEM || |
|
1504 |
widget_type == MENU || |
|
1505 |
widget_type == POPUP_MENU_SEPARATOR) |
|
1506 |
{ |
|
1507 |
GtkWidget *menu = gtk2_get_widget(POPUP_MENU); |
|
1508 |
(*fp_gtk_menu_shell_append)((GtkMenuShell *)menu, result); |
|
1509 |
} |
|
1510 |
else if (widget_type == POPUP_MENU) |
|
1511 |
{ |
|
1512 |
GtkWidget *menu_bar = gtk2_get_widget(MENU_BAR); |
|
1513 |
GtkWidget *root_menu = (*fp_gtk_menu_item_new)(); |
|
1514 |
(*fp_gtk_menu_item_set_submenu)((GtkMenuItem*)root_menu, result); |
|
1515 |
(*fp_gtk_menu_shell_append)((GtkMenuShell *)menu_bar, root_menu); |
|
1516 |
} |
|
1517 |
else if (widget_type == COMBO_BOX_ARROW_BUTTON || |
|
1518 |
widget_type == COMBO_BOX_TEXT_FIELD) |
|
1519 |
{ |
|
1520 |
/* |
|
411 | 1521 |
* We add a regular GtkButton/GtkEntry to a GtkComboBoxEntry |
1522 |
* in order to trick engines into thinking it's a real combobox |
|
1523 |
* arrow button/text field. |
|
1524 |
*/ |
|
2 | 1525 |
GtkWidget *combo = (*fp_gtk_combo_box_entry_new)(); |
411 | 1526 |
|
2487
f1744cd208ba
6804221: Three tests for JTabbedPane produce VM crash on rhel3
peterz
parents:
715
diff
changeset
|
1527 |
if (new_combo && widget_type == COMBO_BOX_ARROW_BUTTON) { |
411 | 1528 |
(*fp_gtk_widget_set_parent)(result, combo); |
1529 |
((GtkBin*)combo)->child = result; |
|
2487
f1744cd208ba
6804221: Three tests for JTabbedPane produce VM crash on rhel3
peterz
parents:
715
diff
changeset
|
1530 |
} else { |
f1744cd208ba
6804221: Three tests for JTabbedPane produce VM crash on rhel3
peterz
parents:
715
diff
changeset
|
1531 |
(*fp_gtk_container_add)((GtkContainer *)combo, result); |
411 | 1532 |
} |
2 | 1533 |
(*fp_gtk_container_add)((GtkContainer *)gtk2_fixed, combo); |
1534 |
} |
|
1535 |
else if (widget_type != TOOL_TIP && |
|
1536 |
widget_type != INTERNAL_FRAME && |
|
1537 |
widget_type != OPTION_PANE) |
|
1538 |
{ |
|
1539 |
(*fp_gtk_container_add)((GtkContainer *)gtk2_fixed, result); |
|
1540 |
} |
|
1541 |
(*fp_gtk_widget_realize)(result); |
|
1542 |
} |
|
1543 |
return result; |
|
1544 |
} |
|
1545 |
||
1546 |
void gtk2_paint_arrow(WidgetType widget_type, GtkStateType state_type, |
|
1547 |
GtkShadowType shadow_type, const gchar *detail, |
|
1548 |
gint x, gint y, gint width, gint height, |
|
1549 |
GtkArrowType arrow_type, gboolean fill) |
|
1550 |
{ |
|
1551 |
static int w, h; |
|
1552 |
static GtkRequisition size; |
|
1553 |
||
1554 |
if (widget_type == COMBO_BOX_ARROW_BUTTON || widget_type == TABLE) |
|
1555 |
gtk2_widget = gtk2_get_arrow(arrow_type, shadow_type); |
|
1556 |
else |
|
1557 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1558 |
||
1559 |
switch (widget_type) |
|
1560 |
{ |
|
1561 |
case SPINNER_ARROW_BUTTON: |
|
1562 |
x = 1; |
|
1563 |
y = ((arrow_type == GTK_ARROW_UP) ? 2 : 0); |
|
1564 |
height -= 2; |
|
1565 |
width -= 3; |
|
1566 |
||
1567 |
w = width / 2; |
|
1568 |
w -= w % 2 - 1; |
|
1569 |
h = (w + 1) / 2; |
|
1570 |
break; |
|
1571 |
||
1572 |
case HSCROLL_BAR_BUTTON_LEFT: |
|
1573 |
case HSCROLL_BAR_BUTTON_RIGHT: |
|
1574 |
case VSCROLL_BAR_BUTTON_UP: |
|
1575 |
case VSCROLL_BAR_BUTTON_DOWN: |
|
1576 |
w = width / 2; |
|
1577 |
h = height / 2; |
|
1578 |
break; |
|
1579 |
||
1580 |
case COMBO_BOX_ARROW_BUTTON: |
|
1581 |
case TABLE: |
|
1582 |
x = 1; |
|
1583 |
(*fp_gtk_widget_size_request)(gtk2_widget, &size); |
|
1584 |
w = size.width - ((GtkMisc*)gtk2_widget)->xpad * 2; |
|
1585 |
h = size.height - ((GtkMisc*)gtk2_widget)->ypad * 2; |
|
1586 |
w = h = MIN(MIN(w, h), MIN(width,height)) * 0.7; |
|
1587 |
break; |
|
1588 |
||
1589 |
default: |
|
1590 |
w = width; |
|
1591 |
h = height; |
|
1592 |
break; |
|
1593 |
} |
|
1594 |
x += (width - w) / 2; |
|
1595 |
y += (height - h) / 2; |
|
1596 |
||
1597 |
(*fp_gtk_paint_arrow)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1598 |
shadow_type, NULL, gtk2_widget, detail, arrow_type, fill, |
|
1599 |
x, y, w, h); |
|
1600 |
(*fp_gtk_paint_arrow)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1601 |
shadow_type, NULL, gtk2_widget, detail, arrow_type, fill, |
|
1602 |
x, y, w, h); |
|
1603 |
} |
|
1604 |
||
1605 |
void gtk2_paint_box(WidgetType widget_type, GtkStateType state_type, |
|
1606 |
GtkShadowType shadow_type, const gchar *detail, |
|
1607 |
gint x, gint y, gint width, gint height, |
|
1608 |
gint synth_state, GtkTextDirection dir) |
|
1609 |
{ |
|
1610 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1611 |
||
1612 |
/* |
|
1613 |
* The clearlooks engine sometimes looks at the widget's state field |
|
1614 |
* instead of just the state_type variable that we pass in, so to account |
|
1615 |
* for those cases we set the widget's state field accordingly. The |
|
1616 |
* flags field is similarly important for things like focus/default state. |
|
1617 |
*/ |
|
1618 |
gtk2_widget->state = state_type; |
|
1619 |
||
1620 |
if (widget_type == HSLIDER_TRACK) { |
|
1621 |
/* |
|
1622 |
* For horizontal JSliders with right-to-left orientation, we need |
|
1623 |
* to set the "inverted" flag to match the native GTK behavior where |
|
1624 |
* the foreground highlight is on the right side of the slider thumb. |
|
1625 |
* This is needed especially for the ubuntulooks engine, which looks |
|
1626 |
* exclusively at the "inverted" flag to determine on which side of |
|
1627 |
* the thumb to paint the highlight... |
|
1628 |
*/ |
|
1629 |
((GtkRange*)gtk2_widget)->inverted = (dir == GTK_TEXT_DIR_RTL); |
|
1630 |
||
1631 |
/* |
|
1632 |
* Note however that other engines like clearlooks will look at both |
|
1633 |
* the "inverted" field and the text direction to determine how |
|
1634 |
* the foreground highlight is painted: |
|
1635 |
* !inverted && ltr --> paint highlight on left side |
|
1636 |
* !inverted && rtl --> paint highlight on right side |
|
1637 |
* inverted && ltr --> paint highlight on right side |
|
1638 |
* inverted && rtl --> paint highlight on left side |
|
1639 |
* So the only way to reliably get the desired results for horizontal |
|
1640 |
* JSlider (i.e., highlight on left side for LTR ComponentOrientation |
|
1641 |
* and highlight on right side for RTL ComponentOrientation) is to |
|
1642 |
* always override text direction as LTR, and then set the "inverted" |
|
1643 |
* flag accordingly (as we have done above). |
|
1644 |
*/ |
|
1645 |
dir = GTK_TEXT_DIR_LTR; |
|
1646 |
} |
|
1647 |
||
1648 |
/* |
|
1649 |
* Some engines (e.g. clearlooks) will paint the shadow of certain |
|
1650 |
* widgets (e.g. COMBO_BOX_ARROW_BUTTON) differently depending on the |
|
1651 |
* the text direction. |
|
1652 |
*/ |
|
1653 |
gtk2_set_direction(gtk2_widget, dir); |
|
1654 |
||
1655 |
switch (widget_type) { |
|
1656 |
case BUTTON: |
|
1657 |
if (synth_state & DEFAULT) { |
|
1658 |
((GtkObject*)gtk2_widget)->flags |= GTK_HAS_DEFAULT; |
|
1659 |
} else { |
|
1660 |
((GtkObject*)gtk2_widget)->flags &= ~GTK_HAS_DEFAULT; |
|
1661 |
} |
|
1662 |
break; |
|
1663 |
case TOGGLE_BUTTON: |
|
1664 |
init_toggle_widget(widget_type, synth_state); |
|
1665 |
break; |
|
1666 |
case HSCROLL_BAR_BUTTON_LEFT: |
|
1667 |
/* |
|
1668 |
* The clearlooks engine will draw a "left" button when: |
|
1669 |
* x == w->allocation.x |
|
1670 |
* |
|
1671 |
* The ubuntulooks engine will draw a "left" button when: |
|
1672 |
* [x,y,width,height] |
|
1673 |
* intersects |
|
1674 |
* [w->alloc.x,w->alloc.y,width,height] |
|
1675 |
* |
|
1676 |
* The values that are set below should ensure that a "left" |
|
1677 |
* button is rendered for both of these (and other) engines. |
|
1678 |
*/ |
|
1679 |
gtk2_widget->allocation.x = x; |
|
1680 |
gtk2_widget->allocation.y = y; |
|
1681 |
gtk2_widget->allocation.width = width; |
|
1682 |
gtk2_widget->allocation.height = height; |
|
1683 |
break; |
|
1684 |
case HSCROLL_BAR_BUTTON_RIGHT: |
|
1685 |
/* |
|
1686 |
* The clearlooks engine will draw a "right" button when: |
|
1687 |
* x + width == w->allocation.x + w->allocation.width |
|
1688 |
* |
|
1689 |
* The ubuntulooks engine will draw a "right" button when: |
|
1690 |
* [x,y,width,height] |
|
1691 |
* does not intersect |
|
1692 |
* [w->alloc.x,w->alloc.y,width,height] |
|
1693 |
* but does intersect |
|
1694 |
* [w->alloc.x+width,w->alloc.y,width,height] |
|
1695 |
* |
|
1696 |
* The values that are set below should ensure that a "right" |
|
1697 |
* button is rendered for both of these (and other) engines. |
|
1698 |
*/ |
|
1699 |
gtk2_widget->allocation.x = x+width; |
|
1700 |
gtk2_widget->allocation.y = 0; |
|
1701 |
gtk2_widget->allocation.width = 0; |
|
1702 |
gtk2_widget->allocation.height = height; |
|
1703 |
break; |
|
1704 |
case VSCROLL_BAR_BUTTON_UP: |
|
1705 |
/* |
|
1706 |
* The clearlooks engine will draw an "up" button when: |
|
1707 |
* y == w->allocation.y |
|
1708 |
* |
|
1709 |
* The ubuntulooks engine will draw an "up" button when: |
|
1710 |
* [x,y,width,height] |
|
1711 |
* intersects |
|
1712 |
* [w->alloc.x,w->alloc.y,width,height] |
|
1713 |
* |
|
1714 |
* The values that are set below should ensure that an "up" |
|
1715 |
* button is rendered for both of these (and other) engines. |
|
1716 |
*/ |
|
1717 |
gtk2_widget->allocation.x = x; |
|
1718 |
gtk2_widget->allocation.y = y; |
|
1719 |
gtk2_widget->allocation.width = width; |
|
1720 |
gtk2_widget->allocation.height = height; |
|
1721 |
break; |
|
1722 |
case VSCROLL_BAR_BUTTON_DOWN: |
|
1723 |
/* |
|
1724 |
* The clearlooks engine will draw a "down" button when: |
|
1725 |
* y + height == w->allocation.y + w->allocation.height |
|
1726 |
* |
|
1727 |
* The ubuntulooks engine will draw a "down" button when: |
|
1728 |
* [x,y,width,height] |
|
1729 |
* does not intersect |
|
1730 |
* [w->alloc.x,w->alloc.y,width,height] |
|
1731 |
* but does intersect |
|
1732 |
* [w->alloc.x,w->alloc.y+height,width,height] |
|
1733 |
* |
|
1734 |
* The values that are set below should ensure that a "down" |
|
1735 |
* button is rendered for both of these (and other) engines. |
|
1736 |
*/ |
|
1737 |
gtk2_widget->allocation.x = x; |
|
1738 |
gtk2_widget->allocation.y = y+height; |
|
1739 |
gtk2_widget->allocation.width = width; |
|
1740 |
gtk2_widget->allocation.height = 0; |
|
1741 |
break; |
|
1742 |
default: |
|
1743 |
break; |
|
1744 |
} |
|
1745 |
||
1746 |
(*fp_gtk_paint_box)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1747 |
shadow_type, NULL, gtk2_widget, detail, x, y, width, height); |
|
1748 |
(*fp_gtk_paint_box)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1749 |
shadow_type, NULL, gtk2_widget, detail, x, y, width, height); |
|
1750 |
||
1751 |
/* |
|
1752 |
* Reset the text direction to the default value so that we don't |
|
1753 |
* accidentally affect other operations and widgets. |
|
1754 |
*/ |
|
1755 |
gtk2_set_direction(gtk2_widget, GTK_TEXT_DIR_LTR); |
|
1756 |
} |
|
1757 |
||
1758 |
void gtk2_paint_box_gap(WidgetType widget_type, GtkStateType state_type, |
|
1759 |
GtkShadowType shadow_type, const gchar *detail, |
|
1760 |
gint x, gint y, gint width, gint height, |
|
1761 |
GtkPositionType gap_side, gint gap_x, gint gap_width) |
|
1762 |
{ |
|
1763 |
/* Clearlooks needs a real clip area to paint the gap properly */ |
|
1764 |
GdkRectangle area = { x, y, width, height }; |
|
1765 |
||
1766 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1767 |
(*fp_gtk_paint_box_gap)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1768 |
shadow_type, &area, gtk2_widget, detail, |
|
1769 |
x, y, width, height, gap_side, gap_x, gap_width); |
|
1770 |
(*fp_gtk_paint_box_gap)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1771 |
shadow_type, &area, gtk2_widget, detail, |
|
1772 |
x, y, width, height, gap_side, gap_x, gap_width); |
|
1773 |
} |
|
1774 |
||
1775 |
void gtk2_paint_check(WidgetType widget_type, gint synth_state, |
|
1776 |
const gchar *detail, gint x, gint y, gint width, gint height) |
|
1777 |
{ |
|
1778 |
GtkStateType state_type = get_gtk_state_type(widget_type, synth_state); |
|
1779 |
GtkShadowType shadow_type = get_gtk_shadow_type(widget_type, synth_state); |
|
1780 |
||
1781 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1782 |
init_toggle_widget(widget_type, synth_state); |
|
1783 |
||
1784 |
(*fp_gtk_paint_check)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1785 |
shadow_type, NULL, gtk2_widget, detail, |
|
1786 |
x, y, width, height); |
|
1787 |
(*fp_gtk_paint_check)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1788 |
shadow_type, NULL, gtk2_widget, detail, |
|
1789 |
x, y, width, height); |
|
1790 |
} |
|
1791 |
||
1792 |
void gtk2_paint_diamond(WidgetType widget_type, GtkStateType state_type, |
|
1793 |
GtkShadowType shadow_type, const gchar *detail, |
|
1794 |
gint x, gint y, gint width, gint height) |
|
1795 |
{ |
|
1796 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1797 |
(*fp_gtk_paint_diamond)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1798 |
shadow_type, NULL, gtk2_widget, detail, |
|
1799 |
x, y, width, height); |
|
1800 |
(*fp_gtk_paint_diamond)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1801 |
shadow_type, NULL, gtk2_widget, detail, |
|
1802 |
x, y, width, height); |
|
1803 |
} |
|
1804 |
||
1805 |
void gtk2_paint_expander(WidgetType widget_type, GtkStateType state_type, |
|
1806 |
const gchar *detail, gint x, gint y, gint width, gint height, |
|
1807 |
GtkExpanderStyle expander_style) |
|
1808 |
{ |
|
1809 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1810 |
(*fp_gtk_paint_expander)(gtk2_widget->style, gtk2_white_pixmap, |
|
1811 |
state_type, NULL, gtk2_widget, detail, |
|
1812 |
x + width / 2, y + height / 2, expander_style); |
|
1813 |
(*fp_gtk_paint_expander)(gtk2_widget->style, gtk2_black_pixmap, |
|
1814 |
state_type, NULL, gtk2_widget, detail, |
|
1815 |
x + width / 2, y + height / 2, expander_style); |
|
1816 |
} |
|
1817 |
||
1818 |
void gtk2_paint_extension(WidgetType widget_type, GtkStateType state_type, |
|
1819 |
GtkShadowType shadow_type, const gchar *detail, |
|
1820 |
gint x, gint y, gint width, gint height, GtkPositionType gap_side) |
|
1821 |
{ |
|
1822 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1823 |
(*fp_gtk_paint_extension)(gtk2_widget->style, gtk2_white_pixmap, |
|
1824 |
state_type, shadow_type, NULL, gtk2_widget, detail, |
|
1825 |
x, y, width, height, gap_side); |
|
1826 |
(*fp_gtk_paint_extension)(gtk2_widget->style, gtk2_black_pixmap, |
|
1827 |
state_type, shadow_type, NULL, gtk2_widget, detail, |
|
1828 |
x, y, width, height, gap_side); |
|
1829 |
} |
|
1830 |
||
1831 |
void gtk2_paint_flat_box(WidgetType widget_type, GtkStateType state_type, |
|
1832 |
GtkShadowType shadow_type, const gchar *detail, |
|
1833 |
gint x, gint y, gint width, gint height, gboolean has_focus) |
|
1834 |
{ |
|
1835 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1836 |
||
1837 |
if (has_focus) |
|
1838 |
((GtkObject*)gtk2_widget)->flags |= GTK_HAS_FOCUS; |
|
1839 |
else |
|
1840 |
((GtkObject*)gtk2_widget)->flags &= ~GTK_HAS_FOCUS; |
|
1841 |
||
1842 |
(*fp_gtk_paint_flat_box)(gtk2_widget->style, gtk2_white_pixmap, |
|
1843 |
state_type, shadow_type, NULL, gtk2_widget, detail, |
|
1844 |
x, y, width, height); |
|
1845 |
(*fp_gtk_paint_flat_box)(gtk2_widget->style, gtk2_black_pixmap, |
|
1846 |
state_type, shadow_type, NULL, gtk2_widget, detail, |
|
1847 |
x, y, width, height); |
|
1848 |
} |
|
1849 |
||
1850 |
void gtk2_paint_focus(WidgetType widget_type, GtkStateType state_type, |
|
1851 |
const char *detail, gint x, gint y, gint width, gint height) |
|
1852 |
{ |
|
1853 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1854 |
(*fp_gtk_paint_focus)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1855 |
NULL, gtk2_widget, detail, x, y, width, height); |
|
1856 |
(*fp_gtk_paint_focus)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1857 |
NULL, gtk2_widget, detail, x, y, width, height); |
|
1858 |
} |
|
1859 |
||
1860 |
void gtk2_paint_handle(WidgetType widget_type, GtkStateType state_type, |
|
1861 |
GtkShadowType shadow_type, const gchar *detail, |
|
1862 |
gint x, gint y, gint width, gint height, GtkOrientation orientation) |
|
1863 |
{ |
|
1864 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1865 |
(*fp_gtk_paint_handle)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1866 |
shadow_type, NULL, gtk2_widget, detail, |
|
1867 |
x, y, width, height, orientation); |
|
1868 |
(*fp_gtk_paint_handle)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1869 |
shadow_type, NULL, gtk2_widget, detail, |
|
1870 |
x, y, width, height, orientation); |
|
1871 |
} |
|
1872 |
||
1873 |
void gtk2_paint_hline(WidgetType widget_type, GtkStateType state_type, |
|
1874 |
const gchar *detail, gint x, gint y, gint width, gint height) |
|
1875 |
{ |
|
1876 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1877 |
(*fp_gtk_paint_hline)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1878 |
NULL, gtk2_widget, detail, x, x + width, y); |
|
1879 |
(*fp_gtk_paint_hline)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1880 |
NULL, gtk2_widget, detail, x, x + width, y); |
|
1881 |
} |
|
1882 |
||
1883 |
void gtk2_paint_option(WidgetType widget_type, gint synth_state, |
|
1884 |
const gchar *detail, gint x, gint y, gint width, gint height) |
|
1885 |
{ |
|
1886 |
GtkStateType state_type = get_gtk_state_type(widget_type, synth_state); |
|
1887 |
GtkShadowType shadow_type = get_gtk_shadow_type(widget_type, synth_state); |
|
1888 |
||
1889 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1890 |
init_toggle_widget(widget_type, synth_state); |
|
1891 |
||
1892 |
(*fp_gtk_paint_option)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1893 |
shadow_type, NULL, gtk2_widget, detail, |
|
1894 |
x, y, width, height); |
|
1895 |
(*fp_gtk_paint_option)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1896 |
shadow_type, NULL, gtk2_widget, detail, |
|
1897 |
x, y, width, height); |
|
1898 |
} |
|
1899 |
||
1900 |
void gtk2_paint_shadow(WidgetType widget_type, GtkStateType state_type, |
|
1901 |
GtkShadowType shadow_type, const gchar *detail, |
|
1902 |
gint x, gint y, gint width, gint height, |
|
1903 |
gint synth_state, GtkTextDirection dir) |
|
1904 |
{ |
|
1905 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1906 |
||
1907 |
/* |
|
1908 |
* The clearlooks engine sometimes looks at the widget's state field |
|
1909 |
* instead of just the state_type variable that we pass in, so to account |
|
1910 |
* for those cases we set the widget's state field accordingly. The |
|
1911 |
* flags field is similarly important for things like focus state. |
|
1912 |
*/ |
|
1913 |
gtk2_widget->state = state_type; |
|
1914 |
||
1915 |
/* |
|
1916 |
* Some engines (e.g. clearlooks) will paint the shadow of certain |
|
1917 |
* widgets (e.g. COMBO_BOX_TEXT_FIELD) differently depending on the |
|
1918 |
* the text direction. |
|
1919 |
*/ |
|
1920 |
gtk2_set_direction(gtk2_widget, dir); |
|
1921 |
||
1922 |
switch (widget_type) { |
|
1923 |
case COMBO_BOX_TEXT_FIELD: |
|
1924 |
case FORMATTED_TEXT_FIELD: |
|
1925 |
case PASSWORD_FIELD: |
|
1926 |
case SPINNER_TEXT_FIELD: |
|
1927 |
case TEXT_FIELD: |
|
1928 |
if (synth_state & FOCUSED) { |
|
1929 |
((GtkObject*)gtk2_widget)->flags |= GTK_HAS_FOCUS; |
|
1930 |
} else { |
|
1931 |
((GtkObject*)gtk2_widget)->flags &= ~GTK_HAS_FOCUS; |
|
1932 |
} |
|
1933 |
break; |
|
1934 |
default: |
|
1935 |
break; |
|
1936 |
} |
|
1937 |
||
1938 |
(*fp_gtk_paint_shadow)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1939 |
shadow_type, NULL, gtk2_widget, detail, x, y, width, height); |
|
1940 |
(*fp_gtk_paint_shadow)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1941 |
shadow_type, NULL, gtk2_widget, detail, x, y, width, height); |
|
1942 |
||
1943 |
/* |
|
1944 |
* Reset the text direction to the default value so that we don't |
|
1945 |
* accidentally affect other operations and widgets. |
|
1946 |
*/ |
|
1947 |
gtk2_set_direction(gtk2_widget, GTK_TEXT_DIR_LTR); |
|
1948 |
} |
|
1949 |
||
1950 |
void gtk2_paint_slider(WidgetType widget_type, GtkStateType state_type, |
|
1951 |
GtkShadowType shadow_type, const gchar *detail, |
|
1952 |
gint x, gint y, gint width, gint height, GtkOrientation orientation) |
|
1953 |
{ |
|
1954 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1955 |
(*fp_gtk_paint_slider)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1956 |
shadow_type, NULL, gtk2_widget, detail, |
|
1957 |
x, y, width, height, orientation); |
|
1958 |
(*fp_gtk_paint_slider)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1959 |
shadow_type, NULL, gtk2_widget, detail, |
|
1960 |
x, y, width, height, orientation); |
|
1961 |
} |
|
1962 |
||
1963 |
void gtk2_paint_vline(WidgetType widget_type, GtkStateType state_type, |
|
1964 |
const gchar *detail, gint x, gint y, gint width, gint height) |
|
1965 |
{ |
|
1966 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1967 |
(*fp_gtk_paint_vline)(gtk2_widget->style, gtk2_white_pixmap, state_type, |
|
1968 |
NULL, gtk2_widget, detail, y, y + height, x); |
|
1969 |
(*fp_gtk_paint_vline)(gtk2_widget->style, gtk2_black_pixmap, state_type, |
|
1970 |
NULL, gtk2_widget, detail, y, y + height, x); |
|
1971 |
} |
|
1972 |
||
1973 |
void gtk_paint_background(WidgetType widget_type, GtkStateType state_type, |
|
1974 |
gint x, gint y, gint width, gint height) |
|
1975 |
{ |
|
1976 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1977 |
(*fp_gtk_style_apply_default_background)(gtk2_widget->style, |
|
1978 |
gtk2_white_pixmap, TRUE, state_type, NULL, x, y, width, height); |
|
1979 |
(*fp_gtk_style_apply_default_background)(gtk2_widget->style, |
|
1980 |
gtk2_black_pixmap, TRUE, state_type, NULL, x, y, width, height); |
|
1981 |
} |
|
1982 |
||
1983 |
GdkPixbuf *gtk2_get_stock_icon(gint widget_type, const gchar *stock_id, |
|
1984 |
GtkIconSize size, GtkTextDirection direction, const char *detail) |
|
1985 |
{ |
|
1986 |
init_containers(); |
|
1987 |
gtk2_widget = gtk2_get_widget((widget_type < 0) ? IMAGE : widget_type); |
|
1988 |
gtk2_widget->state = GTK_STATE_NORMAL; |
|
1989 |
(*fp_gtk_widget_set_direction)(gtk2_widget, direction); |
|
1990 |
return (*fp_gtk_widget_render_icon)(gtk2_widget, stock_id, size, detail); |
|
1991 |
} |
|
1992 |
||
1993 |
/*************************************************/ |
|
1994 |
gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type) |
|
1995 |
{ |
|
1996 |
init_containers(); |
|
1997 |
||
1998 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
1999 |
GtkStyle* style = gtk2_widget->style; |
|
2000 |
return style->xthickness; |
|
2001 |
} |
|
2002 |
||
2003 |
gint gtk2_get_ythickness(JNIEnv *env, WidgetType widget_type) |
|
2004 |
{ |
|
2005 |
init_containers(); |
|
2006 |
||
2007 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
2008 |
GtkStyle* style = gtk2_widget->style; |
|
2009 |
return style->ythickness; |
|
2010 |
} |
|
2011 |
||
2012 |
/*************************************************/ |
|
2013 |
guint8 recode_color(guint16 channel) |
|
2014 |
{ |
|
2015 |
return (guint8)(channel>>8); |
|
2016 |
} |
|
2017 |
||
2018 |
gint gtk2_get_color_for_state(JNIEnv *env, WidgetType widget_type, |
|
2019 |
GtkStateType state_type, ColorType color_type) |
|
2020 |
{ |
|
2021 |
gint result = 0; |
|
2022 |
GdkColor *color = NULL; |
|
2023 |
||
2024 |
init_containers(); |
|
2025 |
||
2026 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
2027 |
GtkStyle* style = gtk2_widget->style; |
|
2028 |
||
2029 |
switch (color_type) |
|
2030 |
{ |
|
2031 |
case FOREGROUND: |
|
2032 |
color = &(style->fg[state_type]); |
|
2033 |
break; |
|
2034 |
case BACKGROUND: |
|
2035 |
color = &(style->bg[state_type]); |
|
2036 |
break; |
|
2037 |
case TEXT_FOREGROUND: |
|
2038 |
color = &(style->text[state_type]); |
|
2039 |
break; |
|
2040 |
case TEXT_BACKGROUND: |
|
2041 |
color = &(style->base[state_type]); |
|
2042 |
break; |
|
2043 |
case LIGHT: |
|
2044 |
color = &(style->light[state_type]); |
|
2045 |
break; |
|
2046 |
case DARK: |
|
2047 |
color = &(style->dark[state_type]); |
|
2048 |
break; |
|
2049 |
case MID: |
|
2050 |
color = &(style->mid[state_type]); |
|
2051 |
break; |
|
2052 |
case FOCUS: |
|
2053 |
case BLACK: |
|
2054 |
color = &(style->black); |
|
2055 |
break; |
|
2056 |
case WHITE: |
|
2057 |
color = &(style->white); |
|
2058 |
break; |
|
2059 |
} |
|
2060 |
||
2061 |
if (color) |
|
2062 |
result = recode_color(color->red) << 16 | |
|
2063 |
recode_color(color->green) << 8 | |
|
2064 |
recode_color(color->blue); |
|
2065 |
||
2066 |
return result; |
|
2067 |
} |
|
2068 |
||
2069 |
/*************************************************/ |
|
2070 |
jobject create_Boolean(JNIEnv *env, jboolean boolean_value); |
|
2071 |
jobject create_Integer(JNIEnv *env, jint int_value); |
|
2072 |
jobject create_Long(JNIEnv *env, jlong long_value); |
|
2073 |
jobject create_Float(JNIEnv *env, jfloat float_value); |
|
2074 |
jobject create_Double(JNIEnv *env, jdouble double_value); |
|
2075 |
jobject create_Character(JNIEnv *env, jchar char_value); |
|
2076 |
jobject create_Insets(JNIEnv *env, GtkBorder *border); |
|
2077 |
||
2078 |
jobject gtk2_get_class_value(JNIEnv *env, WidgetType widget_type, jstring jkey) |
|
2079 |
{ |
|
2080 |
init_containers(); |
|
2081 |
||
2082 |
const char* key = getStrFor(env, jkey); |
|
2083 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
2084 |
||
2085 |
GValue value; |
|
2086 |
value.g_type = 0; |
|
2087 |
||
2088 |
GParamSpec* param = (*fp_gtk_widget_class_find_style_property)( |
|
2089 |
((GTypeInstance*)gtk2_widget)->g_class, key); |
|
2090 |
if( param ) |
|
2091 |
{ |
|
2092 |
(*fp_g_value_init)( &value, param->value_type ); |
|
2093 |
(*fp_gtk_widget_style_get_property)(gtk2_widget, key, &value); |
|
2094 |
||
2095 |
if( (*fp_g_type_is_a)( param->value_type, G_TYPE_BOOLEAN )) |
|
2096 |
{ |
|
2097 |
gboolean val = (*fp_g_value_get_boolean)(&value); |
|
2098 |
return create_Boolean(env, (jboolean)val); |
|
2099 |
} |
|
2100 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_CHAR )) |
|
2101 |
{ |
|
2102 |
gchar val = (*fp_g_value_get_char)(&value); |
|
2103 |
return create_Character(env, (jchar)val); |
|
2104 |
} |
|
2105 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_UCHAR )) |
|
2106 |
{ |
|
2107 |
guchar val = (*fp_g_value_get_uchar)(&value); |
|
2108 |
return create_Character(env, (jchar)val); |
|
2109 |
} |
|
2110 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_INT )) |
|
2111 |
{ |
|
2112 |
gint val = (*fp_g_value_get_int)(&value); |
|
2113 |
return create_Integer(env, (jint)val); |
|
2114 |
} |
|
2115 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_UINT )) |
|
2116 |
{ |
|
2117 |
guint val = (*fp_g_value_get_uint)(&value); |
|
2118 |
return create_Integer(env, (jint)val); |
|
2119 |
} |
|
2120 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_LONG )) |
|
2121 |
{ |
|
2122 |
glong val = (*fp_g_value_get_long)(&value); |
|
2123 |
return create_Long(env, (jlong)val); |
|
2124 |
} |
|
2125 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_ULONG )) |
|
2126 |
{ |
|
2127 |
gulong val = (*fp_g_value_get_ulong)(&value); |
|
2128 |
return create_Long(env, (jlong)val); |
|
2129 |
} |
|
2130 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_INT64 )) |
|
2131 |
{ |
|
2132 |
gint64 val = (*fp_g_value_get_int64)(&value); |
|
2133 |
return create_Long(env, (jlong)val); |
|
2134 |
} |
|
2135 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_UINT64 )) |
|
2136 |
{ |
|
2137 |
guint64 val = (*fp_g_value_get_uint64)(&value); |
|
2138 |
return create_Long(env, (jlong)val); |
|
2139 |
} |
|
2140 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_FLOAT )) |
|
2141 |
{ |
|
2142 |
gfloat val = (*fp_g_value_get_float)(&value); |
|
2143 |
return create_Float(env, (jfloat)val); |
|
2144 |
} |
|
2145 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_DOUBLE )) |
|
2146 |
{ |
|
2147 |
gdouble val = (*fp_g_value_get_double)(&value); |
|
2148 |
return create_Double(env, (jdouble)val); |
|
2149 |
} |
|
2150 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_ENUM )) |
|
2151 |
{ |
|
2152 |
gint val = (*fp_g_value_get_enum)(&value); |
|
2153 |
return create_Integer(env, (jint)val); |
|
2154 |
} |
|
2155 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_FLAGS )) |
|
2156 |
{ |
|
2157 |
guint val = (*fp_g_value_get_flags)(&value); |
|
2158 |
return create_Integer(env, (jint)val); |
|
2159 |
} |
|
2160 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_STRING )) |
|
2161 |
{ |
|
2162 |
const gchar* val = (*fp_g_value_get_string)(&value); |
|
2163 |
||
2164 |
/* We suppose that all values come in C locale and |
|
2165 |
* utf-8 representation of a string is the same as |
|
2166 |
* the string itself. If this isn't so we should |
|
2167 |
* use g_convert. |
|
2168 |
*/ |
|
2169 |
return (*env)->NewStringUTF(env, val); |
|
2170 |
} |
|
2171 |
else if( (*fp_g_type_is_a)( param->value_type, GTK_TYPE_BORDER )) |
|
2172 |
{ |
|
2173 |
GtkBorder *border = (GtkBorder*)(*fp_g_value_get_boxed)(&value); |
|
2174 |
return border ? create_Insets(env, border) : NULL; |
|
2175 |
} |
|
2176 |
||
2177 |
/* TODO: Other types are not supported yet.*/ |
|
2178 |
/* else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_PARAM )) |
|
2179 |
{ |
|
2180 |
GParamSpec* val = (*fp_g_value_get_param)(&value); |
|
2181 |
printf( "Param: %p\n", val ); |
|
2182 |
} |
|
2183 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_BOXED )) |
|
2184 |
{ |
|
2185 |
gpointer* val = (*fp_g_value_get_boxed)(&value); |
|
2186 |
printf( "Boxed: %p\n", val ); |
|
2187 |
} |
|
2188 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_POINTER )) |
|
2189 |
{ |
|
2190 |
gpointer* val = (*fp_g_value_get_pointer)(&value); |
|
2191 |
printf( "Pointer: %p\n", val ); |
|
2192 |
} |
|
2193 |
else if( (*fp_g_type_is_a)( param->value_type, G_TYPE_OBJECT )) |
|
2194 |
{ |
|
2195 |
GObject* val = (GObject*)(*fp_g_value_get_object)(&value); |
|
2196 |
printf( "Object: %p\n", val ); |
|
2197 |
}*/ |
|
2198 |
} |
|
2199 |
||
2200 |
return NULL; |
|
2201 |
} |
|
2202 |
||
2203 |
void gtk2_set_range_value(WidgetType widget_type, jdouble value, |
|
2204 |
jdouble min, jdouble max, jdouble visible) |
|
2205 |
{ |
|
2206 |
GtkAdjustment *adj; |
|
2207 |
||
2208 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
2209 |
||
2210 |
adj = (*fp_gtk_range_get_adjustment)((GtkRange *)gtk2_widget); |
|
2211 |
adj->value = (gdouble)value; |
|
2212 |
adj->lower = (gdouble)min; |
|
2213 |
adj->upper = (gdouble)max; |
|
2214 |
adj->page_size = (gdouble)visible; |
|
2215 |
} |
|
2216 |
||
2217 |
/*************************************************/ |
|
2218 |
jobject create_Object(JNIEnv *env, jmethodID *cid, |
|
2219 |
const char* class_name, |
|
2220 |
const char* signature, |
|
2221 |
jvalue* value) |
|
2222 |
{ |
|
2223 |
jclass class; |
|
2224 |
jobject result; |
|
2225 |
||
2226 |
class = (*env)->FindClass(env, class_name); |
|
2227 |
if( class == NULL ) |
|
2228 |
return NULL; /* can't find/load the class, exception thrown */ |
|
2229 |
||
2230 |
if( *cid == NULL) |
|
2231 |
{ |
|
2232 |
*cid = (*env)->GetMethodID(env, class, "<init>", signature); |
|
2233 |
if( *cid == NULL ) |
|
2234 |
{ |
|
2235 |
(*env)->DeleteLocalRef(env, class); |
|
2236 |
return NULL; /* can't find/get the method, exception thrown */ |
|
2237 |
} |
|
2238 |
} |
|
2239 |
||
2240 |
result = (*env)->NewObjectA(env, class, *cid, value); |
|
2241 |
||
2242 |
(*env)->DeleteLocalRef(env, class); |
|
2243 |
return result; |
|
2244 |
} |
|
2245 |
||
2246 |
jobject create_Boolean(JNIEnv *env, jboolean boolean_value) |
|
2247 |
{ |
|
2248 |
static jmethodID cid = NULL; |
|
2249 |
jvalue value; |
|
2250 |
||
2251 |
value.z = boolean_value; |
|
2252 |
||
2253 |
return create_Object(env, &cid, "java/lang/Boolean", "(Z)V", &value); |
|
2254 |
} |
|
2255 |
||
2256 |
jobject create_Integer(JNIEnv *env, jint int_value) |
|
2257 |
{ |
|
2258 |
static jmethodID cid = NULL; |
|
2259 |
jvalue value; |
|
2260 |
||
2261 |
value.i = int_value; |
|
2262 |
||
2263 |
return create_Object(env, &cid, "java/lang/Integer", "(I)V", &value); |
|
2264 |
} |
|
2265 |
||
2266 |
jobject create_Long(JNIEnv *env, jlong long_value) |
|
2267 |
{ |
|
2268 |
static jmethodID cid = NULL; |
|
2269 |
jvalue value; |
|
2270 |
||
2271 |
value.j = long_value; |
|
2272 |
||
2273 |
return create_Object(env, &cid, "java/lang/Long", "(J)V", &value); |
|
2274 |
} |
|
2275 |
||
2276 |
jobject create_Float(JNIEnv *env, jfloat float_value) |
|
2277 |
{ |
|
2278 |
static jmethodID cid = NULL; |
|
2279 |
jvalue value; |
|
2280 |
||
2281 |
value.f = float_value; |
|
2282 |
||
2283 |
return create_Object(env, &cid, "java/lang/Float", "(F)V", &value); |
|
2284 |
} |
|
2285 |
||
2286 |
jobject create_Double(JNIEnv *env, jdouble double_value) |
|
2287 |
{ |
|
2288 |
static jmethodID cid = NULL; |
|
2289 |
jvalue value; |
|
2290 |
||
2291 |
value.d = double_value; |
|
2292 |
||
2293 |
return create_Object(env, &cid, "java/lang/Double", "(D)V", &value); |
|
2294 |
} |
|
2295 |
||
2296 |
jobject create_Character(JNIEnv *env, jchar char_value) |
|
2297 |
{ |
|
2298 |
static jmethodID cid = NULL; |
|
2299 |
jvalue value; |
|
2300 |
||
2301 |
value.c = char_value; |
|
2302 |
||
2303 |
return create_Object(env, &cid, "java/lang/Character", "(C)V", &value); |
|
2304 |
} |
|
2305 |
||
2306 |
||
2307 |
jobject create_Insets(JNIEnv *env, GtkBorder *border) |
|
2308 |
{ |
|
2309 |
static jmethodID cid = NULL; |
|
2310 |
jvalue values[4]; |
|
2311 |
||
2312 |
values[0].i = border->top; |
|
2313 |
values[1].i = border->left; |
|
2314 |
values[2].i = border->bottom; |
|
2315 |
values[3].i = border->right; |
|
2316 |
||
2317 |
return create_Object(env, &cid, "java/awt/Insets", "(IIII)V", values); |
|
2318 |
} |
|
2319 |
||
2320 |
/*********************************************/ |
|
2321 |
jstring gtk2_get_pango_font_name(JNIEnv *env, WidgetType widget_type) |
|
2322 |
{ |
|
2323 |
init_containers(); |
|
2324 |
||
2325 |
gtk2_widget = gtk2_get_widget(widget_type); |
|
2326 |
jstring result = NULL; |
|
2327 |
GtkStyle* style = gtk2_widget->style; |
|
2328 |
||
2329 |
if (style && style->font_desc) |
|
2330 |
{ |
|
2331 |
gchar* val = (*fp_pango_font_description_to_string)(style->font_desc); |
|
2332 |
result = (*env)->NewStringUTF(env, val); |
|
2333 |
(*fp_g_free)( val ); |
|
2334 |
} |
|
2335 |
||
2336 |
return result; |
|
2337 |
} |
|
2338 |
||
2339 |
/***********************************************/ |
|
2340 |
jobject get_string_property(JNIEnv *env, GtkSettings* settings, const gchar* key) |
|
2341 |
{ |
|
2342 |
jobject result = NULL; |
|
2343 |
gchar* strval = NULL; |
|
2344 |
||
2345 |
(*fp_g_object_get)(settings, key, &strval, NULL); |
|
2346 |
result = (*env)->NewStringUTF(env, strval); |
|
2347 |
(*fp_g_free)(strval); |
|
2348 |
||
2349 |
return result; |
|
2350 |
} |
|
2351 |
/* |
|
2352 |
jobject get_integer_property(JNIEnv *env, GtkSettings* settings, const gchar* key) |
|
2353 |
{ |
|
2354 |
gint intval = NULL; |
|
2355 |
||
2356 |
(*fp_g_object_get)(settings, key, &intval, NULL); |
|
2357 |
return create_Integer(env, intval); |
|
2358 |
}*/ |
|
2359 |
||
2360 |
jobject gtk2_get_setting(JNIEnv *env, Setting property) |
|
2361 |
{ |
|
2362 |
GtkSettings* settings = (*fp_gtk_settings_get_default)(); |
|
2363 |
||
2364 |
switch (property) |
|
2365 |
{ |
|
2366 |
case GTK_FONT_NAME: |
|
2367 |
return get_string_property(env, settings, "gtk-font-name"); |
|
2368 |
case GTK_ICON_SIZES: |
|
2369 |
return get_string_property(env, settings, "gtk-icon-sizes"); |
|
2370 |
} |
|
2371 |
||
2372 |
return NULL; |
|
2373 |
} |