Pass distcheck! \o/
[mmediamanager.git] / libmmanager / mm-attribute.c
blob9e4449d1bafb3d97bc246bbac541f88c9c75c7e0
1 /* MManager - a Desktop wide manager for multimedia applications.
3 * Copyright (C) 2008 Cosimo Cecchi <cosimoc@gnome.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #include "mm-attribute.h"
23 #include <glib.h>
25 struct _MMAttribute {
26 char *id;
27 char *name;
28 char *description;
29 GType type;
32 /* public methods */
34 /**
35 * mm_attribute_get_name:
36 * @attr: a #MMAttribute.
38 * Gets the name of @attr.
40 * Return value: a string containing the name of @attr.
43 const char *
44 mm_attribute_get_name (MMAttribute *attr)
46 return attr->name;
49 /**
50 * mm_attribute_get_description:
51 * @attr: a #MMAttribute.
53 * Gets a textual description of @attr.
55 * Return value: a string containing a description of @attr.
58 const char *
59 mm_attribute_get_description (MMAttribute *attr)
61 return attr->description;
64 /**
65 * mm_attribute_get_value_type:
66 * @attr: a #MMAttribute.
68 * Gets the #GType that a possible value for @attr should have.
70 * Return value: a #GType.
73 GType
74 mm_attribute_get_value_type (MMAttribute *attr)
76 return attr->type;
79 /**
80 * mm_attribute_get_id:
81 * @attr: a #MMAttribute.
83 * Gets the unique identifier of @attr.
85 * Return value: a string containing the unique identifier of @attr.
88 const char *
89 mm_attribute_get_id (MMAttribute *attr)
91 return attr->id;
94 /**
95 * mm_attribute_free:
96 * @attr: a #MMAttribute.
98 * Release the memory occupied by a #MMAttribute.
101 void
102 mm_attribute_free (MMAttribute *attr)
104 g_free (attr->name);
105 g_free (attr->description);
106 g_free (attr->id);
108 g_slice_free (MMAttribute, attr);
112 * mm_attribute_new:
113 * @type: the #GType that a possible value for this attribute should have.
114 * @id: a string containing an unique id for the attribute.
115 * @name: a string containing the attribute's name.
116 * @description: a string containing the attribute's description.
118 * Builds a new #MMAttribute structure, with the specified properties. This is
119 * useful only if you're implementing a #MMAttributeManager, as the attributes
120 * are supposed to be static and owned by the manager.
122 * Return value: a newly allocated #MMAttribute structure. Free it with
123 * #mm_attribute_free.
126 MMAttribute *
127 mm_attribute_new (GType type,
128 const char *id,
129 const char *name,
130 const char *description)
132 MMAttribute *a;
134 a = g_slice_new0 (MMAttribute);
135 a->id = g_strdup (id);
136 a->name = g_strdup (name);
137 a->description = g_strdup (description);
138 a->type = type;
140 return a;