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 return session->priv->key;
61 * ldm_session_get_name
62 * @session: A #LdmSession
64 * Get the name for a session
66 * Return value: The session name
69 ldm_session_get_name (LdmSession *session)
71 return session->priv->name;
75 * ldm_session_get_comment
76 * @session: A #LdmSession
78 * Get the comment for a session
80 * Return value: The session comment
83 ldm_session_get_comment (LdmSession *session)
85 return session->priv->comment;
89 ldm_session_init (LdmSession *session)
91 session->priv = G_TYPE_INSTANCE_GET_PRIVATE (session, LDM_TYPE_SESSION, LdmSessionPrivate);
95 ldm_session_set_property (GObject *object,
103 self = LDM_SESSION (object);
107 g_free (self->priv->key);
108 self->priv->key = g_strdup (g_value_get_string (value));
111 g_free (self->priv->name);
112 self->priv->name = g_strdup (g_value_get_string (value));
115 g_free (self->priv->comment);
116 self->priv->comment = g_strdup (g_value_get_string (value));
119 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
125 ldm_session_get_property (GObject *object,
132 self = LDM_SESSION (object);
136 g_value_set_string (value, ldm_session_get_key (self));
139 g_value_set_string (value, ldm_session_get_name (self));
142 g_value_set_string (value, ldm_session_get_comment (self));
145 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
151 ldm_session_class_init (LdmSessionClass *klass)
153 GObjectClass *object_class = G_OBJECT_CLASS (klass);
155 g_type_class_add_private (klass, sizeof (LdmSessionPrivate));
157 object_class->set_property = ldm_session_set_property;
158 object_class->get_property = ldm_session_get_property;
160 g_object_class_install_property(object_class,
162 g_param_spec_string("key",
166 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
167 g_object_class_install_property(object_class,
169 g_param_spec_string("name",
173 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
174 g_object_class_install_property(object_class,
176 g_param_spec_string("comment",
180 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));