From a37b4bf20d4f964f344aa847807962964311c62b Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Tue, 11 May 2021 15:34:38 -0400 Subject: [PATCH] session-item: add _get_property API --- lib/wp/session-item.c | 22 ++++++++++++++++++++-- lib/wp/session-item.h | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/wp/session-item.c b/lib/wp/session-item.c index 26491dde..5e6e2de0 100644 --- a/lib/wp/session-item.c +++ b/lib/wp/session-item.c @@ -80,7 +80,7 @@ wp_session_item_dispose (GObject * object) } static void -wp_session_item_get_property (GObject * object, guint property_id, +wp_session_item_get_gobject_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { WpSessionItem *self = WP_SESSION_ITEM (object); @@ -193,7 +193,7 @@ wp_session_item_class_init (WpSessionItemClass * klass) GObjectClass * object_class = (GObjectClass *) klass; object_class->dispose = wp_session_item_dispose; - object_class->get_property = wp_session_item_get_property; + object_class->get_property = wp_session_item_get_gobject_property; wpobject_class->get_supported_features = session_item_default_get_supported_features; @@ -381,6 +381,24 @@ wp_session_item_get_properties (WpSessionItem * self) return priv->properties ? wp_properties_ref (priv->properties) : NULL; } +/** + * wp_session_item_get_property: + * @self: the session item + * @key: the property key + * + * Returns: the item property value for the given key. + */ +const gchar * +wp_session_item_get_property (WpSessionItem * self, const gchar *key) +{ + WpSessionItemPrivate *priv = NULL; + + g_return_val_if_fail (WP_IS_SESSION_ITEM (self), NULL); + + priv = wp_session_item_get_instance_private (self); + return priv->properties ? wp_properties_get (priv->properties, key) : NULL; +} + /** * wp_session_item_set_properties: * @self: the session item diff --git a/lib/wp/session-item.h b/lib/wp/session-item.h index 1d842a3d..23844399 100644 --- a/lib/wp/session-item.h +++ b/lib/wp/session-item.h @@ -100,6 +100,10 @@ void wp_session_item_remove (WpSessionItem * self); WP_API WpProperties * wp_session_item_get_properties (WpSessionItem * self); +WP_API +const gchar * wp_session_item_get_property (WpSessionItem * self, + const gchar *key); + /* for subclasses only */ WP_API