1/*
2 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26#include <stdlib.h>
27#include <stdio.h>
28#include "gtk_interface.h"
29#include "com_sun_java_swing_plaf_gtk_GTKStyle.h"
30
31const char *getStrFor(JNIEnv *env, jstring val);
32
33/*
34 * Class:     com_sun_java_swing_plaf_gtk_GTKStyle
35 * Method:    nativeGetXThickness
36 * Signature: (I)I
37 */
38JNIEXPORT jint JNICALL
39Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetXThickness(
40    JNIEnv *env, jclass klass, jint widget_type)
41{
42    jint ret;
43    gtk->gdk_threads_enter();
44    ret = gtk->get_xthickness(env, widget_type);
45    gtk->gdk_threads_leave();
46    return ret;
47}
48
49/*
50 * Class:     com_sun_java_swing_plaf_gtk_GTKStyle
51 * Method:    nativeGetYThickness
52 * Signature: (I)I
53 */
54JNIEXPORT jint JNICALL
55Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetYThickness(
56    JNIEnv *env, jclass klass, jint widget_type)
57{
58    jint ret;
59    gtk->gdk_threads_enter();
60    ret = gtk->get_ythickness(env, widget_type);
61    gtk->gdk_threads_leave();
62    return ret;
63}
64
65/*
66 * Class:     com_sun_java_swing_plaf_gtk_GTKStyle
67 * Method:    nativeGetColorForState
68 * Signature: (III)I
69 */
70JNIEXPORT jint JNICALL
71Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetColorForState(
72    JNIEnv *env, jclass klass, jint widget_type,
73    jint state_type, jint type_id)
74{
75    jint ret;
76    gtk->gdk_threads_enter();
77    ret = gtk->get_color_for_state(env, widget_type, state_type, type_id);
78    gtk->gdk_threads_leave();
79    return ret;
80}
81
82/*
83 * Class:     com_sun_java_swing_plaf_gtk_GTKStyle
84 * Method:    nativeGetClassValue
85 * Signature: (ILjava/lang/String;)Ljava/lang/Object;
86 */
87JNIEXPORT jobject JNICALL
88Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue(
89    JNIEnv *env, jclass klass, jint widget_type, jstring key)
90{
91    jobject ret;
92    gtk->gdk_threads_enter();
93    ret = gtk->get_class_value(env, widget_type, getStrFor(env, key));
94    gtk->gdk_threads_leave();
95    return ret;
96}
97
98/*
99 * Class:     com_sun_java_swing_plaf_gtk_GTKStyle
100 * Method:    nativeGetPangoFontName
101 * Signature: (I)Ljava/lang/String;
102 */
103JNIEXPORT jstring JNICALL
104Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName(
105    JNIEnv *env, jclass klass, jint widget_type)
106{
107    jstring ret;
108    gtk->gdk_threads_enter();
109    ret = gtk->get_pango_font_name(env, widget_type);
110    gtk->gdk_threads_leave();
111    return ret;
112}
113