Wp.ObjectManager

g GObject.Object GObject.Object Wp.ObjectManager Wp.ObjectManager GObject.Object->Wp.ObjectManager

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

add_interest_full (interest)

get_n_objects ()

is_installed ()

lookup_full (interest)

new_filtered_iterator_full (interest)

new_iterator ()

request_object_features (object_type, wanted_features)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

core

Wp.Core

r

The Wp.Core

Signals

Inherited:

GObject.Object (1)

Name

Short Description

installed

object-added

object-removed

objects-changed

Fields

Inherited:

GObject.Object (1)

Class Details

class Wp.ObjectManager(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Wp.ObjectManagerClass

The Wp.ObjectManager class provides a way to collect a set of objects and be notified when objects that fulfill a certain set of criteria are created or destroyed. There are 4 kinds of objects that can be managed by a Wp.ObjectManager:

To start an object manager, you first need to declare interest in a certain kind of object by calling wp_object_manager_add_interest() and then install it on the Wp.Core with Wp.Core.install_object_manager(). Upon installing a Wp.ObjectManager on a Wp.Core, any pre-existing objects that match the interests of this Wp.ObjectManager will immediately become available to get through Wp.ObjectManager.new_iterator() and the Wp.ObjectManager object-added signal will be emitted for all of them. However, note that if these objects need to be prepared (to activate some features on them), the emission of object-added will be delayed. To know when it is safe to access the initial set of objects, wait until the installed signal has been emitted. That signal is emitted asynchronously after all the initial objects have been prepared.

classmethod new()
Returns:

the newly constructed object manager

Return type:

Wp.ObjectManager

Constructs a new object manager.

add_interest_full(interest)
Parameters:

interest (Wp.ObjectInterest) – the interest

Declares interest in a certain kind of object.

Interest consists of a GObject.GType that the object must be an ancestor of (GObject.type_is_a() must match) and optionally, a set of additional constraints on certain properties of the object. Refer to Wp.ObjectInterest for more details.

get_n_objects()
Returns:

the number of objects managed by this Wp.ObjectManager

Return type:

int

Gets the number of objects managed by the object manager.

is_installed()
Returns:

True if the object manager is installed (i.e. the Wp.ObjectManager installed signal has been emitted), False otherwise

Return type:

bool

Checks if an object manager is installed.

lookup_full(interest)
Parameters:

interest (Wp.ObjectInterest) – the interst

Returns:

the first managed object that matches the lookup interest, or None if no object matches

Return type:

GObject.Object or None

Searches for an object that matches the specified interest and returns it, if found.

If more than one objects match, only the first one is returned. To find multiple objects that match certain criteria, wp_object_manager_new_filtered_iterator() is more suitable.

new_filtered_iterator_full(interest)
Parameters:

interest (Wp.ObjectInterest) – the interest

Returns:

a Wp.Iterator that iterates over all the matching objects of this object manager

Return type:

Wp.Iterator

Iterates through all the objects managed by this object manager that match the specified interest.

new_iterator()
Returns:

a Wp.Iterator that iterates over all the managed objects of this object manager

Return type:

Wp.Iterator

Iterates through all the objects managed by this object manager.

request_object_features(object_type, wanted_features)
Parameters:
  • object_type (GObject.GType) – the Wp.Proxy descendant type

  • wanted_features (int) – the features to enable on this kind of object

Requests the object manager to automatically prepare the wanted_features on any managed object that is of the specified object_type.

These features will always be prepared before the object appears on the object manager.

Signal Details

Wp.ObjectManager.signals.installed(object_manager)
Signal Name:

installed

Flags:

RUN_FIRST

Parameters:

object_manager (Wp.ObjectManager) – The object which received the signal

Wp.ObjectManager.signals.object_added(object_manager, object)
Signal Name:

object-added

Flags:

RUN_FIRST

Parameters:
Wp.ObjectManager.signals.object_removed(object_manager, object)
Signal Name:

object-removed

Flags:

RUN_FIRST

Parameters:
Wp.ObjectManager.signals.objects_changed(object_manager)
Signal Name:

objects-changed

Flags:

RUN_FIRST

Parameters:

object_manager (Wp.ObjectManager) – The object which received the signal

Property Details

Wp.ObjectManager.props.core
Name:

core

Type:

Wp.Core

Default Value:

None

Flags:

READABLE

The Wp.Core