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