source: appstream-generator/build/girepo/gobject/Enums.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 4.0 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gobject.Enums;
22
23private import gi.gobject;
24public  import gi.gobjecttypes;
25private import glib.Str;
26
27
28/** */
29public struct Enums
30{
31
32        /**
33         * This function is meant to be called from the `complete_type_info`
34         * function of a #GTypePlugin implementation, as in the following
35         * example:
36         *
37         * |[<!-- language="C" -->
38         * static void
39         * my_enum_complete_type_info (GTypePlugin     *plugin,
40         * GType            g_type,
41         * GTypeInfo       *info,
42         * GTypeValueTable *value_table)
43         * {
44         * static const GEnumValue values[] = {
45         * { MY_ENUM_FOO, "MY_ENUM_FOO", "foo" },
46         * { MY_ENUM_BAR, "MY_ENUM_BAR", "bar" },
47         * { 0, NULL, NULL }
48         * };
49         *
50         * g_enum_complete_type_info (type, info, values);
51         * }
52         * ]|
53         *
54         * Params:
55         *     gEnumType = the type identifier of the type being completed
56         *     info = the #GTypeInfo struct to be filled in
57         *     constValues = An array of #GEnumValue structs for the possible
58         *         enumeration values. The array is terminated by a struct with all
59         *         members being 0.
60         */
61        public static void completeTypeInfo(GType gEnumType, out GTypeInfo info, GEnumValue* constValues)
62        {
63                g_enum_complete_type_info(gEnumType, &info, constValues);
64        }
65
66        /**
67         * Returns the #GEnumValue for a value.
68         *
69         * Params:
70         *     enumClass = a #GEnumClass
71         *     value = the value to look up
72         *
73         * Returns: the #GEnumValue for @value, or %NULL
74         *     if @value is not a member of the enumeration
75         */
76        public static GEnumValue* getValue(GEnumClass* enumClass, int value)
77        {
78                return g_enum_get_value(enumClass, value);
79        }
80
81        /**
82         * Looks up a #GEnumValue by name.
83         *
84         * Params:
85         *     enumClass = a #GEnumClass
86         *     name = the name to look up
87         *
88         * Returns: the #GEnumValue with name @name,
89         *     or %NULL if the enumeration doesn't have a member
90         *     with that name
91         */
92        public static GEnumValue* getValueByName(GEnumClass* enumClass, string name)
93        {
94                return g_enum_get_value_by_name(enumClass, Str.toStringz(name));
95        }
96
97        /**
98         * Looks up a #GEnumValue by nickname.
99         *
100         * Params:
101         *     enumClass = a #GEnumClass
102         *     nick = the nickname to look up
103         *
104         * Returns: the #GEnumValue with nickname @nick,
105         *     or %NULL if the enumeration doesn't have a member
106         *     with that nickname
107         */
108        public static GEnumValue* getValueByNick(GEnumClass* enumClass, string nick)
109        {
110                return g_enum_get_value_by_nick(enumClass, Str.toStringz(nick));
111        }
112
113        /**
114         * Registers a new static enumeration type with the name @name.
115         *
116         * It is normally more convenient to let [glib-mkenums][glib-mkenums],
117         * generate a my_enum_get_type() function from a usual C enumeration
118         * definition  than to write one yourself using g_enum_register_static().
119         *
120         * Params:
121         *     name = A nul-terminated string used as the name of the new type.
122         *     constStaticValues = An array of #GEnumValue structs for the possible
123         *         enumeration values. The array is terminated by a struct with all
124         *         members being 0. GObject keeps a reference to the data, so it cannot
125         *         be stack-allocated.
126         *
127         * Returns: The new type identifier.
128         */
129        public static GType registerStatic(string name, GEnumValue* constStaticValues)
130        {
131                return g_enum_register_static(Str.toStringz(name), constStaticValues);
132        }
133}
Note: See TracBrowser for help on using the repository browser.