home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / perl5 / Gtk2.pm < prev   
Encoding:
Perl POD Document  |  2007-03-05  |  7.3 KB  |  239 lines

  1. #
  2. # Copyright (C) 2003-2006 by the gtk2-perl team (see the file AUTHORS for
  3. # the full list)
  4. #
  5. # This library is free software; you can redistribute it and/or modify it under
  6. # the terms of the GNU Library General Public License as published by the Free
  7. # Software Foundation; either version 2.1 of the License, or (at your option)
  8. # any later version.
  9. #
  10. # This library is distributed in the hope that it will be useful, but WITHOUT
  11. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. # FOR A PARTICULAR PURPOSE.  See the GNU Library General Public License for
  13. # more details.
  14. #
  15. # You should have received a copy of the GNU Library General Public License
  16. # along with this library; if not, write to the Free Software Foundation, Inc.,
  17. # 59 Temple Place - Suite 330, Boston, MA  02111-1307  USA.
  18. #
  19. # $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/Gtk2.pm,v 1.100 2006/09/04 18:37:04 kaffeetisch Exp $
  20. #
  21.  
  22. package Gtk2;
  23.  
  24. # Gtk uses unicode strings; thus we require perl>=5.8.x,
  25. # which is unicode internally.
  26. use 5.008;
  27. use strict;
  28. use warnings;
  29.  
  30. use Glib;
  31.  
  32. # if the gtk+ we've been compiled against is at least as new as 2.8.0, we need
  33. # to import the Cairo module for the cairo glue in gtk+ and pango.
  34. eval "use Cairo;";
  35.  
  36. require DynaLoader;
  37.  
  38. our $VERSION = '1.140';
  39.  
  40. our @ISA = qw(DynaLoader);
  41.  
  42. sub import {
  43.     my $class = shift;
  44.  
  45.     # threads' init needs to be called before the main init and we don't
  46.     # want to force the order those options are passed to us so we need to
  47.     # cache the choices in booleans and (optionally) do them in the corect
  48.     # order afterwards
  49.     my $init = 0;
  50.     my $threads_init = 0;
  51.  
  52.     foreach (@_) {
  53.         if (/^-?init$/) {
  54.             $init = 1;
  55.         } elsif (/-?threads-init$/) {
  56.             $threads_init = 1;
  57.         } else {
  58.             $class->VERSION ($_);
  59.         }
  60.     }
  61.  
  62.     Gtk2::Gdk::Threads->init if ($threads_init);
  63.     Gtk2->init if ($init);
  64. }
  65.  
  66. # this is critical -- tell dynaloader to load the module so that its
  67. # symbols are available to all other modules.  without this, nobody
  68. # else can use important functions like gtk2perl_new_object!
  69. #
  70. # hrm.  win32 doesn't really use this, because we have to link the whole
  71. # thing at compile time to ensure all the symbols are defined.
  72. #
  73. # on darwin, at least with the particular 5.8.0 binary i'm using, perl
  74. # complains "Can't make loaded symbols global on this platform" when this
  75. # is set to 0x01, but goes on to work fine.  returning 0 here avoids the
  76. # warning and doesn't appear to break anything.
  77. sub dl_load_flags { $^O eq 'darwin' ? 0x00 : 0x01 }
  78.  
  79. # now load the XS code.
  80. Gtk2->bootstrap ($VERSION);
  81.  
  82. # Preloaded methods go here.
  83.  
  84. package Gtk2::Gdk;
  85.  
  86. sub CHARS { 8 };
  87. sub SHORTS { 16 };
  88. sub LONGS { 32 };
  89.  
  90. sub USHORTS { 16 };
  91. sub ULONGS { 32 };
  92.  
  93. package Gtk2::Gdk::Atom;
  94.  
  95. use overload
  96.     '==' => \&Gtk2::Gdk::Atom::eq,
  97.     fallback => 1;
  98.  
  99. package Gtk2::TreeSortable::IterCompareFunc;
  100.  
  101. use overload
  102.     '&{}' => sub { \&Gtk2::TreeSortable::IterCompareFunc::invoke },
  103.     fallback => 1;
  104.  
  105. package Gtk2;
  106.  
  107.  
  108. 1;
  109. __END__
  110. # documentation is a good thing.
  111.  
  112. =head1 NAME
  113.  
  114. Gtk2 - Perl interface to the 2.x series of the Gimp Toolkit library
  115.  
  116. =head1 SYNOPSIS
  117.  
  118.   use Gtk2 -init;
  119.   # Gtk2->init; works if you didn't use -init on use
  120.   my $window = Gtk2::Window->new ('toplevel');
  121.   my $button = Gtk2::Button->new ('Quit');
  122.   $button->signal_connect (clicked => sub { Gtk2->main_quit });
  123.   $window->add ($button);
  124.   $window->show_all;
  125.   Gtk2->main;
  126.  
  127. =head1 ABSTRACT
  128.  
  129. Perl bindings to the 2.x series of the Gtk+ widget set.  This module
  130. allows you to write graphical user interfaces in a Perlish and
  131. object-oriented way, freeing you from the casting and memory management
  132. in C, yet remaining very close in spirit to original API.
  133.  
  134. =head1 DESCRIPTION
  135.  
  136. The Gtk2 module allows a Perl developer to use the Gtk+ graphical user
  137. interface library.  Find out more about Gtk+ at http://www.gtk.org.
  138.  
  139. The GTK+ Reference Manual is also a handy companion when writing Gtk
  140. programs in any language.  http://developer.gnome.org/doc/API/2.0/gtk/
  141. The Perl bindings follow the C API very closely, and the C reference
  142. documentation should be considered the canonical source.
  143.  
  144. To discuss gtk2-perl, ask questions and flame/praise the authors,
  145. join gtk-perl-list@gnome.org at lists.gnome.org.
  146.  
  147. Also have a look at the gtk2-perl website and sourceforge project page,
  148. http://gtk2-perl.sourceforge.net
  149.  
  150. =head1 INITIALIZATION
  151.  
  152.   use Gtk2 qw/-init/;
  153.   use Gtk2 qw/-init -threads-init/;
  154.  
  155. =over
  156.  
  157. =item -init
  158.  
  159. Equivalent to Gtk2->init, called to initialize GLIB and GTK+. Just about every
  160. Gtk2-Perl script should do "use Gtk2 -init"; This initialization should take
  161. place before using any other Gtk2 functions in your GUI applications. It will
  162. initialize everything needed to operate the toolkit and parses some standard
  163. command line options. @ARGV is adjusted accordingly so your own code will never
  164. see those standard arguments.
  165.  
  166. =item -threads-init
  167.  
  168. Equivalent to Gtk2::Gdk::Threads->init, called to initialze/enable gdk's thread
  169. safety mechanisms so that gdk can be accessed from multiple threads when used
  170. in conjunction with Gtk2::Gdk::Threads->enter and Gtk2::Gdk::Threads->leave. If
  171. invoked as Gtk2::Gdk::Threads->init it should be done before Gtk2->init is
  172. called, if done by "use Gtk2 -init -threads-init" order does not matter.
  173.  
  174. =back
  175.  
  176. =head1 SEE ALSO
  177.  
  178. L<perl>(1), L<Glib>(3pm).
  179.  
  180. L<Gtk2::Gdk::Keysyms>(3pm) contains a hash of key codes, culled from
  181. gdk/gdkkeysyms.h
  182.  
  183. L<Gtk2::api>(3pm) describes how to map the C API into Perl, and some of the
  184. important differences in the Perl bindings.
  185.  
  186. L<Gtk2::Helper>(3pm) contains stuff that makes writing Gtk2 programs
  187. a little easier.
  188.  
  189. L<Gtk2::SimpleList>(3pm) makes the GtkListStore and GtkTreeModel a I<lot>
  190. easier to use.
  191.  
  192. L<Gtk2::Pango>(3pm) exports various little-used but important constants you
  193. may need to work with pango directly.
  194.  
  195. L<Gtk2::index>(3pm) lists the autogenerated api documentation pod files
  196. for Gtk2.
  197.  
  198. Gtk2 also provides code to make it relatively painless to create Perl
  199. wrappers for other GLib/Gtk-based libraries.  See L<Gtk2::CodeGen>,
  200. L<ExtUtils::PkgConfig>, and L<ExtUtils::Depends>.  If you're writing bindings,
  201. you'll probably also be interested in L<Gtk2::devel>, which is a supplement
  202. to L<Glib::devel> and L<Glib::xsapi>.  The Binding Howto, at
  203. http://gtk2-perl.sourceforge.net/doc/binding_howto.pod.html, ties it all
  204. together.
  205.  
  206. =head1 AUTHORS
  207.  
  208. The gtk2-perl team:
  209.  
  210.  muppet <scott at asofyet dot org>
  211.  Ross McFarland <rwmcfa1 at neces dot com>
  212.  Torsten Schoenfeld <kaffeetisch at web dot de>
  213.  Marc Lehmann <pcg at goof dot com>
  214.  Goeran Thyni <gthyni at kirra dot net>
  215.  Joern Reder <joern at zyn dot de>
  216.  Chas Owens <alas at wilma dot widomaker dot com>
  217.  Guillaume Cottenceau <gc at mandrakesoft dot com>
  218.  
  219. =head1 COPYRIGHT AND LICENSE
  220.  
  221. Copyright 2003-2006 by the gtk2-perl team.
  222.  
  223. This library is free software; you can redistribute it and/or
  224. modify it under the terms of the GNU Library General Public
  225. License as published by the Free Software Foundation; either
  226. version 2 of the License, or (at your option) any later version.
  227.  
  228. This library is distributed in the hope that it will be useful,
  229. but WITHOUT ANY WARRANTY; without even the implied warranty of
  230. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  231. Library General Public License for more details.
  232.  
  233. You should have received a copy of the GNU Library General Public
  234. License along with this library; if not, write to the
  235. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  236. Boston, MA  02111-1307  USA.
  237.  
  238. =cut
  239.