Skip to content
Snippets Groups Projects
Commit 73c6e65a authored by Julian Bouzas's avatar Julian Bouzas
Browse files

session-item: add activate API with closure

parent 89d300ea
No related branches found
No related tags found
No related merge requests found
...@@ -651,13 +651,12 @@ on_activate_transition_post_completed (gpointer data, GClosure *closure) ...@@ -651,13 +651,12 @@ on_activate_transition_post_completed (gpointer data, GClosure *closure)
} }
/** /**
* wp_session_item_activate: * wp_session_item_activate_closure:
* @self: the session item * @self: the session item
* @callback: (scope async): a callback to call when activation is finished * @closure: (transfer full): the closure to use when activation is completed
* @callback_data: (closure): data passed to @callback
* *
* Activates the item asynchronously. * Activates the item asynchronously.
* You can use wp_session_item_activate_finish() in the @callback to get * You can use wp_session_item_activate_finish() in the closure callback to get
* the result of this operation. * the result of this operation.
* *
* This internally starts a #WpTransition that calls into * This internally starts a #WpTransition that calls into
...@@ -682,9 +681,7 @@ on_activate_transition_post_completed (gpointer data, GClosure *closure) ...@@ -682,9 +681,7 @@ on_activate_transition_post_completed (gpointer data, GClosure *closure)
* already activated. * already activated.
*/ */
void void
wp_session_item_activate (WpSessionItem * self, wp_session_item_activate_closure (WpSessionItem * self, GClosure *closure)
GAsyncReadyCallback callback,
gpointer callback_data)
{ {
g_return_if_fail (WP_IS_SESSION_ITEM (self)); g_return_if_fail (WP_IS_SESSION_ITEM (self));
...@@ -694,9 +691,6 @@ wp_session_item_activate (WpSessionItem * self, ...@@ -694,9 +691,6 @@ wp_session_item_activate (WpSessionItem * self,
g_return_if_fail (!(priv->flags & g_return_if_fail (!(priv->flags &
(WP_SI_FLAGS_MASK_OPERATION_IN_PROGRESS | WP_SI_FLAG_ACTIVE))); (WP_SI_FLAGS_MASK_OPERATION_IN_PROGRESS | WP_SI_FLAG_ACTIVE)));
GClosure *closure =
g_cclosure_new (G_CALLBACK (callback), callback_data, NULL);
/* TODO: add a way to cancel the transition if deactivate() is called in the meantime */ /* TODO: add a way to cancel the transition if deactivate() is called in the meantime */
WpTransition *transition = wp_transition_new_closure ( WpTransition *transition = wp_transition_new_closure (
wp_si_transition_get_type (), self, NULL, closure); wp_si_transition_get_type (), self, NULL, closure);
...@@ -721,6 +715,33 @@ wp_session_item_activate (WpSessionItem * self, ...@@ -721,6 +715,33 @@ wp_session_item_activate (WpSessionItem * self,
wp_transition_advance (transition); wp_transition_advance (transition);
} }
/**
* wp_session_item_activate:
* @self: the session item
* @callback: (scope async): a callback to call when activation is finished
* @callback_data: (closure): data passed to @callback
*
* @callback and @callback_data version of wp_session_item_activate_closure()
*/
void
wp_session_item_activate (WpSessionItem * self,
GAsyncReadyCallback callback,
gpointer callback_data)
{
g_return_if_fail (WP_IS_SESSION_ITEM (self));
WpSessionItemPrivate *priv =
wp_session_item_get_instance_private (self);
g_return_if_fail (!(priv->flags &
(WP_SI_FLAGS_MASK_OPERATION_IN_PROGRESS | WP_SI_FLAG_ACTIVE)));
GClosure *closure =
g_cclosure_new (G_CALLBACK (callback), callback_data, NULL);
wp_session_item_activate_closure (self, closure);
}
/** /**
* wp_session_item_activate_finish: * wp_session_item_activate_finish:
* @self: the session item * @self: the session item
......
...@@ -157,6 +157,9 @@ GVariant * wp_session_item_get_configuration (WpSessionItem * self); ...@@ -157,6 +157,9 @@ GVariant * wp_session_item_get_configuration (WpSessionItem * self);
/* state management */ /* state management */
WP_API
void wp_session_item_activate_closure (WpSessionItem * self, GClosure *closure);
WP_API WP_API
void wp_session_item_activate (WpSessionItem * self, void wp_session_item_activate (WpSessionItem * self,
GAsyncReadyCallback callback, gpointer callback_data); GAsyncReadyCallback callback, gpointer callback_data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment