home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / perl5 / Gtk2.pm < prev   
Encoding:
Perl POD Document  |  2005-11-28  |  7.1 KB  |  235 lines

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