]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - liblightdm-gobject/layout.c
Use a private pipe for greeter<->server communication instead of D-Bus (needs to...
[sojka/lightdm.git] / liblightdm-gobject / layout.c
1 /*
2  * Copyright (C) 2010 Robert Ancell.
3  * Author: Robert Ancell <robert.ancell@canonical.com>
4  * 
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
9  * license.
10  */
11
12 #include "layout.h"
13
14 enum {
15     PROP_0,
16     PROP_NAME,
17     PROP_SHORT_DESCRIPTION,
18     PROP_DESCRIPTION
19 };
20
21 struct _LdmLayoutPrivate
22 {
23     gchar *name;
24     gchar *short_description;
25     gchar *description;
26 };
27
28 G_DEFINE_TYPE (LdmLayout, ldm_layout, G_TYPE_OBJECT);
29
30 /**
31  * ldm_layout_new:
32  * 
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
37  * 
38  * Return value: the new #LdmLayout
39  **/
40 LdmLayout *
41 ldm_layout_new (const gchar *name, const gchar *short_description, const gchar *description)
42 {
43     return g_object_new (LDM_TYPE_LAYOUT, "name", name, "short-description", short_description, "description", description, NULL);
44 }
45
46 /**
47  * ldm_layout_get_name:
48  * @layout: A #LdmLayout
49  * 
50  * Get the name of a layout.
51  * 
52  * Return value: The name of the layout
53  **/
54 const gchar *
55 ldm_layout_get_name (LdmLayout *layout)
56 {
57     return layout->priv->name;
58 }
59
60 /**
61  * ldm_layout_get_short_description:
62  * @layout: A #LdmLayout
63  * 
64  * Get the short description of a layout.
65  *
66  * Return value: A short description of the layout
67  **/
68 const gchar *
69 ldm_layout_get_short_description (LdmLayout *layout)
70 {
71     return layout->priv->short_description;
72 }
73
74 /**
75  * ldm_layout_get_description:
76  * @layout: A #LdmLayout
77  * 
78  * Get the long description of a layout.
79  * 
80  * Return value: A long description of the layout
81  **/
82 const gchar *
83 ldm_layout_get_description (LdmLayout *layout)
84 {
85     return layout->priv->description;
86 }
87
88 static void
89 ldm_layout_init (LdmLayout *layout)
90 {
91     layout->priv = G_TYPE_INSTANCE_GET_PRIVATE (layout, LDM_TYPE_LAYOUT, LdmLayoutPrivate);
92 }
93
94 static void
95 ldm_layout_set_property (GObject      *object,
96                          guint         prop_id,
97                          const GValue *value,
98                          GParamSpec   *pspec)
99 {
100     LdmLayout *self;
101
102     self = LDM_LAYOUT (object);
103
104     switch (prop_id) {
105     case PROP_NAME:
106         g_free (self->priv->name);
107         self->priv->name = g_strdup (g_value_get_string (value));
108         break;
109     case PROP_SHORT_DESCRIPTION:
110         g_free (self->priv->short_description);
111         self->priv->short_description = g_strdup (g_value_get_string (value));
112         break;
113     case PROP_DESCRIPTION:
114         g_free (self->priv->description);
115         self->priv->description = g_strdup (g_value_get_string (value));
116         break;
117     default:
118         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
119         break;
120     }
121 }
122
123 static void
124 ldm_layout_get_property (GObject    *object,
125                          guint       prop_id,
126                          GValue     *value,
127                          GParamSpec *pspec)
128 {
129     LdmLayout *self;
130
131     self = LDM_LAYOUT (object);
132
133     switch (prop_id) {
134     case PROP_NAME:
135         g_value_set_string (value, ldm_layout_get_name (self));
136         break;
137     case PROP_SHORT_DESCRIPTION:
138         g_value_set_string (value, ldm_layout_get_short_description (self));
139         break;
140     case PROP_DESCRIPTION:
141         g_value_set_string (value, ldm_layout_get_description (self));
142         break;
143     default:
144         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
145         break;
146     }
147 }
148
149 static void
150 ldm_layout_class_init (LdmLayoutClass *klass)
151 {
152     GObjectClass *object_class = G_OBJECT_CLASS (klass);
153   
154     g_type_class_add_private (klass, sizeof (LdmLayoutPrivate));
155
156     object_class->set_property = ldm_layout_set_property;
157     object_class->get_property = ldm_layout_get_property;
158
159     g_object_class_install_property(object_class,
160                                     PROP_NAME,
161                                     g_param_spec_string("name",
162                                                         "name",
163                                                         "Name of the layout",
164                                                         NULL,
165                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
166     g_object_class_install_property(object_class,
167                                     PROP_SHORT_DESCRIPTION,
168                                     g_param_spec_string("short-description",
169                                                         "short-description",
170                                                         "Short description of the layout",
171                                                         NULL,
172                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
173     g_object_class_install_property(object_class,
174                                     PROP_DESCRIPTION,
175                                     g_param_spec_string("description",
176                                                         "description",
177                                                         "Long description of the layout",
178                                                         NULL,
179                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
180 }