WpObject

digraph inheritance { rankdir=LR; GObject -> WpObject; }

struct WpObject

Base class for objects that have activatable features.

GObject Properties

core

The WpCore associated with this object

WpCore *

G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY

active-features

The active WpObjectFeatures on this proxy

guint (WpObjectFeatures)

G_PARAM_READABLE

supported-features

The supported WpObjectFeatures on this proxy

guint (WpObjectFeatures)

G_PARAM_READABLE

struct _WpObjectClass

Public Members

GObjectClass parent_class
WpObjectFeatures (*get_supported_features)(WpObject *self)
guint (*activate_get_next_step)(WpObject *self, WpFeatureActivationTransition *transition, guint step, WpObjectFeatures missing)
void (*activate_execute_step)(WpObject *self, WpFeatureActivationTransition *transition, guint step, WpObjectFeatures missing)
void (*deactivate)(WpObject *self, WpObjectFeatures features)
typedef guint WpObjectFeatures

Flags that specify functionality that is available on this class.

Use wp_object_activate() to enable more features, wp_object_get_supported_features() to see which features are supported and wp_object_get_active_features() to find out which features are already enabled. Features can also be deactivated later using wp_object_deactivate().

Actual feature flags are to be specified by subclasses and their interfaces. WP_OBJECT_FEATURES_ALL is a special value that can be used to activate all the supported features in any given object.

static const WpObjectFeatures WP_OBJECT_FEATURES_ALL = 0xffffffff

Special value that can be used to activate all the supported features in any given object.

WpCore *wp_object_get_core(WpObject *self)

Gets the core associated with this object.

Parameters:
  • self – the object

Returns:

(transfer full): the core associated with this object

WpObjectFeatures wp_object_get_active_features(WpObject *self)

Gets the active features of this object.

Parameters:
  • self – the object

Returns:

A bitset containing the active features of this object

WpObjectFeatures wp_object_get_supported_features(WpObject *self)

Gets the supported features of this object.

Parameters:
  • self – the object

Returns:

A bitset containing the supported features of this object; note that supported features may change at runtime

void wp_object_activate(WpObject *self, WpObjectFeatures features, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)

Callback version of wp_object_activate_closure()

Parameters:
  • self – the object

  • features – the features to enable

  • cancellable – (nullable): a cancellable for the async operation

  • callback – (scope async): a function to call when activation is complete

  • user_data – (closure): data for callback

void wp_object_activate_closure(WpObject *self, WpObjectFeatures features, GCancellable *cancellable, GClosure *closure)

Activates the requested features and invokes closure when this is done. features may contain unsupported or already active features. The operation will filter them and activate only ones that are supported and inactive.

If multiple calls to this method is done, the operations will be executed one after the other to ensure features only get activated once.

Note

closure may be invoked in sync while this method is being called, if there are no features to activate.

Parameters:
  • self – the object

  • features – the features to enable

  • cancellable – (nullable): a cancellable for the async operation

  • closure – (transfer full): the closure to use when activation is completed

gboolean wp_object_activate_finish(WpObject *self, GAsyncResult *res, GError **error)

Finishes the async operation that was started with wp_object_activate()

Parameters:
  • self – the object

  • res – the async operation result

  • error – (out) (optional): the error of the operation, if any

Returns:

TRUE if the requested features were activated, FALSE if there was an error

void wp_object_deactivate(WpObject *self, WpObjectFeatures features)

Deactivates the given features, leaving the object in the state it was before they were enabled.

This is seldom needed to call manually, but it can be used to save resources if some features are no longer needed.

Parameters:
  • self – the object

  • features – the features to deactivate

void wp_object_abort_activation(WpObject *self, const gchar *msg)

Aborts the current object activation by returning a transition error if any transitions are pending.

This is usually used to stop any pending activation if an error happened.

Since

0.4.6

Parameters:
  • self – the object

  • msg – the message used in the transition error

void wp_object_update_features(WpObject *self, WpObjectFeatures activated, WpObjectFeatures deactivated)

Allows subclasses to update the currently active features.

activated should contain new features and deactivated should contain features that were just deactivated. Calling this method also advances the activation transitions.

Remark

Private method to be called by subclasses only.

Parameters:
  • self – the object

  • activated – the features that were activated, or 0

  • deactivated – the features that were deactivated, or 0

WP_TYPE_OBJECT (wp_object_get_type ())

The WpObject GType.