~jbicha/hud/build-depend-on-valac-not-gir

« back to all changes in this revision

Viewing changes to libhud-client/enum-types.c.in

  • Committer: Tarmac
  • Author(s): Ted Gould, Pete Woods, Antti Kaijanmäki, Ted Gould, Albert Astals, Ryan Lortie, Łukasz 'sil2100' Zemczak, Albert Astals Cid, Mathieu Trudel-Lapierre, Kaleo, Tarmac, Ricardo Salveti de Araujo, Michael Terry, Automatic PS uploader
  • Date: 2013-04-10 16:04:51 UTC
  • mfrom: (227.3.148 phablet)
  • Revision ID: tarmac-20130410160451-o3owpv3zaxulm5of
HUD 2.0 Merge.

Approved by PS Jenkins bot, Mathieu Trudel-Lapierre.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*** BEGIN file-header ***/
 
2
/*
 
3
 * Copyright © 2013 Canonical Ltd.
 
4
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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/>.
 
16
 *
 
17
 * Author: Ted Gould <ted@canonical.com>
 
18
 */
 
19
 
 
20
#include "enum-types.h"
 
21
 
 
22
/*** END file-header ***/
 
23
 
 
24
/*** BEGIN file-production ***/
 
25
#include "@basename@"
 
26
/*** END file-production ***/
 
27
 
 
28
/*** BEGIN value-header ***/
 
29
/**
 
30
        @enum_name@_get_type:
 
31
 
 
32
        Builds a GLib type for the #@EnumName@ enumeration.
 
33
 
 
34
        Return value: A unique #GType for the #@EnumName@ enum.
 
35
*/
 
36
GType
 
37
@enum_name@_get_type (void)
 
38
{
 
39
        static GType etype = 0;
 
40
        if (G_UNLIKELY(etype == 0)) {
 
41
                static const G@Type@Value values[] = {
 
42
/*** END value-header ***/
 
43
 
 
44
/*** BEGIN value-production ***/
 
45
                        { @VALUENAME@,  "@VALUENAME@", "@valuenick@" },
 
46
/*** END value-production ***/
 
47
 
 
48
/*** BEGIN value-tail ***/
 
49
                        { 0, NULL, NULL}
 
50
                };
 
51
                
 
52
                etype = g_@type@_register_static (g_intern_static_string("@EnumName@"), values);
 
53
        }
 
54
 
 
55
        return etype;
 
56
}
 
57
 
 
58
/**
 
59
        @enum_name@_get_nick:
 
60
        @value: The value of @EnumName@ to get the nick of
 
61
 
 
62
        Looks up in the enum table for the nick of @value.
 
63
 
 
64
        Return value: The nick for the given value or #NULL on error
 
65
*/
 
66
const gchar *
 
67
@enum_name@_get_nick (@EnumName@ value)
 
68
{
 
69
        GEnumClass * class = G_ENUM_CLASS(g_type_class_ref(@enum_name@_get_type()));
 
70
        g_return_val_if_fail(class != NULL, NULL);
 
71
 
 
72
        const gchar * ret = NULL;
 
73
        GEnumValue * val = g_enum_get_value(class, value);
 
74
        if (val != NULL) {
 
75
                ret = val->value_nick;
 
76
        }
 
77
 
 
78
        g_type_class_unref(class);
 
79
        return ret;
 
80
}
 
81
 
 
82
/**
 
83
        @enum_name@_get_value_from_nick:
 
84
        @nick: The enum nick to lookup
 
85
 
 
86
        Looks up in the enum table for the value of @nick.
 
87
 
 
88
        Return value: The value for the given @nick
 
89
*/
 
90
@EnumName@
 
91
@enum_name@_get_value_from_nick (const gchar * nick)
 
92
{
 
93
        GEnumClass * class = G_ENUM_CLASS(g_type_class_ref(@enum_name@_get_type()));
 
94
        g_return_val_if_fail(class != NULL, 0);
 
95
 
 
96
        @EnumName@ ret = 0;
 
97
        GEnumValue * val = g_enum_get_value_by_nick(class, nick);
 
98
        if (val != NULL) {
 
99
                ret = val->value;
 
100
        }
 
101
 
 
102
        g_type_class_unref(class);
 
103
        return ret;
 
104
}
 
105
 
 
106
 
 
107
/*** END value-tail ***/