home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / perl5 / Glib / MainLoop.pod < prev    next >
Encoding:
Text File  |  2008-11-04  |  5.2 KB  |  301 lines

  1. =head1 NAME
  2.  
  3. Glib::MainLoop -  An event source manager
  4.  
  5. =for position DESCRIPTION
  6.  
  7. =head1 DESCRIPTION
  8.  
  9. Event-driven programs need some sort of loop which watches for events and
  10. launches the appropriate actions.  Glib::MainLoop provides this functionality.
  11.  
  12. Mainloops have context, provided by the MainContext object.  For the most part
  13. you can use the default context (see C<default>), but if you want to create a
  14. subcontext for a nested loop which doesn't have the same event sources, etc,
  15. you can.
  16.  
  17. Event sources, attached to main contexts, watch for events to happen, and
  18. launch appropriate actions.  Glib provides a few ready-made event sources,
  19. the Glib::Timeout, Glib::Idle, and io watch (C<< Glib::IO->add_watch >>).
  20.  
  21. Under the hood, Gtk+ adds event sources for GdkEvents to dispatch events to
  22. your widgets.  In fact, Gtk2 provides an abstraction of Glib::MainLoop (See
  23. C<< Gtk2->main >> and friends), so you may rarely have cause to use
  24. Glib::MainLoop directly.
  25.  
  26. Note: As of version 1.080, the Glib module uses a custom event source to
  27. ensure that perl's safe signal handling and the glib polling event loop
  28. play nicely together.  It is no longer necessary to install a timeout to
  29. ensure that async signals get handled in a timely manner.
  30.  
  31. =cut
  32.  
  33.  
  34.  
  35. =for object Glib::MainLoop
  36. =cut
  37.  
  38. =for object Glib::MainLoop An event source manager
  39. =cut
  40.  
  41. =for object Glib::MainLoop
  42. =cut
  43.  
  44. =for object Glib::MainLoop
  45. =cut
  46.  
  47. =for object Glib::MainLoop
  48. =cut
  49.  
  50. =for object Glib::MainLoop
  51. =cut
  52.  
  53.  
  54.  
  55.  
  56. =head1 METHODS
  57.  
  58. =head2 maincontext thingamabob = Glib::MainContext-E<gt>B<new> 
  59.  
  60. =over
  61.  
  62. =back
  63.  
  64. =head2 mainloop = Glib::MainLoop-E<gt>B<new> ($context=undef, $is_running=FALSE)
  65.  
  66. =over
  67.  
  68. =over
  69.  
  70. =item * $context (Glib::MainContext thingamabob) 
  71.  
  72. =item * $is_running (boolean) 
  73.  
  74. =back
  75.  
  76. =back
  77.  
  78. =head2 integer = Glib::Timeout-E<gt>B<add> ($interval, $callback, $data=undef, $priority=G_PRIORITY_DEFAULT)
  79.  
  80. =over
  81.  
  82. =over
  83.  
  84. =item * $interval (integer) number of milliseconds
  85.  
  86. =item * $callback (subroutine) 
  87.  
  88. =item * $data (scalar) 
  89.  
  90. =item * $priority (integer) 
  91.  
  92. =back
  93.  
  94.  
  95. Run I<$callback> every I<$interval> milliseconds until I<$callback> returns
  96. false.  Returns a source id which may be used with C<< Glib::Source->remove >>.
  97. Note that a mainloop must be active for the timeout to execute.
  98.  
  99.  
  100. =back
  101.  
  102. =head2 integer = Glib::Idle-E<gt>B<add> ($callback, $data=undef, $priority=G_PRIORITY_DEFAULT_IDLE)
  103.  
  104. =over
  105.  
  106. =over
  107.  
  108. =item * $callback (subroutine) 
  109.  
  110. =item * $data (scalar) 
  111.  
  112. =item * $priority (integer) 
  113.  
  114. =back
  115.  
  116.  
  117. Run I<$callback> when the mainloop is idle.  If I<$callback> returns false,
  118. it will uninstall itself, otherwise, it will run again at the next idle
  119. iteration.  Returns a source id which may be used with
  120. C<< Glib::Source->remove >>.
  121.  
  122.  
  123. =back
  124.  
  125. =head2 integer = Glib::Timeout-E<gt>B<add_seconds> ($interval, $callback, $data=undef, $priority=G_PRIORITY_DEFAULT)
  126.  
  127. =over
  128.  
  129. =over
  130.  
  131. =item * $interval (integer) 
  132.  
  133. =item * $callback (scalar) 
  134.  
  135. =item * $data (scalar) 
  136.  
  137. =item * $priority (integer) 
  138.  
  139. =back
  140.  
  141. Since: glib 2.14
  142.  
  143. =back
  144.  
  145. =head2 integer = Glib::IO-E<gt>B<add_watch> ($fd, $condition, $callback, $data=undef, $priority=G_PRIORITY_DEFAULT)
  146.  
  147. =over
  148.  
  149. =over
  150.  
  151. =item * $fd (integer) file descriptor, e.g. fileno($filehandle)
  152.  
  153. =item * $condition (Glib::IOCondition) 
  154.  
  155. =item * $callback (subroutine) 
  156.  
  157. =item * $data (scalar) 
  158.  
  159. =item * $priority (integer) 
  160.  
  161. =back
  162.  
  163.  
  164. Run I<$callback> when there is an event on I<$fd> that matches I<$condition>.
  165. The watch uninstalls itself if I<$callback> returns false.
  166. Returns a source id that may be used with C<< Glib::Source->remove >>.
  167.  
  168. Glib's IO channels serve the same basic purpose as Perl's file handles, so
  169. for the most part you don't see GIOChannels in Perl.  The IO watch integrates
  170. IO operations with the main loop, which Perl file handles don't do.  For
  171. various reasons, this function requires raw file descriptors, not full
  172. file handles.  See C<fileno> in L<perlfunc>.
  173.  
  174.  
  175. =back
  176.  
  177. =head2 maincontext thingamabob = $loop-E<gt>B<get_context> 
  178.  
  179. =over
  180.  
  181. =back
  182.  
  183. =head2 maincontext thingamabob = Glib::MainContext-E<gt>B<default> 
  184.  
  185. =over
  186.  
  187. =back
  188.  
  189. =head2 boolean = $context-E<gt>B<is_owner> 
  190.  
  191. =over
  192.  
  193. Since: glib 2.12
  194.  
  195. =back
  196.  
  197. =head2 boolean = $loop-E<gt>B<is_running> 
  198.  
  199. =over
  200.  
  201. =back
  202.  
  203. =head2 boolean = $context-E<gt>B<iteration> ($may_block)
  204.  
  205. =over
  206.  
  207. =over
  208.  
  209. =item * $may_block (boolean) 
  210.  
  211. =back
  212.  
  213. =back
  214.  
  215. =head2 integer = Glib::main_depth 
  216.  
  217. =over
  218.  
  219. Find the current main loop recursion level.  This is handy in fringe
  220. situations, but those are very rare; see the C API reference for a more
  221. in-depth discussion.
  222.  
  223. Since: glib 2.4
  224.  
  225. =back
  226.  
  227. =head2 boolean = $context-E<gt>B<pending> 
  228.  
  229. =over
  230.  
  231. =back
  232.  
  233. =head2 $loop-E<gt>B<quit> 
  234.  
  235. =over
  236.  
  237. =back
  238.  
  239. =head2 boolean = Glib::Source-E<gt>B<remove> ($tag)
  240.  
  241. =over
  242.  
  243. =over
  244.  
  245. =item * $tag (integer) 
  246.  
  247. =back
  248.  
  249.  
  250. Remove an event source.  I<$tag> is the number returned by things like
  251. C<< Glib::Timeout->add >>, C<< Glib::Idle->add >>, and
  252. C<< Glib::IO->add_watch >>.
  253.  
  254.  
  255. =back
  256.  
  257. =head2 $loop-E<gt>B<run> 
  258.  
  259. =over
  260.  
  261. =back
  262.  
  263.  
  264. =head1 ENUMS AND FLAGS
  265.  
  266. =head2 flags Glib::IOCondition
  267.  
  268.  
  269.  
  270. =over
  271.  
  272. =item * 'in' / 'G_IO_IN'
  273.  
  274. =item * 'out' / 'G_IO_OUT'
  275.  
  276. =item * 'pri' / 'G_IO_PRI'
  277.  
  278. =item * 'err' / 'G_IO_ERR'
  279.  
  280. =item * 'hup' / 'G_IO_HUP'
  281.  
  282. =item * 'nval' / 'G_IO_NVAL'
  283.  
  284. =back
  285.  
  286.  
  287.  
  288. =head1 SEE ALSO
  289.  
  290. L<Glib>
  291.  
  292. =head1 COPYRIGHT
  293.  
  294. Copyright (C) 2003-2008 by the gtk2-perl team.
  295.  
  296. This software is licensed under the LGPL.  See L<Glib> for a full notice.
  297.  
  298.  
  299. =cut
  300.  
  301.