home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / perl5 / Glib / Object.pod < prev    next >
Encoding:
Text File  |  2006-06-19  |  10.7 KB  |  640 lines

  1. =head1 NAME
  2.  
  3. Glib::Object -  Bindings for GObject
  4.  
  5. =for position DESCRIPTION
  6.  
  7. =head1 DESCRIPTION
  8.  
  9. GObject is the base object class provided by the gobject library.  It provides
  10. object properties with a notification system, and emittable signals.
  11.  
  12. Glib::Object is the corresponding Perl object class.  Glib::Objects are
  13. represented by blessed hash references, with a magical connection to the
  14. underlying C object.
  15.  
  16. =cut
  17.  
  18.  
  19.  
  20. =head1 HIERARCHY
  21.  
  22.   Glib::Object
  23.  
  24. =for object Glib::Object Bindings for GObject
  25. =cut
  26.  
  27.  
  28.  
  29.  
  30. =head1 METHODS
  31.  
  32. =head2 object = $class->B<new> (...)
  33.  
  34. =over
  35.  
  36. =over
  37.  
  38. =item * ... (list) of key/value pairs, property values to set on creation
  39.  
  40. =back
  41.  
  42.  
  43.  
  44.  
  45. Instantiate a Glib::Object of type I<$class>.  Any key/value pairs in
  46. I<...> are used to set properties on the new object; see C<set>.
  47. This is designed to be inherited by Perl-derived subclasses (see
  48. L<Glib::Object::Subclass>), but you can actually use it to create
  49. any GObject-derived type.
  50.  
  51.  
  52. =back
  53.  
  54. =head2 scalar = Glib::Object-E<gt>B<new_from_pointer> ($pointer, $noinc=FALSE)
  55.  
  56. =over
  57.  
  58. =over
  59.  
  60. =item * $pointer (unsigned) a C pointer value as an integer.
  61.  
  62. =item * $noinc (boolean) if true, do not increase the GObject's reference count when creating the Perl wrapper.  this typically means that when the Perl wrapper will own the object.  in general you don't want to do that, so the default is false. 
  63.  
  64. =back
  65.  
  66.  
  67.  
  68.  
  69. Create a Perl Glib::Object reference for the C object pointed to by I<$pointer>.
  70. You should need this I<very> rarely; it's intended to support foreign objects.
  71.  
  72. NOTE: the cast from arbitrary integer to GObject may result in a core dump without
  73. warning, because the type-checking macro G_OBJECT() attempts to dereference the
  74. pointer to find a GTypeClass structure, and there is no portable way to validate
  75. the pointer.
  76.  
  77.  
  78. =back
  79.  
  80. =head2 unsigned = $object-E<gt>B<get_data> ($key)
  81.  
  82. =over
  83.  
  84. =over
  85.  
  86. =item * $key (string) 
  87.  
  88. =back
  89.  
  90.  
  91. Fetch the integer stored under the object data key I<$key>.  These values do not
  92. have types; type conversions must be done manually.  See C<set_data>.
  93.  
  94.  
  95. =back
  96.  
  97. =head2 $object-E<gt>B<set_data> ($key, $data)
  98.  
  99. =over
  100.  
  101. =over
  102.  
  103. =item * $key (string) 
  104.  
  105. =item * $data (scalar) 
  106.  
  107. =back
  108.  
  109.  
  110. GObject provides an arbitrary data mechanism that assigns unsigned integers
  111. to key names.  Functionality overlaps with the hash used as the Perl object
  112. instance, so we strongly recommend you use hash keys for your data storage.
  113. The GObject data values cannot store type information, so they are not safe
  114. to use for anything but integer values, and you really should use this method
  115. only if you know what you are doing.
  116.  
  117.  
  118. =back
  119.  
  120. =head2 $object-E<gt>B<freeze_notify> 
  121.  
  122. =over
  123.  
  124.  
  125. Stops emission of "notify" signals on I<$object>. The signals are queued
  126. until C<thaw_notify> is called on I<$object>.
  127.  
  128.  
  129. =back
  130.  
  131. =head2 list = $object-E<gt>B<get> (...)
  132.  
  133. =over
  134.  
  135. =over
  136.  
  137. =item * ... (list) list of property names
  138.  
  139. =back
  140.  
  141.  
  142. Fetch and return the values for the object properties named in I<...>.
  143.  
  144.  
  145. =back
  146.  
  147. =head2 $object->B<set> (key => $value, ...)
  148.  
  149. =over
  150.  
  151. =over
  152.  
  153. =item * ... (list) 
  154.  
  155. =back
  156.  
  157.  
  158. Set object properties.
  159.  
  160.  
  161. =back
  162.  
  163. =head2 list = $object_or_class_name-E<gt>B<list_properties> 
  164.  
  165. =over
  166.  
  167.  
  168. List all the object properties for I<$object_or_class_name>; returns them as
  169. a list of hashes, containing these keys:
  170.  
  171. =over
  172.  
  173. =item name
  174.  
  175. =item type
  176.  
  177. =item owner_type
  178.  
  179. =item descr
  180.  
  181. =back
  182.  
  183.  
  184. =back
  185.  
  186. =head2 $object-E<gt>B<notify> ($property_name)
  187.  
  188. =over
  189.  
  190. =over
  191.  
  192. =item * $property_name (string) 
  193.  
  194. =back
  195.  
  196.  
  197. Emits a "notify" signal for the property I<$property> on I<$object>.
  198.  
  199.  
  200. =back
  201.  
  202. =head2 gpointer = $object-E<gt>B<get_pointer> 
  203.  
  204. =over
  205.  
  206.  
  207. Complement of C<new_from_pointer>.
  208.  
  209.  
  210. =back
  211.  
  212. =head2 list = $object-E<gt>B<get_property> (...)
  213.  
  214. =over
  215.  
  216. =over
  217.  
  218. =back
  219.  
  220.  
  221. Alias for C<get>.
  222.  
  223.  
  224. =back
  225.  
  226. =head2 $object->B<set_property> (key => $value, ...)
  227.  
  228. =over
  229.  
  230. =over
  231.  
  232. =back
  233.  
  234.  
  235. Alias for C<set>.
  236.  
  237.  
  238. =back
  239.  
  240. =head2 unsigned = $object_or_class_name-E<gt>B<signal_add_emission_hook> ($detailed_signal, $hook_func, $hook_data=undef)
  241.  
  242. =over
  243.  
  244. =over
  245.  
  246. =item * $detailed_signal (string) of the form "signal-name::detail"
  247.  
  248. =item * $hook_func (subroutine) 
  249.  
  250. =item * $hook_data (scalar) 
  251.  
  252. =back
  253.  
  254. Add an emission hook for a signal.  The hook will be called for any emission
  255. of that signal, independent of the instance.  This is possible only for
  256. signals which don't have the C<G_SIGNAL_NO_HOOKS> flag set.
  257.  
  258. The I<$hook_func> should be reference to a subroutine that looks something
  259. like this:
  260.  
  261.   sub emission_hook {
  262.       my ($invocation_hint, $parameters, $hook_data) = @_;
  263.       # $parameters is a reference to the @_ to be passed to
  264.       # signal handlers, including the instance as $parameters->[0].
  265.       return $stay_connected;  # boolean
  266.   }
  267.  
  268. This function returns an id that can be used with C<remove_emission_hook>.
  269.  
  270. Since 1.100.
  271.  
  272. =back
  273.  
  274. =head2 list = $instance-E<gt>B<signal_chain_from_overridden> (...)
  275.  
  276. =over
  277.  
  278. =over
  279.  
  280. =item * ... (list) 
  281.  
  282. =back
  283.  
  284.  
  285. Chain up to an overridden class closure; it is only valid to call this from
  286. a class closure override.
  287.  
  288. Translation: because of various details in how GObjects are implemented,
  289. the way to override a virtual method on a GObject is to provide a new "class
  290. closure", or default handler for a signal.  This happens when a class is
  291. registered with the type system (see Glib::Type::register and
  292. L<Glib::Object::Subclass>).  When called from inside such an override, this
  293. method runs the overridden class closure.  This is equivalent to calling
  294. $self->SUPER::$method (@_) in normal Perl objects.
  295.  
  296.  
  297. =back
  298.  
  299. =head2 unsigned = $instance-E<gt>B<signal_connect> ($detailed_signal, $callback, $data=undef)
  300.  
  301. =over
  302.  
  303. =over
  304.  
  305. =item * $detailed_signal (string) 
  306.  
  307. =item * $callback (subroutine) 
  308.  
  309. =item * $data (scalar) arbitrary data to be passed to each invocation of I<callback>
  310.  
  311. =back
  312.  
  313.  
  314.  
  315.  
  316. Register I<callback> to be called on each emission of I<$detailed_signal>.
  317. Returns an identifier that may be used to remove this handler with
  318. C<< $object->signal_handler_disconnect >>.
  319.  
  320.  
  321. =back
  322.  
  323. =head2 unsigned = $instance-E<gt>B<signal_connect_after> ($detailed_signal, $callback, $data=undef)
  324.  
  325. =over
  326.  
  327. =over
  328.  
  329. =item * $detailed_signal (string) 
  330.  
  331. =item * $callback (scalar) 
  332.  
  333. =item * $data (scalar) 
  334.  
  335. =back
  336.  
  337.  
  338. Like C<signal_connect>, except that I<$callback> will be run after the default
  339. handler.
  340.  
  341.  
  342. =back
  343.  
  344. =head2 unsigned = $instance-E<gt>B<signal_connect_swapped> ($detailed_signal, $callback, $data=undef)
  345.  
  346. =over
  347.  
  348. =over
  349.  
  350. =item * $detailed_signal (string) 
  351.  
  352. =item * $callback (scalar) 
  353.  
  354. =item * $data (scalar) 
  355.  
  356. =back
  357.  
  358.  
  359. Like C<signal_connect>, except that I<$data> and I<$object> will be swapped
  360. on invocation of I<$callback>.
  361.  
  362.  
  363. =back
  364.  
  365. =head2 retval = $object->B<signal_emit> ($name, ...)
  366.  
  367. =over
  368.  
  369. =over
  370.  
  371. =item * $name (string) the name of the signal
  372.  
  373. =item * ... (list) any arguments to pass to handlers.
  374.  
  375. =back
  376.  
  377.  
  378.  
  379.  
  380.  
  381. Emit the signal I<name> on I<$object>.  The number and types of additional
  382. arguments in I<...> are determined by the signal; similarly, the presence
  383. and type of return value depends on the signal being emitted.
  384.  
  385.  
  386. =back
  387.  
  388. =head2 $object-E<gt>B<signal_handler_block> ($handler_id)
  389.  
  390. =over
  391.  
  392. =over
  393.  
  394. =item * $handler_id (unsigned) 
  395.  
  396. =back
  397.  
  398. =back
  399.  
  400. =head2 $object-E<gt>B<signal_handler_disconnect> ($handler_id)
  401.  
  402. =over
  403.  
  404. =over
  405.  
  406. =item * $handler_id (unsigned) 
  407.  
  408. =back
  409.  
  410. =back
  411.  
  412. =head2 boolean = $object-E<gt>B<signal_handler_is_connected> ($handler_id)
  413.  
  414. =over
  415.  
  416. =over
  417.  
  418. =item * $handler_id (unsigned) 
  419.  
  420. =back
  421.  
  422. =back
  423.  
  424. =head2 $object-E<gt>B<signal_handler_unblock> ($handler_id)
  425.  
  426. =over
  427.  
  428. =over
  429.  
  430. =item * $handler_id (unsigned) 
  431.  
  432. =back
  433.  
  434. =back
  435.  
  436. =head2 integer = $instance-E<gt>B<signal_handlers_block_by_func> ($func, $data=undef)
  437.  
  438. =over
  439.  
  440. =over
  441.  
  442. =item * $func (subroutine) function to block
  443.  
  444. =item * $data (scalar) data to match, ignored if undef
  445.  
  446. =back
  447.  
  448.  
  449.  
  450. =back
  451.  
  452. =head2 integer = $instance-E<gt>B<signal_handlers_disconnect_by_func> ($func, $data=undef)
  453.  
  454. =over
  455.  
  456. =over
  457.  
  458. =item * $func (subroutine) function to block
  459.  
  460. =item * $data (scalar) data to match, ignored if undef
  461.  
  462. =back
  463.  
  464.  
  465.  
  466. =back
  467.  
  468. =head2 integer = $instance-E<gt>B<signal_handlers_unblock_by_func> ($func, $data=undef)
  469.  
  470. =over
  471.  
  472. =over
  473.  
  474. =item * $func (subroutine) function to block
  475.  
  476. =item * $data (scalar) data to match, ignored if undef
  477.  
  478. =back
  479.  
  480.  
  481.  
  482. =back
  483.  
  484. =head2 scalar = $object_or_class_name-E<gt>B<signal_query> ($name)
  485.  
  486. =over
  487.  
  488. =over
  489.  
  490. =item * $name (string) 
  491.  
  492. =back
  493.  
  494. Look up information about the signal I<$name> on the instance type
  495. I<$object_or_class_name>, which may be either a Glib::Object or a package
  496. name.
  497.  
  498. See also C<Glib::Type::list_signals>, which returns the same kind of
  499. hash refs as this does.
  500.  
  501. Since 1.080.
  502.  
  503. =back
  504.  
  505. =head2 $object_or_class_name-E<gt>B<signal_remove_emission_hook> ($signal_name, $hook_id)
  506.  
  507. =over
  508.  
  509. =over
  510.  
  511. =item * $signal_name (string) 
  512.  
  513. =item * $hook_id (unsigned) 
  514.  
  515. =back
  516.  
  517. Remove a hook that was installed by C<add_emission_hook>.
  518.  
  519. Since 1.100.
  520.  
  521. =back
  522.  
  523. =head2 $instance-E<gt>B<signal_stop_emission_by_name> ($detailed_signal)
  524.  
  525. =over
  526.  
  527. =over
  528.  
  529. =item * $detailed_signal (string) 
  530.  
  531. =back
  532.  
  533. =back
  534.  
  535. =head2 $object-E<gt>B<thaw_notify> 
  536.  
  537. =over
  538.  
  539.  
  540. Reverts the effect of a previous call to C<freeze_notify>. This causes all
  541. queued "notify" signals on I<$object> to be emitted.
  542.  
  543.  
  544. =back
  545.  
  546. =head2 boolean = Glib::Object-E<gt>B<set_threadsafe> ($threadsafe)
  547.  
  548. =over
  549.  
  550. =over
  551.  
  552. =item * $threadsafe (boolean) 
  553.  
  554. =back
  555.  
  556. Enables/disables threadsafe gobject tracking. Returns whether or not tracking
  557. will be successful and thus whether using perl ithreads will be possible. 
  558.  
  559. =back
  560.  
  561. =head2 $object-E<gt>B<tie_properties> ($all=FALSE)
  562.  
  563. =over
  564.  
  565. =over
  566.  
  567. =item * $all (boolean) if FALSE (or omitted) tie only properties for this object's class, if TRUE tie the properties of this and all parent classes.
  568.  
  569. =back
  570.  
  571.  
  572. A special method avaiable to Glib::Object derivatives, it uses perl's tie
  573. facilities to associate hash keys with the properties of the object. For
  574. example:
  575.  
  576.   $button->tie_properties;
  577.   # equivilent to $button->set (label => 'Hello World');
  578.   $button->{label} = 'Hello World';
  579.   print "the label is: ".$button->{label}."\n";
  580.  
  581. Attempts to write to read-only properties will croak, reading a write-only
  582. property will return '[write-only]'.
  583.  
  584. Care must be taken when using tie_properties with objects of types created with
  585. Glib::Object::Subclass as there may be clashes with existing hash keys that
  586. could cause infinite loops. The solution is to use custom property get/set
  587. functions to alter the storage locations of the properties.
  588.  
  589. =back
  590.  
  591.  
  592. =head1 SIGNALS
  593.  
  594. =over
  595.  
  596. =item B<notify> (Glib::Object, Glib::ParamSpec)
  597.  
  598. =back
  599.  
  600.  
  601. =head1 ENUMS AND FLAGS
  602.  
  603. =head2 flags Glib::SignalFlags
  604.  
  605.  
  606.  
  607. =over
  608.  
  609. =item * 'run-first' / 'G_SIGNAL_RUN_FIRST'
  610.  
  611. =item * 'run-last' / 'G_SIGNAL_RUN_LAST'
  612.  
  613. =item * 'run-cleanup' / 'G_SIGNAL_RUN_CLEANUP'
  614.  
  615. =item * 'no-recurse' / 'G_SIGNAL_NO_RECURSE'
  616.  
  617. =item * 'detailed' / 'G_SIGNAL_DETAILED'
  618.  
  619. =item * 'action' / 'G_SIGNAL_ACTION'
  620.  
  621. =item * 'no-hooks' / 'G_SIGNAL_NO_HOOKS'
  622.  
  623. =back
  624.  
  625.  
  626.  
  627. =head1 SEE ALSO
  628.  
  629. L<Glib>
  630.  
  631. =head1 COPYRIGHT
  632.  
  633. Copyright (C) 2003-2005 by the gtk2-perl team.
  634.  
  635. This software is licensed under the LGPL.  See L<Glib> for a full notice.
  636.  
  637.  
  638. =cut
  639.  
  640.