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
17 PROP_SHORT_DESCRIPTION,
21 struct _LdmLayoutPrivate
24 gchar *short_description;
28 G_DEFINE_TYPE (LdmLayout, ldm_layout, G_TYPE_OBJECT);
33 * Create a new layout.
34 * @name: The layout name
35 * @short_description: Short description for the layout
36 * @description: Long description for the layout
38 * Return value: the new #LdmLayout
41 ldm_layout_new (const gchar *name, const gchar *short_description, const gchar *description)
43 return g_object_new (LDM_TYPE_LAYOUT, "name", name, "short-description", short_description, "description", description, NULL);
47 * ldm_layout_get_name:
48 * @layout: A #LdmLayout
50 * Get the name of a layout.
52 * Return value: The name of the layout
55 ldm_layout_get_name (LdmLayout *layout)
57 g_return_val_if_fail (LDM_IS_LAYOUT (layout), NULL);
58 return layout->priv->name;
62 * ldm_layout_get_short_description:
63 * @layout: A #LdmLayout
65 * Get the short description of a layout.
67 * Return value: A short description of the layout
70 ldm_layout_get_short_description (LdmLayout *layout)
72 g_return_val_if_fail (LDM_IS_LAYOUT (layout), NULL);
73 return layout->priv->short_description;
77 * ldm_layout_get_description:
78 * @layout: A #LdmLayout
80 * Get the long description of a layout.
82 * Return value: A long description of the layout
85 ldm_layout_get_description (LdmLayout *layout)
87 g_return_val_if_fail (LDM_IS_LAYOUT (layout), NULL);
88 return layout->priv->description;
92 ldm_layout_init (LdmLayout *layout)
94 layout->priv = G_TYPE_INSTANCE_GET_PRIVATE (layout, LDM_TYPE_LAYOUT, LdmLayoutPrivate);
98 ldm_layout_set_property (GObject *object,
105 self = LDM_LAYOUT (object);
109 g_free (self->priv->name);
110 self->priv->name = g_strdup (g_value_get_string (value));
112 case PROP_SHORT_DESCRIPTION:
113 g_free (self->priv->short_description);
114 self->priv->short_description = g_strdup (g_value_get_string (value));
116 case PROP_DESCRIPTION:
117 g_free (self->priv->description);
118 self->priv->description = g_strdup (g_value_get_string (value));
121 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
127 ldm_layout_get_property (GObject *object,
134 self = LDM_LAYOUT (object);
138 g_value_set_string (value, ldm_layout_get_name (self));
140 case PROP_SHORT_DESCRIPTION:
141 g_value_set_string (value, ldm_layout_get_short_description (self));
143 case PROP_DESCRIPTION:
144 g_value_set_string (value, ldm_layout_get_description (self));
147 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
153 ldm_layout_class_init (LdmLayoutClass *klass)
155 GObjectClass *object_class = G_OBJECT_CLASS (klass);
157 g_type_class_add_private (klass, sizeof (LdmLayoutPrivate));
159 object_class->set_property = ldm_layout_set_property;
160 object_class->get_property = ldm_layout_get_property;
162 g_object_class_install_property(object_class,
164 g_param_spec_string("name",
166 "Name of the layout",
168 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
169 g_object_class_install_property(object_class,
170 PROP_SHORT_DESCRIPTION,
171 g_param_spec_string("short-description",
173 "Short description of the layout",
175 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
176 g_object_class_install_property(object_class,
178 g_param_spec_string("description",
180 "Long description of the layout",
182 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));