Skip to content
Snippets Groups Projects
Commit 230c103f authored by Julian Bouzas's avatar Julian Bouzas Committed by George Kiagiadakis
Browse files

session-item: add _get_parent API

parent e810d327
No related branches found
No related tags found
No related merge requests found
......@@ -179,6 +179,10 @@ WpSpaPod * wp_spa_props_build_props (WpSpaProps * self);
GPtrArray * wp_spa_props_build_propinfo (WpSpaProps * self);
GPtrArray * wp_spa_props_build_all_pods (WpSpaProps * self);
/* session item */
void wp_session_item_set_parent (WpSessionItem *self, WpSessionItem *parent);
/* impl endpoint */
#define WP_TYPE_IMPL_ENDPOINT (wp_impl_endpoint_get_type ())
......
......@@ -96,6 +96,7 @@ wp_session_bin_add (WpSessionBin *self, WpSessionItem *item)
return FALSE;
g_ptr_array_add (priv->items, item);
wp_session_item_set_parent (item, WP_SESSION_ITEM (self));
return TRUE;
}
......@@ -112,6 +113,7 @@ gboolean
wp_session_bin_remove (WpSessionBin *self, WpSessionItem *item)
{
WpSessionBinPrivate *priv = wp_session_bin_get_instance_private (self);
wp_session_item_set_parent (item, NULL);
return g_ptr_array_remove_fast (priv->items, item);
}
......
......@@ -78,6 +78,7 @@ struct _WpSessionItemPrivate
{
GWeakRef session;
guint32 flags;
GWeakRef parent;
union {
WpProxy *impl_proxy;
......@@ -106,6 +107,7 @@ wp_session_item_init (WpSessionItem * self)
wp_session_item_get_instance_private (self);
g_weak_ref_init (&priv->session, NULL);
g_weak_ref_init (&priv->parent, NULL);
}
static void
......@@ -125,6 +127,7 @@ wp_session_item_finalize (GObject * object)
WpSessionItemPrivate *priv = wp_session_item_get_instance_private (self);
g_weak_ref_clear (&priv->session);
g_weak_ref_clear (&priv->parent);
G_OBJECT_CLASS (wp_session_item_parent_class)->finalize (object);
}
......@@ -359,6 +362,45 @@ wp_session_item_reset (WpSessionItem * self)
WP_SESSION_ITEM_GET_CLASS (self)->reset (self);
}
/**
* wp_session_item_get_parent:
* @self: the session item
*
* Gets the item's parent, which is the #WpSessionBin this item has been added
* to, or NULL if the item does not belong to a session bin.
*
* Returns: (nullable) (transfer full): the item's parent.
*/
WpSessionItem *
wp_session_item_get_parent (WpSessionItem * self)
{
g_return_val_if_fail (WP_IS_SESSION_ITEM (self), NULL);
WpSessionItemPrivate *priv =
wp_session_item_get_instance_private (self);
return g_weak_ref_get (&priv->parent);
}
/**
* wp_session_item_set_parent:
* @self: the session item
*
* Gets the item's parent, which is the #WpSessionBin this item has been added
* to, or NULL if the item does not belong to a session bin.
*
* Returns: (nullable) (transfer full): the item's parent.
*/
void
wp_session_item_set_parent (WpSessionItem *self, WpSessionItem *parent)
{
g_return_if_fail (WP_IS_SESSION_ITEM (self));
WpSessionItemPrivate *priv =
wp_session_item_get_instance_private (self);
g_weak_ref_set (&priv->parent, parent);
}
/**
* wp_session_item_get_flags:
* @self: the session item
......
......@@ -120,6 +120,9 @@ struct _WpSessionItemClass
WP_API
void wp_session_item_reset (WpSessionItem * self);
WP_API
WpSessionItem * wp_session_item_get_parent (WpSessionItem * self);
/* flags */
WP_API
......
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