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; 80 gushort revents; 81 } GPollFD; 82 83 typedef struct { 84 gint x; 85 gint y; 86 gint width; 87 gint height; 88 } GdkRectangle; 89 90 typedef struct { 91 gint x; 92 gint y; 93 gint width; 94 gint height; 95 } GtkAllocation; 96 97 typedef struct { 98 gint width; 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 { 139 GTypeInstance g_type_instance; 140 141 gchar *name; 142 GParamFlags flags; 143 GType value_type; 144 GType owner_type; 145 } GParamSpec; 146 147 typedef struct { 148 GTypeInstance g_type_instance; 149 guint ref_count; 150 void *qdata; 151 } GObject; 152 153 typedef struct { 154 GObject parent_instance; 155 guint32 flags; 156 } GtkObject; 157 158 typedef struct 159 { 160 GObject parent_instance; 161 162 GdkColor fg[5]; 163 GdkColor bg[5]; 164 GdkColor light[5]; 165 GdkColor dark[5]; 166 GdkColor mid[5]; 167 GdkColor text[5]; 168 GdkColor base[5]; 169 GdkColor text_aa[5]; /* Halfway between text/base */ 170 171 GdkColor black; 172 GdkColor white; 173 PangoFontDescription *font_desc; 174 175 gint xthickness; 176 gint ythickness; 177 178 GdkGC *fg_gc[5]; 179 GdkGC *bg_gc[5]; 180 GdkGC *light_gc[5]; 181 GdkGC *dark_gc[5]; 182 GdkGC *mid_gc[5]; 183 GdkGC *text_gc[5]; 184 GdkGC *base_gc[5]; 185 GdkGC *text_aa_gc[5]; 186 GdkGC *black_gc; 187 GdkGC *white_gc; 188 189 GdkPixmap *bg_pixmap[5]; 190 } GtkStyle; 191 192 typedef struct _GtkWidget GtkWidget; 193 struct _GtkWidget 194 { 195 GtkObject object; 196 guint16 private_flags; 197 guint8 state; 198 guint8 saved_state; 199 gchar *name; 200 GtkStyle *style; 201 GtkRequisition requisition; 202 GtkAllocation allocation; 203 GdkWindow *window; 204 GtkWidget *parent; 205 }; 206 207 typedef struct 208 { 209 GtkWidget widget; 210 211 gfloat xalign; 212 gfloat yalign; 213 214 guint16 xpad; 215 guint16 ypad; 216 } GtkMisc; 217 218 typedef struct { 219 GtkWidget widget; 220 GtkWidget *focus_child; 221 guint border_width : 16; 222 guint need_resize : 1; 223 guint resize_mode : 2; 224 guint reallocate_redraws : 1; 225 guint has_focus_chain : 1; 226 } GtkContainer; 227 228 typedef struct { 229 GtkContainer container; 230 GtkWidget *child; 231 } GtkBin; 232 233 typedef struct { 234 GtkBin bin; 235 GdkWindow *event_window; 236 gchar *label_text; 237 guint activate_timeout; 238 guint constructed : 1; 239 guint in_button : 1; 240 guint button_down : 1; 241 guint relief : 2; 242 guint use_underline : 1; 243 guint use_stock : 1; 244 guint depressed : 1; 245 guint depress_on_activate : 1; 246 guint focus_on_click : 1; 247 } GtkButton; 248 249 typedef struct { 250 GtkButton button; 251 guint active : 1; 252 guint draw_indicator : 1; 253 guint inconsistent : 1; 254 } GtkToggleButton; 255 256 typedef struct _GtkAdjustment GtkAdjustment; 257 struct _GtkAdjustment 258 { 259 GtkObject parent_instance; 260 261 gdouble lower; 262 gdouble upper; 263 gdouble value; 264 gdouble step_increment; 265 gdouble page_increment; 266 gdouble page_size; 267 }; 268 269 typedef enum 270 { 271 GTK_UPDATE_CONTINUOUS, 272 GTK_UPDATE_DISCONTINUOUS, 273 GTK_UPDATE_DELAYED 274 } GtkUpdateType; 275 276 typedef struct _GtkRange GtkRange; 277 struct _GtkRange 278 { 279 GtkWidget widget; 280 GtkAdjustment *adjustment; 281 GtkUpdateType update_policy; 282 guint inverted : 1; 283 /*< protected >*/ 284 guint flippable : 1; 285 guint has_stepper_a : 1; 286 guint has_stepper_b : 1; 287 guint has_stepper_c : 1; 288 guint has_stepper_d : 1; 289 guint need_recalc : 1; 290 guint slider_size_fixed : 1; 291 gint min_slider_size; 292 GtkOrientation orientation; 293 GdkRectangle range_rect; 294 gint slider_start, slider_end; 295 gint round_digits; 296 /*< private >*/ 297 guint trough_click_forward : 1; 298 guint update_pending : 1; 299 /*GtkRangeLayout * */ void *layout; 300 /*GtkRangeStepTimer * */ void* timer; 301 gint slide_initial_slider_position; 302 gint slide_initial_coordinate; 303 guint update_timeout_id; 304 GdkWindow *event_window; 305 }; 306 307 typedef struct _GtkProgressBar GtkProgressBar; 308 309 typedef enum 310 { 311 GTK_PROGRESS_CONTINUOUS, 312 GTK_PROGRESS_DISCRETE 313 } GtkProgressBarStyle; 314 315 typedef enum 316 { 317 GTK_PROGRESS_LEFT_TO_RIGHT, 318 GTK_PROGRESS_RIGHT_TO_LEFT, 319 GTK_PROGRESS_BOTTOM_TO_TOP, 320 GTK_PROGRESS_TOP_TO_BOTTOM 321 } GtkProgressBarOrientation; 322 323 typedef struct _GtkProgress GtkProgress; 324 325 struct _GtkProgress 326 { 327 GtkWidget widget; 328 GtkAdjustment *adjustment; 329 GdkPixmap *offscreen_pixmap; 330 gchar *format; 331 gfloat x_align; 332 gfloat y_align; 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 */