Wp.Transition¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r |
Whether the transition has completed |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Wp.Transition(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
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 callWp.Transition.advance
() in order to continue to the next step. If an error occurs, the operation’s code must callWp.Transition.return_error
() instead, in which case the transition completes immediately andWp.Transition.had_error
() returnsTrue
. Typically, every step will start an asynchronous operation. Although it is possible, theWp.Transition
base class does not expect _WpTransitionClass::execute_step() to callWp.Transition.advance
() directly. Instead, it is expected thatWp.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 aGio.AsyncResult
- Raises:
- Returns:
True
if the transition completed successfully,False
if there was an error- Return type:
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 inWp.Transition.new
().
- classmethod new(type, source_object, cancellable, callback, *callback_data)¶
- Parameters:
type (
GObject.GType
) – theGObject.GType
of theWp.Transition
subclass to instantiatesource_object (
GObject.Object
orNone
) – theGObject.Object
that owns this task, orNone
cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
callback_data (
object
orNone
) – user data passed to callback
- Returns:
the new transition
- Return type:
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:
type (
GObject.GType
) – theGObject.GType
of theWp.Transition
subclass to instantiatesource_object (
GObject.Object
orNone
) – theGObject.Object
that owns this task, orNone
cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
closure (
GObject.Closure
orNone
) – aGio.AsyncReadyCallback
wrapped in aGObject.Closure
- Returns:
the new transition
- Return type:
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() returnsWp.TransitionStep.NONE
this function completes the transition, calling the transition’s callback and then unref-ing the transition. When _WpTransitionClass::get_next_step() returnsWp.TransitionStep.ERROR
, this function callsWp.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 beingWp.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:
Checks if the transition completed.
- get_data()¶
-
Gets self ‘s data.
See
Wp.Transition.set_data
().
- get_source_object()¶
- Returns:
the source object
- Return type:
Gets the source object from the transition.
Like
Gio.AsyncResult.get_source_object
(), but does not ref the object.
- get_source_tag()¶
-
Gets self ‘s source tag.
See
Wp.Transition.set_source_tag
().
- had_error()¶
-
Checks if the transition completed with an error.
- is_tagged(tag)¶
- Parameters:
- Returns:
- Return type:
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
) – aGLib.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:
data_destroy (
GLib.DestroyNotify
orNone
) –GLib.DestroyNotify
for data
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)¶
-
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
() (orGio.AsyncResult.is_tagged
()) in the transition’s “finish” function, to figure out if the response came from a particular place.