1 /*
2 * Copyright (c) 2005, 2015, 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 #ifndef _GTK2_INTERFACE_H
26 #define _GTK2_INTERFACE_H
27
28 #include <stdlib.h>
29 #include <jni.h>
30 #include <X11/X.h>
31
32 #define _G_TYPE_CIC(ip, gt, ct) ((ct*) ip)
33 #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type))
34 #define GTK_TYPE_FILE_CHOOSER (fp_gtk_file_chooser_get_type ())
35 #define GTK_FILE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser))
36 #define fp_g_signal_connect(instance, detailed_signal, c_handler, data) \
37 fp_g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0)
38 #define G_CALLBACK(f) ((GCallback) (f))
39 #define G_TYPE_FUNDAMENTAL_SHIFT (2)
40 #define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
41 #define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20)
42 #define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
43 #define GTK_STOCK_CANCEL "gtk-cancel"
44 #define GTK_STOCK_SAVE "gtk-save"
45 #define GTK_STOCK_OPEN "gtk-open"
46 #define GDK_CURRENT_TIME 0L
47
48 typedef enum _WidgetType
49 {
50 BUTTON, /* GtkButton */
51 CHECK_BOX, /* GtkCheckButton */
52 CHECK_BOX_MENU_ITEM, /* GtkCheckMenuItem */
53 COLOR_CHOOSER, /* GtkColorSelectionDialog */
54 COMBO_BOX, /* GtkComboBox */
55 COMBO_BOX_ARROW_BUTTON, /* GtkComboBoxEntry */
56 COMBO_BOX_TEXT_FIELD, /* GtkComboBoxEntry */
57 DESKTOP_ICON, /* GtkLabel */
58 DESKTOP_PANE, /* GtkContainer */
59 EDITOR_PANE, /* GtkTextView */
60 FORMATTED_TEXT_FIELD, /* GtkEntry */
61 HANDLE_BOX, /* GtkHandleBox */
62 HPROGRESS_BAR, /* GtkProgressBar */
63 HSCROLL_BAR, /* GtkHScrollbar */
64 HSCROLL_BAR_BUTTON_LEFT, /* GtkHScrollbar */
65 HSCROLL_BAR_BUTTON_RIGHT, /* GtkHScrollbar */
66 HSCROLL_BAR_TRACK, /* GtkHScrollbar */
67 HSCROLL_BAR_THUMB, /* GtkHScrollbar */
68 HSEPARATOR, /* GtkHSeparator */
69 HSLIDER, /* GtkHScale */
70 HSLIDER_TRACK, /* GtkHScale */
71 HSLIDER_THUMB, /* GtkHScale */
72 HSPLIT_PANE_DIVIDER, /* GtkHPaned */
73 INTERNAL_FRAME, /* GtkWindow */
74 INTERNAL_FRAME_TITLE_PANE, /* GtkLabel */
75 IMAGE, /* GtkImage */
76 LABEL, /* GtkLabel */
77 LIST, /* GtkTreeView */
78 MENU, /* GtkMenu */
79 MENU_BAR, /* GtkMenuBar */
80 MENU_ITEM, /* GtkMenuItem */
81 MENU_ITEM_ACCELERATOR, /* GtkLabel */
82 OPTION_PANE, /* GtkMessageDialog */
83 PANEL, /* GtkContainer */
84 PASSWORD_FIELD, /* GtkEntry */
85 POPUP_MENU, /* GtkMenu */
86 POPUP_MENU_SEPARATOR, /* GtkSeparatorMenuItem */
87 RADIO_BUTTON, /* GtkRadioButton */
88 RADIO_BUTTON_MENU_ITEM, /* GtkRadioMenuItem */
89 ROOT_PANE, /* GtkContainer */
90 SCROLL_PANE, /* GtkScrolledWindow */
91 SPINNER, /* GtkSpinButton */
92 SPINNER_ARROW_BUTTON, /* GtkSpinButton */
93 SPINNER_TEXT_FIELD, /* GtkSpinButton */
94 SPLIT_PANE, /* GtkPaned */
95 TABBED_PANE, /* GtkNotebook */
96 TABBED_PANE_TAB_AREA, /* GtkNotebook */
97 TABBED_PANE_CONTENT, /* GtkNotebook */
98 TABBED_PANE_TAB, /* GtkNotebook */
99 TABLE, /* GtkTreeView */
100 TABLE_HEADER, /* GtkButton */
101 TEXT_AREA, /* GtkTextView */
102 TEXT_FIELD, /* GtkEntry */
103 TEXT_PANE, /* GtkTextView */
104 TITLED_BORDER, /* GtkFrame */
105 TOGGLE_BUTTON, /* GtkToggleButton */
106 TOOL_BAR, /* GtkToolbar */
107 TOOL_BAR_DRAG_WINDOW, /* GtkToolbar */
108 TOOL_BAR_SEPARATOR, /* GtkSeparatorToolItem */
109 TOOL_TIP, /* GtkWindow */
110 TREE, /* GtkTreeView */
111 TREE_CELL, /* GtkTreeView */
112 VIEWPORT, /* GtkViewport */
113 VPROGRESS_BAR, /* GtkProgressBar */
114 VSCROLL_BAR, /* GtkVScrollbar */
115 VSCROLL_BAR_BUTTON_UP, /* GtkVScrollbar */
116 VSCROLL_BAR_BUTTON_DOWN, /* GtkVScrollbar */
117 VSCROLL_BAR_TRACK, /* GtkVScrollbar */
118 VSCROLL_BAR_THUMB, /* GtkVScrollbar */
119 VSEPARATOR, /* GtkVSeparator */
120 VSLIDER, /* GtkVScale */
121 VSLIDER_TRACK, /* GtkVScale */
122 VSLIDER_THUMB, /* GtkVScale */
123 VSPLIT_PANE_DIVIDER, /* GtkVPaned */
124 WIDGET_TYPE_SIZE
125 } WidgetType;
126
127 typedef enum _ColorType
128 {
129 FOREGROUND,
130 BACKGROUND,
131 TEXT_FOREGROUND,
132 TEXT_BACKGROUND,
133 FOCUS,
134 LIGHT,
135 DARK,
136 MID,
137 BLACK,
138 WHITE
139 } ColorType;
140
141 typedef enum _Setting
142 {
143 GTK_FONT_NAME,
144 GTK_ICON_SIZES,
145 GTK_CURSOR_BLINK,
146 GTK_CURSOR_BLINK_TIME
147 } Setting;
148
149 /* GTK types, here to eliminate need for GTK headers at compile time */
150
151 #ifndef FALSE
152 #define FALSE (0)
153 #define TRUE (!FALSE)
154 #endif
155
156 #define GTK_HAS_FOCUS (1 << 12)
157 #define GTK_HAS_DEFAULT (1 << 14)
158
159
160 /* basic types */
161 typedef char gchar;
162 typedef short gshort;
163 typedef int gint;
164 typedef long glong;
165 typedef float gfloat;
166 typedef double gdouble;
167 typedef void* gpointer;
168 typedef gint gboolean;
169
170 typedef signed char gint8;
171 typedef signed short gint16;
172 typedef signed int gint32;
173
174 typedef unsigned char guchar;
175 typedef unsigned char guint8;
176 typedef unsigned short gushort;
177 typedef unsigned short guint16;
178 typedef unsigned int guint;
179 typedef unsigned int guint32;
180 typedef unsigned int gsize;
181 typedef unsigned long gulong;
182
183 typedef signed long long gint64;
184 typedef unsigned long long guint64;
185
186 /* enumerated constants */
187 typedef enum
188 {
189 GTK_ARROW_UP,
190 GTK_ARROW_DOWN,
191 GTK_ARROW_LEFT,
192 GTK_ARROW_RIGHT
193 } GtkArrowType;
194
195 typedef enum {
196 GDK_COLORSPACE_RGB
197 } GdkColorspace;
198
199 typedef enum
200 {
201 GTK_EXPANDER_COLLAPSED,
202 GTK_EXPANDER_SEMI_COLLAPSED,
203 GTK_EXPANDER_SEMI_EXPANDED,
204 GTK_EXPANDER_EXPANDED
205 } GtkExpanderStyle;
206
207 typedef enum
208 {
209 GTK_ICON_SIZE_INVALID,
210 GTK_ICON_SIZE_MENU,
211 GTK_ICON_SIZE_SMALL_TOOLBAR,
212 GTK_ICON_SIZE_LARGE_TOOLBAR,
213 GTK_ICON_SIZE_BUTTON,
214 GTK_ICON_SIZE_DND,
215 GTK_ICON_SIZE_DIALOG
216 } GtkIconSize;
217
218 typedef enum
219 {
220 GTK_ORIENTATION_HORIZONTAL,
221 GTK_ORIENTATION_VERTICAL
222 } GtkOrientation;
223
224 typedef enum
225 {
226 GTK_POS_LEFT,
227 GTK_POS_RIGHT,
228 GTK_POS_TOP,
229 GTK_POS_BOTTOM
230 } GtkPositionType;
231
232 typedef enum
233 {
234 GTK_SHADOW_NONE,
235 GTK_SHADOW_IN,
236 GTK_SHADOW_OUT,
237 GTK_SHADOW_ETCHED_IN,
238 GTK_SHADOW_ETCHED_OUT
239 } GtkShadowType;
240
241 typedef enum
242 {
243 GTK_STATE_NORMAL,
244 GTK_STATE_ACTIVE,
245 GTK_STATE_PRELIGHT,
246 GTK_STATE_SELECTED,
247 GTK_STATE_INSENSITIVE
248 } GtkStateType;
249
250 typedef enum
251 {
252 GTK_TEXT_DIR_NONE,
253 GTK_TEXT_DIR_LTR,
254 GTK_TEXT_DIR_RTL
255 } GtkTextDirection;
256
257 typedef enum
258 {
259 GTK_WINDOW_TOPLEVEL,
260 GTK_WINDOW_POPUP
261 } GtkWindowType;
262
263 typedef enum
264 {
265 G_PARAM_READABLE = 1 << 0,
266 G_PARAM_WRITABLE = 1 << 1,
267 G_PARAM_CONSTRUCT = 1 << 2,
268 G_PARAM_CONSTRUCT_ONLY = 1 << 3,
269 G_PARAM_LAX_VALIDATION = 1 << 4,
270 G_PARAM_PRIVATE = 1 << 5
271 } GParamFlags;
272
273 typedef enum {
274 GDK_INTERP_NEAREST,
275 GDK_INTERP_TILES,
276 GDK_INTERP_BILINEAR,
277 GDK_INTERP_HYPER
278 } GdkInterpType;
279
280 /* We define all structure pointers to be void* */
281 typedef void GError;
282 typedef void GMainContext;
283 typedef void GVfs;
284
285 typedef struct _GSList GSList;
286 struct _GSList
287 {
288 gpointer data;
289 GSList *next;
290 };
291
292 typedef void GdkColormap;
293 typedef void GdkDrawable;
294 typedef void GdkGC;
295 typedef void GdkScreen;
296 typedef void GdkPixbuf;
297 typedef void GdkPixmap;
298 typedef void GdkWindow;
299
300 typedef void GtkFixed;
301 typedef void GtkMenuItem;
302 typedef void GtkMenuShell;
303 typedef void GtkWidgetClass;
304 typedef void PangoFontDescription;
305 typedef void GtkSettings;
306
307 /* Some real structures */
308 typedef struct
309 {
310 guint32 pixel;
311 guint16 red;
312 guint16 green;
313 guint16 blue;
314 } GdkColor;
315
316 typedef struct {
317 gint fd;
318 gushort events;
338 gint height;
339 } GtkRequisition;
340
341 typedef struct {
342 GtkWidgetClass *g_class;
343 } GTypeInstance;
344
345 typedef struct {
346 gint left;
347 gint right;
348 gint top;
349 gint bottom;
350 } GtkBorder;
351
352 /******************************************************
353 * FIXME: it is more safe to include gtk headers for
354 * the precise type definition of GType and other
355 * structures. This is a place where getting rid of gtk
356 * headers may be dangerous.
357 ******************************************************/
358 typedef gulong GType;
359
360 typedef struct
361 {
362 GType g_type;
363
364 union {
365 gint v_int;
366 guint v_uint;
367 glong v_long;
368 gulong v_ulong;
369 gint64 v_int64;
370 guint64 v_uint64;
371 gfloat v_float;
372 gdouble v_double;
373 gpointer v_pointer;
374 } data[2];
375 } GValue;
376
377 typedef struct
378 {
573 guint show_text : 1;
574 guint activity_mode : 1;
575 guint use_text_format : 1;
576 };
577
578 struct _GtkProgressBar
579 {
580 GtkProgress progress;
581 GtkProgressBarStyle bar_style;
582 GtkProgressBarOrientation orientation;
583 guint blocks;
584 gint in_block;
585 gint activity_pos;
586 guint activity_step;
587 guint activity_blocks;
588 gdouble pulse_fraction;
589 guint activity_dir : 1;
590 guint ellipsize : 3;
591 };
592
593 typedef enum {
594 GTK_RESPONSE_NONE = -1,
595 GTK_RESPONSE_REJECT = -2,
596 GTK_RESPONSE_ACCEPT = -3,
597 GTK_RESPONSE_DELETE_EVENT = -4,
598 GTK_RESPONSE_OK = -5,
599 GTK_RESPONSE_CANCEL = -6,
600 GTK_RESPONSE_CLOSE = -7,
601 GTK_RESPONSE_YES = -8,
602 GTK_RESPONSE_NO = -9,
603 GTK_RESPONSE_APPLY = -10,
604 GTK_RESPONSE_HELP = -11
605 } GtkResponseType;
606
607 typedef struct _GtkWindow GtkWindow;
608
609 typedef struct _GtkFileChooser GtkFileChooser;
610
611 typedef enum {
612 GTK_FILE_CHOOSER_ACTION_OPEN,
613 GTK_FILE_CHOOSER_ACTION_SAVE,
614 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
615 GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
616 } GtkFileChooserAction;
617
618 typedef struct _GtkFileFilter GtkFileFilter;
619
620 typedef enum {
621 GTK_FILE_FILTER_FILENAME = 1 << 0,
622 GTK_FILE_FILTER_URI = 1 << 1,
623 GTK_FILE_FILTER_DISPLAY_NAME = 1 << 2,
624 GTK_FILE_FILTER_MIME_TYPE = 1 << 3
625 } GtkFileFilterFlags;
626
627 typedef struct {
628 GtkFileFilterFlags contains;
629 const gchar *filename;
630 const gchar *uri;
631 const gchar *display_name;
632 const gchar *mime_type;
633 } GtkFileFilterInfo;
634
635 typedef gboolean (*GtkFileFilterFunc)(const GtkFileFilterInfo *filter_info,
636 gpointer data);
637
638 typedef void (*GDestroyNotify)(gpointer data);
639
640 typedef void (*GCallback)(void);
641
642 typedef struct _GClosure GClosure;
643
644 typedef void (*GClosureNotify)(gpointer data, GClosure *closure);
645
646 typedef enum {
647 G_CONNECT_AFTER = 1 << 0, G_CONNECT_SWAPPED = 1 << 1
648 } GConnectFlags;
649
650 typedef struct _GThreadFunctions GThreadFunctions;
651
652 /*
653 * Converts java.lang.String object to UTF-8 character string.
654 */
655 const char *getStrFor(JNIEnv *env, jstring value);
656
657 /**
658 * Returns :
659 * NULL if the GLib library is compatible with the given version, or a string
660 * describing the version mismatch.
661 * Please note that the glib_check_version() is available since 2.6,
662 * so you should use GLIB_CHECK_VERSION macro instead.
663 */
664 gchar* (*fp_glib_check_version)(guint required_major, guint required_minor,
665 guint required_micro);
666
667 /**
668 * Returns :
669 * TRUE if the GLib library is compatible with the given version
670 */
671 #define GLIB_CHECK_VERSION(major, minor, micro) \
672 (fp_glib_check_version && fp_glib_check_version(major, minor, micro) == NULL)
673
674 /*
675 * Check whether the gtk2 library is available and meets the minimum
676 * version requirement. If the library is already loaded this method has no
677 * effect and returns success.
678 * Returns FALSE on failure and TRUE on success.
679 */
680 gboolean gtk2_check_version();
681
682 /**
683 * Returns :
684 * NULL if the GTK+ library is compatible with the given version, or a string
685 * describing the version mismatch.
686 */
687 gchar* (*fp_gtk_check_version)(guint required_major, guint required_minor,
688 guint required_micro);
689 /*
690 * Load the gtk2 library. If the library is already loaded this method has no
691 * effect and returns success.
692 * Returns FALSE on failure and TRUE on success.
693 */
694 gboolean gtk2_load(JNIEnv *env);
695
696 /*
697 * Loads fp_gtk_show_uri function pointer. This initialization is
698 * separated because the function is required only
699 * for java.awt.Desktop API. The function relies on initialization in
700 * gtk2_load, so it must be invoked only after a successful gtk2_load
701 * invocation
702 */
703 gboolean gtk2_show_uri_load(JNIEnv *env);
704
705 /*
706 * Unload the gtk2 library. If the library is already unloaded this method has
707 * no effect and returns success.
708 * Returns FALSE on failure and TRUE on success.
709 */
710 gboolean gtk2_unload();
711
712 void gtk2_paint_arrow(WidgetType widget_type, GtkStateType state_type,
713 GtkShadowType shadow_type, const gchar *detail,
714 gint x, gint y, gint width, gint height,
715 GtkArrowType arrow_type, gboolean fill);
716 void gtk2_paint_box(WidgetType widget_type, GtkStateType state_type,
717 GtkShadowType shadow_type, const gchar *detail,
718 gint x, gint y, gint width, gint height,
719 gint synth_state, GtkTextDirection dir);
720 void gtk2_paint_box_gap(WidgetType widget_type, GtkStateType state_type,
721 GtkShadowType shadow_type, const gchar *detail,
722 gint x, gint y, gint width, gint height,
723 GtkPositionType gap_side, gint gap_x, gint gap_width);
724 void gtk2_paint_check(WidgetType widget_type, gint synth_state,
725 const gchar *detail, gint x, gint y, gint width, gint height);
726 void gtk2_paint_diamond(WidgetType widget_type, GtkStateType state_type,
727 GtkShadowType shadow_type, const gchar *detail,
728 gint x, gint y, gint width, gint height);
729 void gtk2_paint_expander(WidgetType widget_type, GtkStateType state_type,
730 const gchar *detail, gint x, gint y, gint width, gint height,
731 GtkExpanderStyle expander_style);
732 void gtk2_paint_extension(WidgetType widget_type, GtkStateType state_type,
733 GtkShadowType shadow_type, const gchar *detail,
734 gint x, gint y, gint width, gint height, GtkPositionType gap_side);
735 void gtk2_paint_flat_box(WidgetType widget_type, GtkStateType state_type,
736 GtkShadowType shadow_type, const gchar *detail,
737 gint x, gint y, gint width, gint height, gboolean has_focus);
738 void gtk2_paint_focus(WidgetType widget_type, GtkStateType state_type,
739 const char *detail, gint x, gint y, gint width, gint height);
740 void gtk2_paint_handle(WidgetType widget_type, GtkStateType state_type,
741 GtkShadowType shadow_type, const gchar *detail,
742 gint x, gint y, gint width, gint height, GtkOrientation orientation);
743 void gtk2_paint_hline(WidgetType widget_type, GtkStateType state_type,
744 const gchar *detail, gint x, gint y, gint width, gint height);
745 void gtk2_paint_option(WidgetType widget_type, gint synth_state,
746 const gchar *detail, gint x, gint y, gint width, gint height);
747 void gtk2_paint_shadow(WidgetType widget_type, GtkStateType state_type,
748 GtkShadowType shadow_type, const gchar *detail,
749 gint x, gint y, gint width, gint height,
750 gint synth_state, GtkTextDirection dir);
751 void gtk2_paint_slider(WidgetType widget_type, GtkStateType state_type,
752 GtkShadowType shadow_type, const gchar *detail,
753 gint x, gint y, gint width, gint height, GtkOrientation orientation);
754 void gtk2_paint_vline(WidgetType widget_type, GtkStateType state_type,
755 const gchar *detail, gint x, gint y, gint width, gint height);
756 void gtk_paint_background(WidgetType widget_type, GtkStateType state_type,
757 gint x, gint y, gint width, gint height);
758
759 void gtk2_init_painting(JNIEnv *env, gint w, gint h);
760 gint gtk2_copy_image(gint *dest, gint width, gint height);
761
762 gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type);
763 gint gtk2_get_ythickness(JNIEnv *env, WidgetType widget_type);
764 gint gtk2_get_color_for_state(JNIEnv *env, WidgetType widget_type,
765 GtkStateType state_type, ColorType color_type);
766 jobject gtk2_get_class_value(JNIEnv *env, WidgetType widget_type, jstring key);
767
768 GdkPixbuf *gtk2_get_stock_icon(gint widget_type, const gchar *stock_id,
769 GtkIconSize size, GtkTextDirection direction, const char *detail);
770 GdkPixbuf *gtk2_get_icon(const gchar *filename, gint size);
771 jstring gtk2_get_pango_font_name(JNIEnv *env, WidgetType widget_type);
772
773 void flush_gtk_event_loop();
774
775 jobject gtk2_get_setting(JNIEnv *env, Setting property);
776
777 void gtk2_set_range_value(WidgetType widget_type, jdouble value,
778 jdouble min, jdouble max, jdouble visible);
779
780 void (*fp_g_free)(gpointer mem);
781 void (*fp_g_object_unref)(gpointer object);
782 GdkWindow *(*fp_gdk_get_default_root_window) (void);
783
784 int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
785 guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
786 gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);
787 int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);
788 int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
789 int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
790 int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
791 GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
792 GdkColorspace (*fp_gdk_pixbuf_get_colorspace)(const GdkPixbuf *pixbuf);
793
794 GdkPixbuf *(*fp_gdk_pixbuf_get_from_drawable)(GdkPixbuf *dest,
795 GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y,
796 int dest_x, int dest_y, int width, int height);
797 GdkPixbuf *(*fp_gdk_pixbuf_scale_simple)(GdkPixbuf *src,
798 int dest_width, int dest_heigh, GdkInterpType interp_type);
799
800
801 void (*fp_gtk_widget_destroy)(GtkWidget *widget);
802 void (*fp_gtk_window_present)(GtkWindow *window);
803 void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);
804 void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);
805
806 /**
807 * Function Pointers for GtkFileChooser
808 */
809 gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
810 void (*fp_gtk_widget_hide)(GtkWidget *widget);
811 void (*fp_gtk_main_quit)(void);
812 GtkWidget* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,
813 GtkWindow *parent, GtkFileChooserAction action,
814 const gchar *first_button_text, ...);
815 gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
816 const gchar *filename);
817 gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
818 const char *filename);
819 void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
820 const gchar *name);
821 void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
822 GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
823 GDestroyNotify notify);
824 void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
825 GtkFileFilter *filter);
826 GType (*fp_gtk_file_chooser_get_type)(void);
827 GtkFileFilter* (*fp_gtk_file_filter_new)(void);
828 void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(
829 GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
830 void (*fp_gtk_file_chooser_set_select_multiple)(
831 GtkFileChooser *chooser, gboolean select_multiple);
832 gchar* (*fp_gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);
833 GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
834 guint (*fp_gtk_g_slist_length)(GSList *list);
835 gulong (*fp_g_signal_connect_data)(gpointer instance,
836 const gchar *detailed_signal, GCallback c_handler, gpointer data,
837 GClosureNotify destroy_data, GConnectFlags connect_flags);
838 void (*fp_gtk_widget_show)(GtkWidget *widget);
839 void (*fp_gtk_main)(void);
840 guint (*fp_gtk_main_level)(void);
841 gchar* (*fp_g_path_get_dirname) (const gchar *file_name);
842 XID (*fp_gdk_x11_drawable_get_xid) (GdkWindow *drawable);
843
844 /**
845 * This function is available for GLIB > 2.20, so it MUST be
846 * called within GLIB_CHECK_VERSION(2, 20, 0) check.
847 */
848 gboolean (*fp_g_thread_get_initialized)(void);
849
850 void (*fp_g_thread_init)(GThreadFunctions *vtable);
851 void (*fp_gdk_threads_init)(void);
852 void (*fp_gdk_threads_enter)(void);
853 void (*fp_gdk_threads_leave)(void);
854
855 gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,
856 guint32 timestamp, GError **error);
857
858 #endif /* !_GTK2_INTERFACE_H */
|
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 #ifndef _GTK2_INTERFACE_H
26 #define _GTK2_INTERFACE_H
27
28 #include <stdlib.h>
29 #include <jni.h>
30 #include <X11/X.h>
31 #include "gtk_interface.h"
32
33 #define GTK_HAS_FOCUS (1 << 12)
34 #define GTK_HAS_DEFAULT (1 << 14)
35
36 typedef enum
37 {
38 GTK_WINDOW_TOPLEVEL,
39 GTK_WINDOW_POPUP
40 } GtkWindowType;
41
42 typedef enum
43 {
44 G_PARAM_READABLE = 1 << 0,
45 G_PARAM_WRITABLE = 1 << 1,
46 G_PARAM_CONSTRUCT = 1 << 2,
47 G_PARAM_CONSTRUCT_ONLY = 1 << 3,
48 G_PARAM_LAX_VALIDATION = 1 << 4,
49 G_PARAM_PRIVATE = 1 << 5
50 } GParamFlags;
51
52 /* We define all structure pointers to be void* */
53 typedef void GMainContext;
54 typedef void GVfs;
55
56 typedef void GdkColormap;
57 typedef void GdkDrawable;
58 typedef void GdkGC;
59 typedef void GdkPixbuf;
60 typedef void GdkPixmap;
61
62 typedef void GtkFixed;
63 typedef void GtkMenuItem;
64 typedef void GtkMenuShell;
65 typedef void GtkWidgetClass;
66 typedef void PangoFontDescription;
67 typedef void GtkSettings;
68
69 /* Some real structures */
70 typedef struct
71 {
72 guint32 pixel;
73 guint16 red;
74 guint16 green;
75 guint16 blue;
76 } GdkColor;
77
78 typedef struct {
79 gint fd;
80 gushort events;
100 gint height;
101 } GtkRequisition;
102
103 typedef struct {
104 GtkWidgetClass *g_class;
105 } GTypeInstance;
106
107 typedef struct {
108 gint left;
109 gint right;
110 gint top;
111 gint bottom;
112 } GtkBorder;
113
114 /******************************************************
115 * FIXME: it is more safe to include gtk headers for
116 * the precise type definition of GType and other
117 * structures. This is a place where getting rid of gtk
118 * headers may be dangerous.
119 ******************************************************/
120
121 typedef struct
122 {
123 GType g_type;
124
125 union {
126 gint v_int;
127 guint v_uint;
128 glong v_long;
129 gulong v_ulong;
130 gint64 v_int64;
131 guint64 v_uint64;
132 gfloat v_float;
133 gdouble v_double;
134 gpointer v_pointer;
135 } data[2];
136 } GValue;
137
138 typedef struct
139 {
334 guint show_text : 1;
335 guint activity_mode : 1;
336 guint use_text_format : 1;
337 };
338
339 struct _GtkProgressBar
340 {
341 GtkProgress progress;
342 GtkProgressBarStyle bar_style;
343 GtkProgressBarOrientation orientation;
344 guint blocks;
345 gint in_block;
346 gint activity_pos;
347 guint activity_step;
348 guint activity_blocks;
349 gdouble pulse_fraction;
350 guint activity_dir : 1;
351 guint ellipsize : 3;
352 };
353
354
355 typedef struct _GThreadFunctions GThreadFunctions;
356
357 /**
358 * Returns :
359 * NULL if the GLib library is compatible with the given version, or a string
360 * describing the version mismatch.
361 * Please note that the glib_check_version() is available since 2.6,
362 * so you should use GLIB_CHECK_VERSION macro instead.
363 */
364 static gchar* (*fp_glib_check_version)(guint required_major, guint required_minor,
365 guint required_micro);
366
367 /**
368 * Returns :
369 * TRUE if the GLib library is compatible with the given version
370 */
371 #define GLIB_CHECK_VERSION(major, minor, micro) \
372 (fp_glib_check_version && fp_glib_check_version(major, minor, micro) == NULL)
373
374 /**
375 * Returns :
376 * NULL if the GTK+ library is compatible with the given version, or a string
377 * describing the version mismatch.
378 */
379 static gchar* (*fp_gtk_check_version)(guint required_major, guint required_minor,
380 guint required_micro);
381
382 static void gtk2_init(GtkApi* gtk);
383
384 static void (*fp_g_free)(gpointer mem);
385 static void (*fp_g_object_unref)(gpointer object);
386 static GdkWindow *(*fp_gdk_get_default_root_window) (void);
387
388 static int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
389 static guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
390 static gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);
391 static int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);
392 static int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
393 static int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
394 static int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
395 static GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
396 static GdkColorspace (*fp_gdk_pixbuf_get_colorspace)(const GdkPixbuf *pixbuf);
397
398 static GdkPixbuf *(*fp_gdk_pixbuf_get_from_drawable)(GdkPixbuf *dest,
399 GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y,
400 int dest_x, int dest_y, int width, int height);
401 static GdkPixbuf *(*fp_gdk_pixbuf_scale_simple)(GdkPixbuf *src,
402 int dest_width, int dest_heigh, GdkInterpType interp_type);
403
404
405 static void (*fp_gtk_widget_destroy)(void *widget);
406 static void (*fp_gtk_window_present)(GtkWindow *window);
407 static void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);
408 static void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);
409
410 /**
411 * Function Pointers for GtkFileChooser
412 */
413 static gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
414 static void (*fp_gtk_widget_hide)(void *widget);
415 static void (*fp_gtk_main_quit)(void);
416 static void* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,
417 GtkWindow *parent, GtkFileChooserAction action,
418 const gchar *first_button_text, ...);
419 static gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
420 const gchar *filename);
421 static gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
422 const char *filename);
423 static void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
424 const gchar *name);
425 static void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
426 GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
427 GDestroyNotify notify);
428 static void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
429 GtkFileFilter *filter);
430 static GType (*fp_gtk_file_chooser_get_type)(void);
431 static GtkFileFilter* (*fp_gtk_file_filter_new)(void);
432 static void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(
433 GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
434 static void (*fp_gtk_file_chooser_set_select_multiple)(
435 GtkFileChooser *chooser, gboolean select_multiple);
436 static gchar* (*fp_gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);
437 static GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
438 static guint (*fp_gtk_g_slist_length)(GSList *list);
439 static gulong (*fp_g_signal_connect_data)(gpointer instance,
440 const gchar *detailed_signal, GCallback c_handler, gpointer data,
441 GClosureNotify destroy_data, GConnectFlags connect_flags);
442 static void (*fp_gtk_widget_show)(void *widget);
443 static void (*fp_gtk_main)(void);
444 static guint (*fp_gtk_main_level)(void);
445 static gchar* (*fp_g_path_get_dirname) (const gchar *file_name);
446 static XID (*fp_gdk_x11_drawable_get_xid) (GdkWindow *drawable);
447
448 /**
449 * This function is available for GLIB > 2.20, so it MUST be
450 * called within GLIB_CHECK_VERSION(2, 20, 0) check.
451 */
452 static gboolean (*fp_g_thread_get_initialized)(void);
453
454 static void (*fp_g_thread_init)(GThreadFunctions *vtable);
455 static void (*fp_gdk_threads_init)(void);
456 static void (*fp_gdk_threads_enter)(void);
457 static void (*fp_gdk_threads_leave)(void);
458
459 static gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,
460 guint32 timestamp, GError **error);
461
462 #endif /* !_GTK2_INTERFACE_H */
|