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