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