Wp.Transition

g GObject.GInterface GObject.GInterface Gio.AsyncResult Gio.AsyncResult GObject.GInterface->Gio.AsyncResult GObject.Object GObject.Object Wp.Transition Wp.Transition GObject.Object->Wp.Transition Gio.AsyncResult->Wp.Transition

Subclasses:

Wp.FeatureActivationTransition

Methods

Inherited:

GObject.Object (37), Gio.AsyncResult (4)

Structs:

GObject.ObjectClass (5)

class

finish (res)

class

new (type, source_object, cancellable, callback, *callback_data)

class

new_closure (type, source_object, cancellable, closure)

advance ()

get_completed ()

get_data ()

get_source_object ()

get_source_tag ()

had_error ()

is_tagged (tag)

return_error (error)

set_data (data, data_destroy)

set_source_tag (tag)

Virtual Methods

Inherited:

GObject.Object (7), Gio.AsyncResult (3)

do_execute_step (step)

do_get_next_step (step)

Properties

Name

Type

Flags

Short Description

completed

bool

r

Whether the transition has completed

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Wp.Transition(**kwargs)
Bases:

GObject.Object, Gio.AsyncResult

Abstract:

Yes

Structure:

Wp.TransitionClass

A transition is an asynchronous operation, like Gio.Task, that contains an internal state machine, where a series of ‘steps’ are executed in order to complete the operation. For every step, _WpTransitionClass::get_next_step() is called in order to determine the next step to execute. Afterwards, _WpTransitionClass::execute_step() is called to perform any actions necessary to complete this step. When execution of the step is done, the operation’s code must call Wp.Transition.advance() in order to continue to the next step. If an error occurs, the operation’s code must call Wp.Transition.return_error() instead, in which case the transition completes immediately and Wp.Transition.had_error() returns True. Typically, every step will start an asynchronous operation. Although it is possible, the Wp.Transition base class does not expect _WpTransitionClass::execute_step() to call Wp.Transition.advance() directly. Instead, it is expected that Wp.Transition.advance() will be called from the callback that the step’s asynchronous operation will call when it is completed.

classmethod finish(res)
Parameters:

res (Gio.AsyncResult) – a transition, as a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True if the transition completed successfully, False if there was an error

Return type:

bool

Returns the final return status of the transition and its error, if there was one.

This is meant to be called from within the Gio.AsyncReadyCallback that was specified in Wp.Transition.new().

classmethod new(type, source_object, cancellable, callback, *callback_data)
Parameters:
Returns:

the new transition

Return type:

Wp.Transition

Creates a Wp.Transition acting on source_object.

When the transition is done, callback will be invoked. The transition does not automatically start executing steps. You must call Wp.Transition.advance() after creating it in order to start it. The transition is automatically unref’ed after the callback has been executed. If you wish to keep an additional reference on it, you need to ref it explicitly.

classmethod new_closure(type, source_object, cancellable, closure)
Parameters:
Returns:

the new transition

Return type:

Wp.Transition

Creates a Wp.Transition acting on source_object. When the transition is done, closure will be invoked.

The transition does not automatically start executing steps. You must call Wp.Transition.advance() after creating it in order to start it. Note that the transition is automatically unref’ed after the closure has been executed. If you wish to keep an additional reference on it, you need to ref it explicitly.

advance()

Advances the transition to the next step.

This initially calls _WpTransitionClass::get_next_step() in order to determine what the next step is. If _WpTransitionClass::get_next_step() returns a step different than the previous one, it calls _WpTransitionClass::execute_step() to execute it. The very first time that _WpTransitionClass::get_next_step() is called, its step parameter equals Wp.TransitionStep.NONE. When _WpTransitionClass::get_next_step() returns Wp.TransitionStep.NONE this function completes the transition, calling the transition’s callback and then unref-ing the transition. When _WpTransitionClass::get_next_step() returns Wp.TransitionStep.ERROR, this function calls Wp.Transition.return_error(), unless it has already been called directly by _WpTransitionClass::get_next_step(). In error conditions, _WpTransitionClass::execute_step() is called once with step being Wp.TransitionStep.ERROR, allowing the implementation to rollback any changes or cancel underlying jobs, if necessary.

get_completed()
Returns:

True if the transition has completed (with or without an error), False otherwise

Return type:

bool

Checks if the transition completed.

get_data()
Returns:

the transition’s data

Return type:

object or None

Gets self ‘s data.

See Wp.Transition.set_data().

get_source_object()
Returns:

the source object

Return type:

GObject.Object

Gets the source object from the transition.

Like Gio.AsyncResult.get_source_object(), but does not ref the object.

get_source_tag()
Returns:

the transition’s source tag

Return type:

object or None

Gets self ‘s source tag.

See Wp.Transition.set_source_tag().

had_error()
Returns:

True if the transition completed with an error, False otherwise

Return type:

bool

Checks if the transition completed with an error.

is_tagged(tag)
Parameters:

tag (object or None) – a tag

Returns:

True if self has the indicated tag , False if not.

Return type:

bool

Checks if self has the given tag (generally a function pointer indicating the function self was created by).

return_error(error)
Parameters:

error (GLib.Error) – a GLib.Error

Completes the transition with an error.

This can be called anytime from within any virtual function or an async job handler. In most cases this will also unref the transition, so it is not safe to access it after this function has been called.

set_data(data, data_destroy)
Parameters:

Sets self ‘s data (freeing the existing data, if any). This can be an arbitrary user structure that holds data associated with this transition.

set_source_tag(tag)
Parameters:

tag (object or None) – an opaque pointer indicating the source of this transition

Sets self ‘s source tag.

You can use this to tag a transition’s return value with a particular pointer (usually a pointer to the function doing the tagging) and then later check it using Wp.Transition.get_source_tag() (or Gio.AsyncResult.is_tagged()) in the transition’s “finish” function, to figure out if the response came from a particular place.

do_execute_step(step) virtual
Parameters:

step (int) –

do_get_next_step(step) virtual
Parameters:

step (int) –

Return type:

int

Property Details

Wp.Transition.props.completed
Name:

completed

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the transition has completed