1
/*** BEGIN file-header ***/
3
* Copyright © 2013 Canonical Ltd.
5
* This program is free software: you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 3, as
7
* published by the Free Software Foundation.
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranties of
11
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
* PURPOSE. See the GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Author: Ted Gould <ted@canonical.com>
20
#include "enum-types.h"
22
/*** END file-header ***/
24
/*** BEGIN file-production ***/
26
/*** END file-production ***/
28
/*** BEGIN value-header ***/
32
Builds a GLib type for the #@EnumName@ enumeration.
34
Return value: A unique #GType for the #@EnumName@ enum.
37
@enum_name@_get_type (void)
39
static GType etype = 0;
40
if (G_UNLIKELY(etype == 0)) {
41
static const G@Type@Value values[] = {
42
/*** END value-header ***/
44
/*** BEGIN value-production ***/
45
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
46
/*** END value-production ***/
48
/*** BEGIN value-tail ***/
52
etype = g_@type@_register_static (g_intern_static_string("@EnumName@"), values);
60
@value: The value of @EnumName@ to get the nick of
62
Looks up in the enum table for the nick of @value.
64
Return value: The nick for the given value or #NULL on error
67
@enum_name@_get_nick (@EnumName@ value)
69
GEnumClass * class = G_ENUM_CLASS(g_type_class_ref(@enum_name@_get_type()));
70
g_return_val_if_fail(class != NULL, NULL);
72
const gchar * ret = NULL;
73
GEnumValue * val = g_enum_get_value(class, value);
75
ret = val->value_nick;
78
g_type_class_unref(class);
83
@enum_name@_get_value_from_nick:
84
@nick: The enum nick to lookup
86
Looks up in the enum table for the value of @nick.
88
Return value: The value for the given @nick
91
@enum_name@_get_value_from_nick (const gchar * nick)
93
GEnumClass * class = G_ENUM_CLASS(g_type_class_ref(@enum_name@_get_type()));
94
g_return_val_if_fail(class != NULL, 0);
97
GEnumValue * val = g_enum_get_value_by_nick(class, nick);
102
g_type_class_unref(class);
107
/*** END value-tail ***/