2 * Copyright (C) 2010 Robert Ancell.
3 * Author: Robert Ancell <robert.ancell@canonical.com>
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3 of the License, or (at your option) any
8 * later version. See http://www.gnu.org/copyleft/lgpl.html the full text of the
21 struct _LdmSessionPrivate
28 G_DEFINE_TYPE (LdmSession, ldm_session, G_TYPE_OBJECT);
33 * Create a new session.
34 * @key: The unique key for this session
35 * @name: The name of this session
36 * @comment: The comment for this session
38 * Return value: the new #LdmSession
41 ldm_session_new (const gchar *key, const gchar *name, const gchar *comment)
43 return g_object_new (LDM_TYPE_SESSION, "key", key, "name", name, "comment", comment, NULL);
48 * @session: A #LdmSession
50 * Get the key for a session
52 * Return value: The session key
55 ldm_session_get_key (LdmSession *session)
57 g_return_val_if_fail (LDM_IS_SESSION (session), NULL);
58 return session->priv->key;
62 * ldm_session_get_name
63 * @session: A #LdmSession
65 * Get the name for a session
67 * Return value: The session name
70 ldm_session_get_name (LdmSession *session)
72 g_return_val_if_fail (LDM_IS_SESSION (session), NULL);
73 return session->priv->name;
77 * ldm_session_get_comment
78 * @session: A #LdmSession
80 * Get the comment for a session
82 * Return value: The session comment
85 ldm_session_get_comment (LdmSession *session)
87 g_return_val_if_fail (LDM_IS_SESSION (session), NULL);
88 return session->priv->comment;
92 ldm_session_init (LdmSession *session)
94 session->priv = G_TYPE_INSTANCE_GET_PRIVATE (session, LDM_TYPE_SESSION, LdmSessionPrivate);
98 ldm_session_set_property (GObject *object,
105 self = LDM_SESSION (object);
109 g_free (self->priv->key);
110 self->priv->key = g_strdup (g_value_get_string (value));
113 g_free (self->priv->name);
114 self->priv->name = g_strdup (g_value_get_string (value));
117 g_free (self->priv->comment);
118 self->priv->comment = g_strdup (g_value_get_string (value));
121 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
127 ldm_session_get_property (GObject *object,
134 self = LDM_SESSION (object);
138 g_value_set_string (value, ldm_session_get_key (self));
141 g_value_set_string (value, ldm_session_get_name (self));
144 g_value_set_string (value, ldm_session_get_comment (self));
147 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
153 ldm_session_class_init (LdmSessionClass *klass)
155 GObjectClass *object_class = G_OBJECT_CLASS (klass);
157 g_type_class_add_private (klass, sizeof (LdmSessionPrivate));
159 object_class->set_property = ldm_session_set_property;
160 object_class->get_property = ldm_session_get_property;
162 g_object_class_install_property(object_class,
164 g_param_spec_string("key",
168 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
169 g_object_class_install_property(object_class,
171 g_param_spec_string("name",
175 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
176 g_object_class_install_property(object_class,
178 g_param_spec_string("comment",
182 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));