home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / perl5 / Gtk2 / Install / gtk2perl.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-01-07  |  8.3 KB  |  227 lines

  1. /*
  2.  * 
  3.  * Copyright (C) 2003-2004 by the gtk2-perl team (see the file AUTHORS for the
  4.  * full list)
  5.  * 
  6.  * This library is free software; you can redistribute it and/or modify it
  7.  * under the terms of the GNU Library General Public License as published by
  8.  * the Free Software Foundation; either version 2.1 of the License, or (at your
  9.  * option) any later version.
  10.  * 
  11.  * This library 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 Library General Public
  14.  * License for more details.
  15.  * 
  16.  * You should have received a copy of the GNU Library General Public License
  17.  * along with this library; if not, write to the Free Software Foundation,
  18.  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307  USA.
  19.  * 
  20.  *
  21.  * $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/gtk2perl.h,v 1.46 2008/01/07 19:54:48 kaffeetisch Exp $
  22.  */
  23.  
  24. #ifndef _GTK2PERL_H_
  25. #define _GTK2PERL_H_
  26.  
  27. #include <gperl.h>
  28. #include <gtk/gtk.h>
  29.  
  30. #include "gtk2perl-versions.h"
  31.  
  32. /* custom GType for GdkRegion */
  33. #ifndef GDK_TYPE_REGION
  34. # define GDK_TYPE_REGION (gtk2perl_gdk_region_get_type ())
  35.   GType gtk2perl_gdk_region_get_type (void) G_GNUC_CONST;
  36. #endif
  37.  
  38. /* custom GType for PangoAttribute */
  39. #ifndef PANGO_TYPE_ATTRIBUTE
  40. # define PANGO_TYPE_ATTRIBUTE (gtk2perl_pango_attribute_get_type ())
  41.   GType gtk2perl_pango_attribute_get_type (void) G_GNUC_CONST;
  42. #endif
  43.  
  44. /* custom GType for PangoAttrIter */
  45. #ifndef PANGO_TYPE_ATTR_ITERATOR
  46. # define PANGO_TYPE_ATTR_ITERATOR (gtk2perl_pango_attr_iterator_get_type ())
  47.   GType gtk2perl_pango_attr_iterator_get_type (void) G_GNUC_CONST;
  48. #endif
  49.  
  50. /* custom GType for PangoLayoutIter */
  51. #ifndef PANGO_TYPE_LAYOUT_ITER
  52. # define PANGO_TYPE_LAYOUT_ITER (gtk2perl_pango_layout_iter_get_type ())
  53.   GType gtk2perl_pango_layout_iter_get_type (void) G_GNUC_CONST;
  54. #endif
  55.  
  56. /* custom GType for PangoLayoutLine */
  57. #ifndef PANGO_TYPE_LAYOUT_LINE
  58. # define PANGO_TYPE_LAYOUT_LINE (gtk2perl_pango_layout_line_get_type ())
  59.   GType gtk2perl_pango_layout_line_get_type (void) G_GNUC_CONST;
  60. #endif
  61.  
  62. /* custom GType for PangoScriptIter */
  63. #if PANGO_CHECK_VERSION (1, 4, 0)
  64. # ifndef PANGO_TYPE_SCRIPT_ITER
  65. #  define PANGO_TYPE_SCRIPT_ITER (gtk2perl_pango_script_iter_get_type ())
  66.    GType gtk2perl_pango_script_iter_get_type (void) G_GNUC_CONST;
  67. # endif
  68. #endif
  69.  
  70. #include "gtk2perl-autogen.h"
  71.  
  72. /* no plug/socket on non-X11 despite patches exist for years. */
  73. #ifndef GDK_WINDOWING_X11
  74. # undef GTK_TYPE_PLUG
  75. # undef GTK_TYPE_SOCKET
  76. #endif
  77.  
  78. /**
  79.  * gtk2perl_new_gtkobject:
  80.  * @object: object to wrap.
  81.  * 
  82.  * convenient wrapper around gperl_new_object() which always passes %TRUE
  83.  * for gperl_new_object()'s "own" parameter.  for #GtkObjects, that parameter
  84.  * merely results in gtk_object_sink() being called; if the object was not
  85.  * floating, this does nothing.  thus, everything just works out.
  86.  *
  87.  * returns: scalar wrapper for @object.
  88.  *
  89.  * in xs/GtkObject.xs 
  90.  */
  91. SV * gtk2perl_new_gtkobject (GtkObject * object);
  92.  
  93.  
  94. /*
  95. custom handling for GdkBitmaps, since there are no typemacros for them.
  96. */
  97. /* GObject derivative GdkBitmap */
  98. #define SvGdkBitmap(sv)       ((GdkBitmap*)gperl_get_object_check (sv, GDK_TYPE_DRAWABLE))
  99. typedef GdkBitmap GdkBitmap_ornull;
  100. #define SvGdkBitmap_ornull(sv)        (gperl_sv_is_defined (sv) ? SvGdkBitmap(sv) : NULL)
  101. typedef GdkBitmap GdkBitmap_noinc;
  102. /* these are real functions, rather than macros, because there's some extra
  103.  * work involved in making sure it's blessed into Gtk2::Gdk::Bitmap when no
  104.  * GType exists for GdkBitmap. */
  105. SV * newSVGdkBitmap (GdkBitmap * bitmap);
  106. SV * newSVGdkBitmap_noinc (GdkBitmap * bitmap);
  107. #define newSVGdkBitmap_ornull(b) (b ? newSVGdkBitmap (b) : Nullsv)
  108.  
  109. /* exported for GtkGC */
  110. SV * newSVGdkGCValues (GdkGCValues * v);
  111. void SvGdkGCValues (SV * data, GdkGCValues * v, GdkGCValuesMask * m);
  112.  
  113. /* exported for various other parts of pango */
  114. SV * newSVPangoRectangle (PangoRectangle * rectangle);
  115. PangoRectangle * SvPangoRectangle (SV * sv);
  116.  
  117. /*
  118.  * GdkAtom, an opaque pointer
  119.  */
  120. SV * newSVGdkAtom (GdkAtom atom);
  121. GdkAtom SvGdkAtom (SV * sv);
  122.  
  123. SV * newSVGtkTargetEntry (GtkTargetEntry * target_entry);
  124. /* do not store GtkTargetEntry objects returned from this function -- 
  125.  * they are only good for the block of code in which they are created */
  126. GtkTargetEntry * SvGtkTargetEntry (SV * sv);
  127. void gtk2perl_read_gtk_target_entry (SV * sv, GtkTargetEntry * entry);
  128.  
  129. #define GTK2PERL_STACK_ITEMS_TO_TARGET_ENTRY_ARRAY(first, targets, ntargets) \
  130.     {                                    \
  131.     guint i;                                \
  132.     if (items <= first) {                                           \
  133.         ntargets = 0;                                           \
  134.         targets = NULL;                                         \
  135.     } else {                                                        \
  136.         ntargets = items - first;                \
  137.         targets = gperl_alloc_temp (sizeof (GtkTargetEntry) * ntargets); \
  138.         for (i = 0 ; i < ntargets ; i++)            \
  139.             gtk2perl_read_gtk_target_entry (ST (i + first),    \
  140.                                             targets + i);    \
  141.         }                                                       \
  142.     }
  143.  
  144. /* 
  145.  * get a list of GTypes from the xsub argument stack
  146.  * used to collect column types for creating and initializing GtkTreeStores
  147.  * and GtkListStores.
  148.  */
  149. #define GTK2PERL_STACK_ITEMS_TO_GTYPE_ARRAY(arrayvar, first, last)    \
  150.     (arrayvar) = g_array_new (FALSE, FALSE, sizeof (GType));    \
  151.     g_array_set_size ((arrayvar), (last) - (first) + 1);        \
  152.     {                                \
  153.     int i;                                \
  154.     for (i = (first) ; i <= (last) ; i++) {                \
  155.         char * package = SvPV_nolen (ST (i));            \
  156.         /* look up GType by package name. */            \
  157.         GType t = gperl_type_from_package (package);        \
  158.         if (t == 0) {                        \
  159.             g_array_free ((arrayvar), TRUE);        \
  160.             croak ("package %s is not registered with GPerl", \
  161.                    package);                \
  162.             g_assert ("not reached");            \
  163.         }                            \
  164.         g_array_index ((arrayvar), GType, i-(first)) = t;    \
  165.     }                                \
  166.     }
  167.  
  168.  
  169. /*
  170.  * some custom opaque object handling for private gtk structures needed 
  171.  * for doing drag and drop.
  172.  */
  173.  
  174. /* gtk+ 2.10 introduces a boxed type for GtkTargetList and we use it for
  175.  * property marshalling, etc.  But we also need to keep backwards compatability
  176.  * with the old wrappers so we overwrite the macros. */
  177. #if GTK_CHECK_VERSION (2, 10, 0)
  178. # undef newSVGtkTargetList
  179. # undef newSVGtkTargetList_ornull
  180. # undef SvGtkTargetList
  181. # undef SvGtkTargetList_ornull
  182. #else
  183.   typedef GtkTargetList GtkTargetList_ornull;
  184. #endif
  185. SV * newSVGtkTargetList (GtkTargetList * list);
  186. #define newSVGtkTargetList_ornull(list)    ((list) ? newSVGtkTargetList (list) : &PL_sv_undef)
  187. GtkTargetList * SvGtkTargetList (SV * sv);
  188. #define SvGtkTargetList_ornull(sv)    (gperl_sv_is_defined (sv) ? SvGtkTargetList (sv) : NULL)
  189.  
  190. /*
  191.  * exported so Gnome2 can reuse it in wrappers.  other modules might want to
  192.  * do the same.  the callback for it needn't worry about param_types or
  193.  * return type, as this does all the marshaling by hand (the C function writes
  194.  * through the params, so we have to handle the stack specially).
  195.  */
  196. void gtk2perl_menu_position_func (GtkMenu       * menu,
  197.                                   gint          * x,
  198.                                   gint          * y,
  199.                                   gboolean      * push_in,
  200.                                   GPerlCallback * callback);
  201.  
  202.  
  203. #if ! GTK_CHECK_VERSION (2, 4, 0)
  204.  /* in versions prior to 2.4.0, GtkTreeSearchFlags was declared such that
  205.   * glib-mkenums interpreted and registered it as a GEnum type.  sometime
  206.   * before 2.3.0, this was corrected, and the type is registered as a GFlags.
  207.   * The maps file has GFlags (since that's correct), but we have to mangle
  208.   * things somewhat for the bindings to work properly with older libraries. */
  209. # undef SvGtkTextSearchFlags
  210. # undef newSVGtkTextSearchFlags
  211. # define SvGtkTextSearchFlags(sv)    (gperl_convert_enum (GTK_TYPE_TEXT_SEARCH_FLAGS, sv))
  212. # define newSVGtkTextSearchFlags(val)    (gperl_convert_back_enum (GTK_TYPE_TEXT_SEARCH_FLAGS, val))
  213. #endif
  214.  
  215. /* object handling for GdkGeometry */
  216. SV * newSVGdkGeometry (GdkGeometry *geometry);
  217. GdkGeometry * SvGdkGeometry (SV *object);
  218. GdkGeometry * SvGdkGeometryReal (SV *object, GdkWindowHints *hints);
  219.  
  220. /* special handling for GdkPixbufFormat, which was introduced in gtk+ 2.2.0 */
  221. #if GTK_CHECK_VERSION (2, 2, 0)
  222. SV * newSVGdkPixbufFormat (GdkPixbufFormat * format);
  223. GdkPixbufFormat * SvGdkPixbufFormat (SV * sv);
  224. #endif
  225.  
  226. #endif /* _GTK2PERL_H_ */
  227.