Glib::Object(3)
π¦ Glib::Object β bindings for GObject π¦
okay so this is the Glib::Object(3) page from the User Contributed Perl Documentation, and it's literally the Perl-side bestie of GObject. no cap. π«Ά
π NAME π
Glib::Object β Bindings for GObject
β¨ DESCRIPTION β¨
GObject is the base object class provided by the gobject library. It's giving object properties with a notification system, plus emittable signals. iconic behavior. π
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. yes, magical. β¨
π«Ά get and set
Some subclasses of Glib::Object override get and set with methods more useful to the subclass β for example, Gtk2::TreeModel getting and setting row contents. slay.
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 get_property and set_property (together with find_property and list_properties to enquire about them). that's the safety net, bestie. π
Generic code for any object subclass can use the names get_property and set_property to be sure of getting the object properties as such. periodt.
π HIERARCHY π
Glib::Object
π METHODS π
π object = $class->new (...)
...(list) β key/value pairs, property values to set on creation
Instantiate a Glib::Object of type $class. Any key/value pairs in ... are used to set properties on the new object; see set. 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. π₯
π§ scalar = Glib::Object->new_from_pointer ($pointer, $noinc=FALSE)
$pointer(unsigned) β a C pointer value as an integer.$noinc(boolean) β if true, do not increase the GObject's reference count when creating the Perl wrapper. this typically means that the Perl wrapper will own the object. in general you don't want to do that, so the default is false.
Create a Perl Glib::Object reference for the C object pointed to by $pointer. You should need this very rarely; it's intended to support foreign objects.
β οΈ NOTE: the cast from arbitrary integer to GObject may result in a core dump without warning, because the type-checking macroG_OBJECT()attempts to dereference the pointer to find aGTypeClassstructure, and there is no portable way to validate the pointer. π so yeah, be careful.
π unsigned = $object->get_data ($key)
$key(string)
Fetch the integer stored under the object data key $key. These values do not have types; type conversions must be done manually. See set_data.
π₯ $object->set_data ($key, $data)
$key(string)$data(scalar)
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. iykyk. π
πΈ pspec or undef = $object_or_class_name->find_property ($name)
$name(string)
Find the definition of object property $name for $object_or_class_name. Return undef if no such property. For the returned data see Glib::Object::list_properties.
π $object->freeze_notify
Stops emission of "notify" signals on $object. The signals are queued until thaw_notify is called on $object. π§
π«Ά $object->get (...)
...(list) β list of property names
Alias for get_property (see get and set above).
π $object->set (key => $value, ...)
...(list) β key/value pairs
Alias for set_property (see get and set above).
β¨ list = $object_or_class_name->list_properties
List all the object properties for $object_or_class_name; returns them as a list of hashes, containing these keys:
nameβ The name of the propertytypeβ The type of the propertyowner_typeβ The type that owns the propertydescrβ The description of the propertyflagsβ TheGlib::ParamFlagsof the property
π¦ $object->notify ($property_name)
$property_name(string)
Emits a "notify" signal for the property $property on $object.
π§ gpointer = $object->get_pointer
Complement of new_from_pointer. cute. π
π $object->get_property (...)
Fetch and return the values for the object properties named in ....
π $object->set_property (key => $value, ...)
Set object properties. straightforward.
π₯ unsigned = $object_or_class_name->signal_add_emission_hook ($detailed_signal, $hook_func, $hook_data=undef)
$detailed_signal(string) β of the form"signal-name::detail"$hook_func(subroutine)$hook_data(scalar)
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 G_SIGNAL_NO_HOOKS flag set.
The $hook_func should be reference to a subroutine that looks something like this:
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->[0].
return $stay_connected; # boolean
}
This function returns an id that can be used with remove_emission_hook.
Since 1.100.
π§ list = $instance->signal_chain_from_overridden (...)
...(list)
Chain up to an overridden class closure; it is only valid to call this from a class closure override.
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 $self->SUPER::$method (@_) in normal Perl objects. π«Ά
π
unsigned = $instance->signal_connect ($detailed_signal, $callback, $data=undef)
$detailed_signal(string)$callback(subroutine)$data(scalar) β arbitrary data to be passed to each invocation of callback
Register callback to be called on each emission of $detailed_signal. Returns an identifier that may be used to remove this handler with "$object->signal_handler_disconnect".
πΈ unsigned = $instance->signal_connect_after ($detailed_signal, $callback, $data=undef)
$detailed_signal(string)$callback(scalar)$data(scalar)
Like signal_connect, except that $callback will be run after the default handler.
π unsigned = $instance->signal_connect_swapped ($detailed_signal, $callback, $data=undef)
$detailed_signal(string)$callback(scalar)$data(scalar)
Like signal_connect, except that $data and $object will be swapped on invocation of $callback.
π¦ retval = $object->signal_emit ($name, ...)
$name(string) β the name of the signal...(list) β any arguments to pass to handlers.
Emit the signal name on $object. The number and types of additional arguments in ... are determined by the signal; similarly, the presence and type of return value depends on the signal being emitted.
π $ihint = $instance->signal_get_invocation_hint
Get a reference to a hash describing the innermost signal currently active on $instance. Returns undef if no signal emission is active. This invocation hint is the same object passed to signal emission hooks, and contains these keys:
signal_nameβ The name of the signal being emitted.detailβ The detail passed on for this emission. For example, a"notify"signal will have the property name as the detail.run_typeβ The current stage of signal emission, one of"run-first","run-last", or"run-cleanup".
π $object->signal_handler_block ($handler_id)
$handler_id(unsigned)
π§ $object->signal_handler_disconnect ($handler_id)
$handler_id(unsigned)
β boolean = $object->signal_handler_is_connected ($handler_id)
$handler_id(unsigned)
β¨ $object->signal_handler_unblock ($handler_id)
$handler_id(unsigned)
π₯ integer = $instance->signal_handlers_block_by_func ($func, $data=undef)
$func(subroutine) β function to block$data(scalar) β data to match, ignored if undef
π integer = $instance->signal_handlers_disconnect_by_func ($func, $data=undef)
$func(subroutine) β function to block$data(scalar) β data to match, ignored if undef
πΈ integer = $instance->signal_handlers_unblock_by_func ($func, $data=undef)
$func(subroutine) β function to block$data(scalar) β data to match, ignored if undef
π¦ scalar = $object_or_class_name->signal_query ($name)
$name(string)
Look up information about the signal $name on the instance type $object_or_class_name, which may be either a Glib::Object or a package name.
See also "Glib::Type::list_signals", which returns the same kind of hash refs as this does.
Since 1.080.
π
$object_or_class_name->signal_remove_emission_hook ($signal_name, $hook_id)
$signal_name(string)$hook_id(unsigned)
Remove a hook that was installed by add_emission_hook.
Since 1.100.
π§ $instance->signal_stop_emission_by_name ($detailed_signal)
$detailed_signal(string)
π₯ $object->thaw_notify
Reverts the effect of a previous call to freeze_notify. This causes all queued "notify" signals on $object to be emitted. yes bestie, they escape now. π
π boolean = Glib::Object->set_threadsafe ($threadsafe)
$threadsafe(boolean)
Enables/disables threadsafe gobject tracking. Returns whether or not tracking will be successful and thus whether using perl ithreads will be possible.
π $object->tie_properties ($all=FALSE)
$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.
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:
$button->tie_properties;
# equivilent to $button->set (label => 'Hello World');
$button->{label} = 'Hello World';
print "the label is: ".$button->{label}."\n";
Attempts to write to read-only properties will croak, reading a write-only property will return '[write-only]'.
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. π infinite loops are not the vibe.
π‘ SIGNALS π‘
notify (Glib::Object, Glib::ParamSpec)
π SEE ALSO π
Glib
π COPYRIGHT π
okay so legal stuff, but make it cute β here's the vibe:
Copyright (C) 2003-2011 by the gtk2-perl team. π that's the whole squad who made this happen, and honestly? legends. periodt.
This software is licensed under the LGPL. π¦ and if you want the full β¨legal loreβ¨, the manpage says it plain: See Glib for a full notice β so like, go read Glib for the whole story, bestie, it's all there iykyk.
ngl the LGPL is the icon here β it's giving "share the love, keep it open" energy and we respect it π
and that's a wrap on this page, fr fr π«Ά this little rewrite was served up by perl v5.42.0, dated 2023-09-05 β no cap, that's the source and the date, go off ππ β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-Glib 1.3294-160000.2.2 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms