man-pages/man3/Glib::Object.3pm.html
2021-03-31 01:06:50 +01:00

717 lines
19 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Glib::Object</TITLE>
</HEAD><BODY>
<H1>Glib::Object</H1>
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2020-02-18<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
Glib::Object - Bindings for GObject
<A NAME="lbAC">&nbsp;</A>
<H2>DESCRIPTION</H2>
GObject is the base object class provided by the gobject library. It provides
object properties with a notification system, and emittable signals.
<P>
Glib::Object is the corresponding Perl object class. Glib::Objects are
represented by blessed hash references, with a magical connection to the
underlying C object.
<A NAME="lbAD">&nbsp;</A>
<H3>get and set</H3>
Some subclasses of <TT>&quot;Glib::Object&quot;</TT> override <TT>&quot;get&quot;</TT> and <TT>&quot;set&quot;</TT> with methods
more useful to the subclass, for example <TT>&quot;Gtk2::TreeModel&quot;</TT> getting and
setting row contents.
<P>
This is usually done when the subclass has no object properties. Any object
properties it or a further subclass does have can always be accessed with
<TT>&quot;get_property&quot;</TT> and <TT>&quot;set_property&quot;</TT> (together with <TT>&quot;find_property&quot;</TT> and
<TT>&quot;list_properties&quot;</TT> to enquire about them).
<P>
Generic code for any object subclass can use the names <TT>&quot;get_property&quot;</TT> and
<TT>&quot;set_property&quot;</TT> to be sure of getting the object properties as such.
<A NAME="lbAE">&nbsp;</A>
<H2>HIERARCHY</H2>
<PRE>
Glib::Object
</PRE>
<A NAME="lbAF">&nbsp;</A>
<H2>METHODS</H2>
<A NAME="lbAG">&nbsp;</A>
<H3>object = $class-&gt;<B>new</B> (...)</H3>
<DL COMPACT>
<DT id="1">&bull;<DD>
... (list) key/value pairs, property values to set on creation
</DL>
<P>
Instantiate a Glib::Object of type <I></I>$class<I></I>. Any key/value pairs in
<I>...</I> are used to set properties on the new object; see <TT>&quot;set&quot;</TT>.
This is designed to be inherited by Perl-derived subclasses (see
Glib::Object::Subclass), but you can actually use it to create
any GObject-derived type.
<A NAME="lbAH">&nbsp;</A>
<H3>scalar = Glib::Object-&gt;<B>new_from_pointer</B> ($pointer, $noinc=FALSE)</H3>
<DL COMPACT>
<DT id="2">&bull;<DD>
<TT>$pointer</TT> (unsigned) a C pointer value as an integer.
<DT id="3">&bull;<DD>
<TT>$noinc</TT> (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.
</DL>
<P>
Create a Perl Glib::Object reference for the C object pointed to by <I></I>$pointer<I></I>.
You should need this <I>very</I> rarely; it's intended to support foreign objects.
<P>
<FONT SIZE="-1">NOTE:</FONT> the cast from arbitrary integer to GObject may result in a core dump without
warning, because the type-checking macro <B>G_OBJECT()</B> attempts to dereference the
pointer to find a GTypeClass structure, and there is no portable way to validate
the pointer.
<A NAME="lbAI">&nbsp;</A>
<H3>unsigned = $object-&gt;<B>get_data</B> ($key)</H3>
<DL COMPACT>
<DT id="4">&bull;<DD>
<TT>$key</TT> (string)
</DL>
<P>
Fetch the integer stored under the object data key <I></I>$key<I></I>. These values do not
have types; type conversions must be done manually. See <TT>&quot;set_data&quot;</TT>.
<A NAME="lbAJ">&nbsp;</A>
<H3>$object-&gt;<B>set_data</B> ($key, $data)</H3>
<DL COMPACT>
<DT id="5">&bull;<DD>
<TT>$key</TT> (string)
<DT id="6">&bull;<DD>
<TT>$data</TT> (scalar)
</DL>
<P>
GObject provides an arbitrary data mechanism that assigns unsigned integers
to key names. Functionality overlaps with the hash used as the Perl object
instance, so we strongly recommend you use hash keys for your data storage.
The GObject data values cannot store type information, so they are not safe
to use for anything but integer values, and you really should use this method
only if you know what you are doing.
<A NAME="lbAK">&nbsp;</A>
<H3>pspec or undef = $object_or_class_name-&gt;<B>find_property</B> ($name)</H3>
<DL COMPACT>
<DT id="7">&bull;<DD>
<TT>$name</TT> (string)
</DL>
<P>
Find the definition of object property <I></I>$name<I></I> for <I></I>$object_or_class_name<I></I>.
Return <TT>&quot;undef&quot;</TT> if no such property. For
the returned data see Glib::Object::list_properties.
<A NAME="lbAL">&nbsp;</A>
<H3>$object-&gt;<B>freeze_notify</B></H3>
Stops emission of ``notify'' signals on <I></I>$object<I></I>. The signals are queued
until <TT>&quot;thaw_notify&quot;</TT> is called on <I></I>$object<I></I>.
<A NAME="lbAM">&nbsp;</A>
<H3>$object-&gt;<B>get</B> (...)</H3>
<DL COMPACT>
<DT id="8">&bull;<DD>
... (list) list of property names
</DL>
<P>
Alias for <TT>&quot;get_property&quot;</TT> (see ``get and set'' above).
<A NAME="lbAN">&nbsp;</A>
<H3>$object-&gt;<B>set</B> (key =&gt; $value, ...)</H3>
<DL COMPACT>
<DT id="9">&bull;<DD>
... (list) key/value pairs
</DL>
<P>
Alias for <TT>&quot;set_property&quot;</TT> (see ``get and set'' above).
<A NAME="lbAO">&nbsp;</A>
<H3>list = $object_or_class_name-&gt;<B>list_properties</B></H3>
List all the object properties for <I></I>$object_or_class_name<I></I>; returns them as
a list of hashes, containing these keys:
<DL COMPACT>
<DT id="10">name<DD>
The name of the property
<DT id="11">type<DD>
The type of the property
<DT id="12">owner_type<DD>
The type that owns the property
<DT id="13">descr<DD>
The description of the property
<DT id="14">flags<DD>
The Glib::ParamFlags of the property
</DL>
<A NAME="lbAP">&nbsp;</A>
<H3>$object-&gt;<B>notify</B> ($property_name)</H3>
<DL COMPACT>
<DT id="15">&bull;<DD>
<TT>$property_name</TT> (string)
</DL>
<P>
Emits a ``notify'' signal for the property <I></I>$property<I></I> on <I></I>$object<I></I>.
<A NAME="lbAQ">&nbsp;</A>
<H3>gpointer = $object-&gt;<B>get_pointer</B></H3>
Complement of <TT>&quot;new_from_pointer&quot;</TT>.
<A NAME="lbAR">&nbsp;</A>
<H3>$object-&gt;<B>get_property</B> (...)</H3>
Fetch and return the values for the object properties named in <I>...</I>.
<A NAME="lbAS">&nbsp;</A>
<H3>$object-&gt;<B>set_property</B> (key =&gt; $value, ...)</H3>
Set object properties.
<A NAME="lbAT">&nbsp;</A>
<H3>unsigned = $object_or_class_name-&gt;<B>signal_add_emission_hook</B> ($detailed_signal, $hook_func, $hook_data=undef)</H3>
<DL COMPACT>
<DT id="16">&bull;<DD>
<TT>$detailed_signal</TT> (string) of the form ``signal-name::detail''
<DT id="17">&bull;<DD>
<TT>$hook_func</TT> (subroutine)
<DT id="18">&bull;<DD>
<TT>$hook_data</TT> (scalar)
</DL>
<P>
Add an emission hook for a signal. The hook will be called for any emission
of that signal, independent of the instance. This is possible only for
signals which don't have the <TT>&quot;G_SIGNAL_NO_HOOKS&quot;</TT> flag set.
<P>
The <I></I>$hook_func<I></I> should be reference to a subroutine that looks something
like this:
<P>
<PRE>
sub emission_hook {
my ($invocation_hint, $parameters, $hook_data) = @_;
# $parameters is a reference to the @_ to be passed to
# signal handlers, including the instance as $parameters-&gt;[0].
return $stay_connected; # boolean
}
</PRE>
<P>
This function returns an id that can be used with <TT>&quot;remove_emission_hook&quot;</TT>.
<P>
Since 1.100.
<A NAME="lbAU">&nbsp;</A>
<H3>list = $instance-&gt;<B>signal_chain_from_overridden</B> (...)</H3>
<DL COMPACT>
<DT id="19">&bull;<DD>
... (list)
</DL>
<P>
Chain up to an overridden class closure; it is only valid to call this from
a class closure override.
<P>
Translation: because of various details in how GObjects are implemented,
the way to override a virtual method on a GObject is to provide a new ``class
closure'', or default handler for a signal. This happens when a class is
registered with the type system (see Glib::Type::register and
Glib::Object::Subclass). When called from inside such an override, this
method runs the overridden class closure. This is equivalent to calling
<TT>$self</TT>-&gt;SUPER::$method (@_) in normal Perl objects.
<A NAME="lbAV">&nbsp;</A>
<H3>unsigned = $instance-&gt;<B>signal_connect</B> ($detailed_signal, $callback, $data=undef)</H3>
<DL COMPACT>
<DT id="20">&bull;<DD>
<TT>$detailed_signal</TT> (string)
<DT id="21">&bull;<DD>
<TT>$callback</TT> (subroutine)
<DT id="22">&bull;<DD>
<TT>$data</TT> (scalar) arbitrary data to be passed to each invocation of <I>callback</I>
</DL>
<P>
Register <I>callback</I> to be called on each emission of <I></I>$detailed_signal<I></I>.
Returns an identifier that may be used to remove this handler with
<TT>&quot;$object-&gt;signal_handler_disconnect&quot;</TT>.
<A NAME="lbAW">&nbsp;</A>
<H3>unsigned = $instance-&gt;<B>signal_connect_after</B> ($detailed_signal, $callback, $data=undef)</H3>
<DL COMPACT>
<DT id="23">&bull;<DD>
<TT>$detailed_signal</TT> (string)
<DT id="24">&bull;<DD>
<TT>$callback</TT> (scalar)
<DT id="25">&bull;<DD>
<TT>$data</TT> (scalar)
</DL>
<P>
Like <TT>&quot;signal_connect&quot;</TT>, except that <I></I>$callback<I></I> will be run after the default
handler.
<A NAME="lbAX">&nbsp;</A>
<H3>unsigned = $instance-&gt;<B>signal_connect_swapped</B> ($detailed_signal, $callback, $data=undef)</H3>
<DL COMPACT>
<DT id="26">&bull;<DD>
<TT>$detailed_signal</TT> (string)
<DT id="27">&bull;<DD>
<TT>$callback</TT> (scalar)
<DT id="28">&bull;<DD>
<TT>$data</TT> (scalar)
</DL>
<P>
Like <TT>&quot;signal_connect&quot;</TT>, except that <I></I>$data<I></I> and <I></I>$object<I></I> will be swapped
on invocation of <I></I>$callback<I></I>.
<A NAME="lbAY">&nbsp;</A>
<H3>retval = $object-&gt;<B>signal_emit</B> ($name, ...)</H3>
<DL COMPACT>
<DT id="29">&bull;<DD>
<TT>$name</TT> (string) the name of the signal
<DT id="30">&bull;<DD>
... (list) any arguments to pass to handlers.
</DL>
<P>
Emit the signal <I>name</I> on <I></I>$object<I></I>. The number and types of additional
arguments in <I>...</I> are determined by the signal; similarly, the presence
and type of return value depends on the signal being emitted.
<A NAME="lbAZ">&nbsp;</A>
<H3>$ihint = $instance-&gt;<B>signal_get_invocation_hint</B></H3>
Get a reference to a hash describing the innermost signal currently active
on <TT>$instance</TT>. Returns undef if no signal emission is active. This
invocation hint is the same object passed to signal emission hooks, and
contains these keys:
<DL COMPACT>
<DT id="31">signal_name<DD>
The name of the signal being emitted.
<DT id="32">detail<DD>
The detail passed on for this emission. For example, a <TT>&quot;notify&quot;</TT> signal will
have the property name as the detail.
<DT id="33">run_type<DD>
The current stage of signal emission, one of ``run-first'', ``run-last'', or
``run-cleanup''.
</DL>
<A NAME="lbBA">&nbsp;</A>
<H3>$object-&gt;<B>signal_handler_block</B> ($handler_id)</H3>
<DL COMPACT>
<DT id="34">&bull;<DD>
<TT>$handler_id</TT> (unsigned)
</DL>
<A NAME="lbBB">&nbsp;</A>
<H3>$object-&gt;<B>signal_handler_disconnect</B> ($handler_id)</H3>
<DL COMPACT>
<DT id="35">&bull;<DD>
<TT>$handler_id</TT> (unsigned)
</DL>
<A NAME="lbBC">&nbsp;</A>
<H3>boolean = $object-&gt;<B>signal_handler_is_connected</B> ($handler_id)</H3>
<DL COMPACT>
<DT id="36">&bull;<DD>
<TT>$handler_id</TT> (unsigned)
</DL>
<A NAME="lbBD">&nbsp;</A>
<H3>$object-&gt;<B>signal_handler_unblock</B> ($handler_id)</H3>
<DL COMPACT>
<DT id="37">&bull;<DD>
<TT>$handler_id</TT> (unsigned)
</DL>
<A NAME="lbBE">&nbsp;</A>
<H3>integer = $instance-&gt;<B>signal_handlers_block_by_func</B> ($func, $data=undef)</H3>
<DL COMPACT>
<DT id="38">&bull;<DD>
<TT>$func</TT> (subroutine) function to block
<DT id="39">&bull;<DD>
<TT>$data</TT> (scalar) data to match, ignored if undef
</DL>
<A NAME="lbBF">&nbsp;</A>
<H3>integer = $instance-&gt;<B>signal_handlers_disconnect_by_func</B> ($func, $data=undef)</H3>
<DL COMPACT>
<DT id="40">&bull;<DD>
<TT>$func</TT> (subroutine) function to block
<DT id="41">&bull;<DD>
<TT>$data</TT> (scalar) data to match, ignored if undef
</DL>
<A NAME="lbBG">&nbsp;</A>
<H3>integer = $instance-&gt;<B>signal_handlers_unblock_by_func</B> ($func, $data=undef)</H3>
<DL COMPACT>
<DT id="42">&bull;<DD>
<TT>$func</TT> (subroutine) function to block
<DT id="43">&bull;<DD>
<TT>$data</TT> (scalar) data to match, ignored if undef
</DL>
<A NAME="lbBH">&nbsp;</A>
<H3>scalar = $object_or_class_name-&gt;<B>signal_query</B> ($name)</H3>
<DL COMPACT>
<DT id="44">&bull;<DD>
<TT>$name</TT> (string)
</DL>
<P>
Look up information about the signal <I></I>$name<I></I> on the instance type
<I></I>$object_or_class_name<I></I>, which may be either a Glib::Object or a package
name.
<P>
See also <TT>&quot;Glib::Type::list_signals&quot;</TT>, which returns the same kind of
hash refs as this does.
<P>
Since 1.080.
<A NAME="lbBI">&nbsp;</A>
<H3>$object_or_class_name-&gt;<B>signal_remove_emission_hook</B> ($signal_name, $hook_id)</H3>
<DL COMPACT>
<DT id="45">&bull;<DD>
<TT>$signal_name</TT> (string)
<DT id="46">&bull;<DD>
<TT>$hook_id</TT> (unsigned)
</DL>
<P>
Remove a hook that was installed by <TT>&quot;add_emission_hook&quot;</TT>.
<P>
Since 1.100.
<A NAME="lbBJ">&nbsp;</A>
<H3>$instance-&gt;<B>signal_stop_emission_by_name</B> ($detailed_signal)</H3>
<DL COMPACT>
<DT id="47">&bull;<DD>
<TT>$detailed_signal</TT> (string)
</DL>
<A NAME="lbBK">&nbsp;</A>
<H3>$object-&gt;<B>thaw_notify</B></H3>
Reverts the effect of a previous call to <TT>&quot;freeze_notify&quot;</TT>. This causes all
queued ``notify'' signals on <I></I>$object<I></I> to be emitted.
<A NAME="lbBL">&nbsp;</A>
<H3>boolean = Glib::Object-&gt;<B>set_threadsafe</B> ($threadsafe)</H3>
<DL COMPACT>
<DT id="48">&bull;<DD>
<TT>$threadsafe</TT> (boolean)
</DL>
<P>
Enables/disables threadsafe gobject tracking. Returns whether or not tracking
will be successful and thus whether using perl ithreads will be possible.
<A NAME="lbBM">&nbsp;</A>
<H3>$object-&gt;<B>tie_properties</B> ($all=FALSE)</H3>
<DL COMPACT>
<DT id="49">&bull;<DD>
<TT>$all</TT> (boolean) if <FONT SIZE="-1">FALSE</FONT> (or omitted) tie only properties for this object's class, if <FONT SIZE="-1">TRUE</FONT> tie the properties of this and all parent classes.
</DL>
<P>
A special method available to Glib::Object derivatives, it uses perl's tie
facilities to associate hash keys with the properties of the object. For
example:
<P>
<PRE>
$button-&gt;tie_properties;
# equivilent to $button-&gt;set (label =&gt; 'Hello World');
$button-&gt;{label} = 'Hello World';
print &quot;the label is: &quot;.$button-&gt;{label}.&quot;\n&quot;;
</PRE>
<P>
Attempts to write to read-only properties will croak, reading a write-only
property will return '[write-only]'.
<P>
Care must be taken when using tie_properties with objects of types created with
Glib::Object::Subclass as there may be clashes with existing hash keys that
could cause infinite loops. The solution is to use custom property get/set
functions to alter the storage locations of the properties.
<A NAME="lbBN">&nbsp;</A>
<H2>SIGNALS</H2>
<DL COMPACT>
<DT id="50"><B>notify</B> (Glib::Object, Glib::ParamSpec)<DD>
</DL>
<A NAME="lbBO">&nbsp;</A>
<H2>SEE ALSO</H2>
Glib
<A NAME="lbBP">&nbsp;</A>
<H2>COPYRIGHT</H2>
Copyright (C) 2003-2011 by the gtk2-perl team.
<P>
This software is licensed under the <FONT SIZE="-1">LGPL.</FONT> See Glib for a full notice.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="51"><A HREF="#lbAB">NAME</A><DD>
<DT id="52"><A HREF="#lbAC">DESCRIPTION</A><DD>
<DL>
<DT id="53"><A HREF="#lbAD">get and set</A><DD>
</DL>
<DT id="54"><A HREF="#lbAE">HIERARCHY</A><DD>
<DT id="55"><A HREF="#lbAF">METHODS</A><DD>
<DL>
<DT id="56"><A HREF="#lbAG">object = $class-&gt;<B>new</B> (...)</A><DD>
<DT id="57"><A HREF="#lbAH">scalar = Glib::Object-&gt;<B>new_from_pointer</B> ($pointer, $noinc=FALSE)</A><DD>
<DT id="58"><A HREF="#lbAI">unsigned = $object-&gt;<B>get_data</B> ($key)</A><DD>
<DT id="59"><A HREF="#lbAJ">$object-&gt;<B>set_data</B> ($key, $data)</A><DD>
<DT id="60"><A HREF="#lbAK">pspec or undef = $object_or_class_name-&gt;<B>find_property</B> ($name)</A><DD>
<DT id="61"><A HREF="#lbAL">$object-&gt;<B>freeze_notify</B></A><DD>
<DT id="62"><A HREF="#lbAM">$object-&gt;<B>get</B> (...)</A><DD>
<DT id="63"><A HREF="#lbAN">$object-&gt;<B>set</B> (key =&gt; $value, ...)</A><DD>
<DT id="64"><A HREF="#lbAO">list = $object_or_class_name-&gt;<B>list_properties</B></A><DD>
<DT id="65"><A HREF="#lbAP">$object-&gt;<B>notify</B> ($property_name)</A><DD>
<DT id="66"><A HREF="#lbAQ">gpointer = $object-&gt;<B>get_pointer</B></A><DD>
<DT id="67"><A HREF="#lbAR">$object-&gt;<B>get_property</B> (...)</A><DD>
<DT id="68"><A HREF="#lbAS">$object-&gt;<B>set_property</B> (key =&gt; $value, ...)</A><DD>
<DT id="69"><A HREF="#lbAT">unsigned = $object_or_class_name-&gt;<B>signal_add_emission_hook</B> ($detailed_signal, $hook_func, $hook_data=undef)</A><DD>
<DT id="70"><A HREF="#lbAU">list = $instance-&gt;<B>signal_chain_from_overridden</B> (...)</A><DD>
<DT id="71"><A HREF="#lbAV">unsigned = $instance-&gt;<B>signal_connect</B> ($detailed_signal, $callback, $data=undef)</A><DD>
<DT id="72"><A HREF="#lbAW">unsigned = $instance-&gt;<B>signal_connect_after</B> ($detailed_signal, $callback, $data=undef)</A><DD>
<DT id="73"><A HREF="#lbAX">unsigned = $instance-&gt;<B>signal_connect_swapped</B> ($detailed_signal, $callback, $data=undef)</A><DD>
<DT id="74"><A HREF="#lbAY">retval = $object-&gt;<B>signal_emit</B> ($name, ...)</A><DD>
<DT id="75"><A HREF="#lbAZ">$ihint = $instance-&gt;<B>signal_get_invocation_hint</B></A><DD>
<DT id="76"><A HREF="#lbBA">$object-&gt;<B>signal_handler_block</B> ($handler_id)</A><DD>
<DT id="77"><A HREF="#lbBB">$object-&gt;<B>signal_handler_disconnect</B> ($handler_id)</A><DD>
<DT id="78"><A HREF="#lbBC">boolean = $object-&gt;<B>signal_handler_is_connected</B> ($handler_id)</A><DD>
<DT id="79"><A HREF="#lbBD">$object-&gt;<B>signal_handler_unblock</B> ($handler_id)</A><DD>
<DT id="80"><A HREF="#lbBE">integer = $instance-&gt;<B>signal_handlers_block_by_func</B> ($func, $data=undef)</A><DD>
<DT id="81"><A HREF="#lbBF">integer = $instance-&gt;<B>signal_handlers_disconnect_by_func</B> ($func, $data=undef)</A><DD>
<DT id="82"><A HREF="#lbBG">integer = $instance-&gt;<B>signal_handlers_unblock_by_func</B> ($func, $data=undef)</A><DD>
<DT id="83"><A HREF="#lbBH">scalar = $object_or_class_name-&gt;<B>signal_query</B> ($name)</A><DD>
<DT id="84"><A HREF="#lbBI">$object_or_class_name-&gt;<B>signal_remove_emission_hook</B> ($signal_name, $hook_id)</A><DD>
<DT id="85"><A HREF="#lbBJ">$instance-&gt;<B>signal_stop_emission_by_name</B> ($detailed_signal)</A><DD>
<DT id="86"><A HREF="#lbBK">$object-&gt;<B>thaw_notify</B></A><DD>
<DT id="87"><A HREF="#lbBL">boolean = Glib::Object-&gt;<B>set_threadsafe</B> ($threadsafe)</A><DD>
<DT id="88"><A HREF="#lbBM">$object-&gt;<B>tie_properties</B> ($all=FALSE)</A><DD>
</DL>
<DT id="89"><A HREF="#lbBN">SIGNALS</A><DD>
<DT id="90"><A HREF="#lbBO">SEE ALSO</A><DD>
<DT id="91"><A HREF="#lbBP">COPYRIGHT</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:45 GMT, March 31, 2021
</BODY>
</HTML>