src/solaris/native/sun/awt/gtk2_interface.h

Print this page




  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  22  * CA 95054 USA or visit www.sun.com if you need additional information or
  23  * have any questions.
  24  */
  25 #ifndef _GTK2_INTERFACE_H
  26 #define _GTK2_INTERFACE_H
  27 
  28 #include <stdlib.h>
  29 #include <jni.h>
  30 















  31 typedef enum _WidgetType
  32 {
  33     BUTTON,                     /* GtkButton */
  34     CHECK_BOX,                  /* GtkCheckButton */
  35     CHECK_BOX_MENU_ITEM,        /* GtkCheckMenuItem */
  36     COLOR_CHOOSER,              /* GtkColorSelectionDialog */
  37     COMBO_BOX,                  /* GtkComboBox */
  38     COMBO_BOX_ARROW_BUTTON,     /* GtkComboBoxEntry */
  39     COMBO_BOX_TEXT_FIELD,       /* GtkComboBoxEntry */
  40     DESKTOP_ICON,               /* GtkLabel */
  41     DESKTOP_PANE,               /* GtkContainer */
  42     EDITOR_PANE,                /* GtkTextView */
  43     FORMATTED_TEXT_FIELD,       /* GtkEntry */
  44     HANDLE_BOX,                 /* GtkHandleBox */
  45     HPROGRESS_BAR,              /* GtkProgressBar */
  46     HSCROLL_BAR,                /* GtkHScrollbar */
  47     HSCROLL_BAR_BUTTON_LEFT,    /* GtkHScrollbar */
  48     HSCROLL_BAR_BUTTON_RIGHT,   /* GtkHScrollbar */
  49     HSCROLL_BAR_TRACK,          /* GtkHScrollbar */
  50     HSCROLL_BAR_THUMB,          /* GtkHScrollbar */


 237 
 238 typedef enum
 239 {
 240   GTK_WINDOW_TOPLEVEL,
 241   GTK_WINDOW_POPUP
 242 } GtkWindowType;
 243 
 244 typedef enum
 245 {
 246   G_PARAM_READABLE            = 1 << 0,
 247   G_PARAM_WRITABLE            = 1 << 1,
 248   G_PARAM_CONSTRUCT           = 1 << 2,
 249   G_PARAM_CONSTRUCT_ONLY      = 1 << 3,
 250   G_PARAM_LAX_VALIDATION      = 1 << 4,
 251   G_PARAM_PRIVATE             = 1 << 5
 252 } GParamFlags;
 253 
 254 /* We define all structure pointers to be void* */
 255 typedef void GError;
 256 typedef void GMainContext;
 257 typedef void GSList;






 258 
 259 typedef void GdkColormap;
 260 typedef void GdkDrawable;
 261 typedef void GdkGC;
 262 typedef void GdkPixbuf;
 263 typedef void GdkPixmap;
 264 typedef void GdkWindow;
 265 
 266 typedef void GtkFixed;
 267 typedef void GtkMenuItem;
 268 typedef void GtkMenuShell;
 269 typedef void GtkWidgetClass;
 270 typedef void PangoFontDescription;
 271 typedef void GtkSettings;
 272 
 273 /* Some real structures */
 274 typedef struct
 275 {
 276   guint32 pixel;
 277   guint16 red;


 539   guint          show_text : 1;
 540   guint          activity_mode : 1;
 541   guint          use_text_format : 1;
 542 };
 543 
 544 struct _GtkProgressBar
 545 {
 546   GtkProgress progress;
 547   GtkProgressBarStyle bar_style;
 548   GtkProgressBarOrientation orientation;
 549   guint blocks;
 550   gint  in_block;
 551   gint  activity_pos;
 552   guint activity_step;
 553   guint activity_blocks;
 554   gdouble pulse_fraction;
 555   guint activity_dir : 1;
 556   guint ellipsize : 3;
 557 };
 558 




























































 559 /*
 560  * Converts java.lang.String object to UTF-8 character string.
 561  */
 562 const char *getStrFor(JNIEnv *env, jstring value);
 563 
 564 /*
 565  * Check whether the gtk2 library is available and meets the minimum
 566  * version requirement.  If the library is already loaded this method has no
 567  * effect and returns success.
 568  * Returns FALSE on failure and TRUE on success.
 569  */
 570 gboolean gtk2_check_version();
 571 







 572 /*
 573  * Load the gtk2 library.  If the library is already loaded this method has no
 574  * effect and returns success.
 575  * Returns FALSE on failure and TRUE on success.
 576  */
 577 gboolean gtk2_load();
 578 
 579 /*
 580  * Unload the gtk2 library.  If the library is already unloaded this method has
 581  * no effect and returns success.
 582  * Returns FALSE on failure and TRUE on success.
 583  */
 584 gboolean gtk2_unload();
 585 
 586 void gtk2_paint_arrow(WidgetType widget_type, GtkStateType state_type,
 587         GtkShadowType shadow_type, const gchar *detail,
 588         gint x, gint y, gint width, gint height,
 589         GtkArrowType arrow_type, gboolean fill);
 590 void gtk2_paint_box(WidgetType widget_type, GtkStateType state_type,
 591         GtkShadowType shadow_type, const gchar *detail,


 634 gint gtk2_copy_image(gint *dest, gint width, gint height);
 635 
 636 gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type);
 637 gint gtk2_get_ythickness(JNIEnv *env, WidgetType widget_type);
 638 gint gtk2_get_color_for_state(JNIEnv *env, WidgetType widget_type,
 639                               GtkStateType state_type, ColorType color_type);
 640 jobject gtk2_get_class_value(JNIEnv *env, WidgetType widget_type, jstring key);
 641 
 642 GdkPixbuf *gtk2_get_stock_icon(gint widget_type, const gchar *stock_id,
 643         GtkIconSize size, GtkTextDirection direction, const char *detail);
 644 GdkPixbuf *gtk2_get_icon(const gchar *filename, gint size);
 645 jstring gtk2_get_pango_font_name(JNIEnv *env, WidgetType widget_type);
 646 
 647 void flush_gtk_event_loop();
 648 
 649 jobject gtk2_get_setting(JNIEnv *env, Setting property);
 650 
 651 void gtk2_set_range_value(WidgetType widget_type, jdouble value,
 652                           jdouble min, jdouble max, jdouble visible);
 653 

 654 void (*fp_g_object_unref)(gpointer object);
 655 int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
 656 guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
 657 gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);
 658 int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);
 659 int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
 660 int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
 661 int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
 662 GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);











































 663 
 664 #endif /* !_GTK2_INTERFACE_H */


  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  22  * CA 95054 USA or visit www.sun.com if you need additional information or
  23  * have any 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 
  46 typedef enum _WidgetType
  47 {
  48     BUTTON,                     /* GtkButton */
  49     CHECK_BOX,                  /* GtkCheckButton */
  50     CHECK_BOX_MENU_ITEM,        /* GtkCheckMenuItem */
  51     COLOR_CHOOSER,              /* GtkColorSelectionDialog */
  52     COMBO_BOX,                  /* GtkComboBox */
  53     COMBO_BOX_ARROW_BUTTON,     /* GtkComboBoxEntry */
  54     COMBO_BOX_TEXT_FIELD,       /* GtkComboBoxEntry */
  55     DESKTOP_ICON,               /* GtkLabel */
  56     DESKTOP_PANE,               /* GtkContainer */
  57     EDITOR_PANE,                /* GtkTextView */
  58     FORMATTED_TEXT_FIELD,       /* GtkEntry */
  59     HANDLE_BOX,                 /* GtkHandleBox */
  60     HPROGRESS_BAR,              /* GtkProgressBar */
  61     HSCROLL_BAR,                /* GtkHScrollbar */
  62     HSCROLL_BAR_BUTTON_LEFT,    /* GtkHScrollbar */
  63     HSCROLL_BAR_BUTTON_RIGHT,   /* GtkHScrollbar */
  64     HSCROLL_BAR_TRACK,          /* GtkHScrollbar */
  65     HSCROLL_BAR_THUMB,          /* GtkHScrollbar */


 252 
 253 typedef enum
 254 {
 255   GTK_WINDOW_TOPLEVEL,
 256   GTK_WINDOW_POPUP
 257 } GtkWindowType;
 258 
 259 typedef enum
 260 {
 261   G_PARAM_READABLE            = 1 << 0,
 262   G_PARAM_WRITABLE            = 1 << 1,
 263   G_PARAM_CONSTRUCT           = 1 << 2,
 264   G_PARAM_CONSTRUCT_ONLY      = 1 << 3,
 265   G_PARAM_LAX_VALIDATION      = 1 << 4,
 266   G_PARAM_PRIVATE             = 1 << 5
 267 } GParamFlags;
 268 
 269 /* We define all structure pointers to be void* */
 270 typedef void GError;
 271 typedef void GMainContext;
 272 
 273 typedef struct _GSList GSList;
 274 struct _GSList
 275 {
 276   gpointer data;
 277   GSList *next;
 278 };
 279 
 280 typedef void GdkColormap;
 281 typedef void GdkDrawable;
 282 typedef void GdkGC;
 283 typedef void GdkPixbuf;
 284 typedef void GdkPixmap;
 285 typedef void GdkWindow;
 286 
 287 typedef void GtkFixed;
 288 typedef void GtkMenuItem;
 289 typedef void GtkMenuShell;
 290 typedef void GtkWidgetClass;
 291 typedef void PangoFontDescription;
 292 typedef void GtkSettings;
 293 
 294 /* Some real structures */
 295 typedef struct
 296 {
 297   guint32 pixel;
 298   guint16 red;


 560   guint          show_text : 1;
 561   guint          activity_mode : 1;
 562   guint          use_text_format : 1;
 563 };
 564 
 565 struct _GtkProgressBar
 566 {
 567   GtkProgress progress;
 568   GtkProgressBarStyle bar_style;
 569   GtkProgressBarOrientation orientation;
 570   guint blocks;
 571   gint  in_block;
 572   gint  activity_pos;
 573   guint activity_step;
 574   guint activity_blocks;
 575   gdouble pulse_fraction;
 576   guint activity_dir : 1;
 577   guint ellipsize : 3;
 578 };
 579 
 580 typedef enum {
 581         GTK_RESPONSE_NONE = -1,
 582         GTK_RESPONSE_REJECT = -2,
 583         GTK_RESPONSE_ACCEPT = -3,
 584         GTK_RESPONSE_DELETE_EVENT = -4,
 585         GTK_RESPONSE_OK = -5,
 586         GTK_RESPONSE_CANCEL = -6,
 587         GTK_RESPONSE_CLOSE = -7,
 588         GTK_RESPONSE_YES = -8,
 589         GTK_RESPONSE_NO = -9,
 590         GTK_RESPONSE_APPLY = -10,
 591         GTK_RESPONSE_HELP = -11
 592 } GtkResponseType;
 593 
 594 typedef struct _GtkWindow GtkWindow;
 595 
 596 typedef struct _GtkFileChooser GtkFileChooser;
 597 
 598 typedef enum {
 599         GTK_FILE_CHOOSER_ACTION_OPEN,
 600         GTK_FILE_CHOOSER_ACTION_SAVE,
 601         GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
 602         GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
 603 } GtkFileChooserAction;
 604 
 605 typedef struct _GtkFileFilter GtkFileFilter;
 606 
 607 typedef enum {
 608         GTK_FILE_FILTER_FILENAME = 1 << 0,
 609         GTK_FILE_FILTER_URI = 1 << 1,
 610         GTK_FILE_FILTER_DISPLAY_NAME = 1 << 2,
 611         GTK_FILE_FILTER_MIME_TYPE = 1 << 3
 612 } GtkFileFilterFlags;
 613 
 614 typedef struct {
 615         GtkFileFilterFlags contains;
 616 
 617         const gchar *filename;
 618         const gchar *uri;
 619         const gchar *display_name;
 620         const gchar *mime_type;
 621 } GtkFileFilterInfo;
 622 
 623 typedef gboolean (*GtkFileFilterFunc)(const GtkFileFilterInfo *filter_info,
 624                 gpointer data);
 625 
 626 typedef void (*GDestroyNotify)(gpointer data);
 627 
 628 typedef void (*GCallback)(void);
 629 
 630 typedef struct _GClosure GClosure;
 631 
 632 typedef void (*GClosureNotify)(gpointer data, GClosure *closure);
 633 
 634 typedef enum {
 635         G_CONNECT_AFTER = 1 << 0, G_CONNECT_SWAPPED = 1 << 1
 636 } GConnectFlags;
 637 
 638 typedef struct _GThreadFunctions GThreadFunctions;
 639 
 640 /*
 641  * Converts java.lang.String object to UTF-8 character string.
 642  */
 643 const char *getStrFor(JNIEnv *env, jstring value);
 644 
 645 /*
 646  * Check whether the gtk2 library is available and meets the minimum
 647  * version requirement.  If the library is already loaded this method has no
 648  * effect and returns success.
 649  * Returns FALSE on failure and TRUE on success.
 650  */
 651 gboolean gtk2_check_version();
 652 
 653 /**
 654  * Returns :
 655  *      NULL if the GTK+ library is compatible with the given version, or a string
 656  *      describing the version mismatch.
 657  */
 658 gchar* (*fp_gtk_check_version)(guint required_major, guint required_minor,
 659                                        guint required_micro);
 660 /*
 661  * Load the gtk2 library.  If the library is already loaded this method has no
 662  * effect and returns success.
 663  * Returns FALSE on failure and TRUE on success.
 664  */
 665 gboolean gtk2_load();
 666 
 667 /*
 668  * Unload the gtk2 library.  If the library is already unloaded this method has
 669  * no effect and returns success.
 670  * Returns FALSE on failure and TRUE on success.
 671  */
 672 gboolean gtk2_unload();
 673 
 674 void gtk2_paint_arrow(WidgetType widget_type, GtkStateType state_type,
 675         GtkShadowType shadow_type, const gchar *detail,
 676         gint x, gint y, gint width, gint height,
 677         GtkArrowType arrow_type, gboolean fill);
 678 void gtk2_paint_box(WidgetType widget_type, GtkStateType state_type,
 679         GtkShadowType shadow_type, const gchar *detail,


 722 gint gtk2_copy_image(gint *dest, gint width, gint height);
 723 
 724 gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type);
 725 gint gtk2_get_ythickness(JNIEnv *env, WidgetType widget_type);
 726 gint gtk2_get_color_for_state(JNIEnv *env, WidgetType widget_type,
 727                               GtkStateType state_type, ColorType color_type);
 728 jobject gtk2_get_class_value(JNIEnv *env, WidgetType widget_type, jstring key);
 729 
 730 GdkPixbuf *gtk2_get_stock_icon(gint widget_type, const gchar *stock_id,
 731         GtkIconSize size, GtkTextDirection direction, const char *detail);
 732 GdkPixbuf *gtk2_get_icon(const gchar *filename, gint size);
 733 jstring gtk2_get_pango_font_name(JNIEnv *env, WidgetType widget_type);
 734 
 735 void flush_gtk_event_loop();
 736 
 737 jobject gtk2_get_setting(JNIEnv *env, Setting property);
 738 
 739 void gtk2_set_range_value(WidgetType widget_type, jdouble value,
 740                           jdouble min, jdouble max, jdouble visible);
 741 
 742 void (*fp_g_free)(gpointer mem);
 743 void (*fp_g_object_unref)(gpointer object);
 744 int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
 745 guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
 746 gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);
 747 int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);
 748 int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
 749 int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
 750 int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
 751 GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
 752 void (*fp_gtk_widget_destroy)(GtkWidget *widget);
 753 
 754 
 755 /**
 756  * Function Pointers for GtkFileChooser
 757  */
 758 gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
 759 void (*fp_gtk_widget_hide)(GtkWidget *widget);
 760 void (*fp_gtk_main_quit)(void);
 761 GtkWidget* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,
 762                 GtkWindow *parent, GtkFileChooserAction action,
 763                 const gchar *first_button_text, ...);
 764 gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
 765                 const gchar *filename);
 766 gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
 767                 const char *filename);
 768 void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
 769                 GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
 770                 GDestroyNotify notify);
 771 void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
 772                 GtkFileFilter *filter);
 773 GType (*fp_gtk_file_chooser_get_type)(void);
 774 GtkFileFilter* (*fp_gtk_file_filter_new)(void);
 775 void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(
 776                 GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
 777 void (*fp_gtk_file_chooser_set_select_multiple)(
 778                 GtkFileChooser *chooser, gboolean select_multiple);
 779 gchar* (*fp_gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);
 780 GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
 781 guint (*fp_gtk_g_slist_length)(GSList *list);
 782 gulong (*fp_g_signal_connect_data)(gpointer instance,
 783                 const gchar *detailed_signal, GCallback c_handler, gpointer data,
 784                 GClosureNotify destroy_data, GConnectFlags connect_flags);
 785 void (*fp_gtk_widget_show)(GtkWidget *widget);
 786 void (*fp_gtk_main)(void);
 787 guint (*fp_gtk_main_level)(void);
 788 
 789 
 790 gboolean (*fp_g_thread_get_initialized)(void);
 791 void (*fp_g_thread_init)(GThreadFunctions *vtable);
 792 void (*fp_gdk_threads_init)(void);
 793 void (*fp_gdk_threads_enter)(void);
 794 void (*fp_gdk_threads_leave)(void);
 795 
 796 #endif /* !_GTK2_INTERFACE_H */