1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = gobject-Enumeration-and-Flag-Types.html
27  * outPack = gobject
28  * outFile = Enums
29  * strct   = GEnumValue
30  * realStrct=
31  * ctorStrct=
32  * clss    = Enums
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_enum_
41  * omit structs:
42  * omit prefixes:
43  * 	- g_flags_
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * structWrap:
49  * 	- GEnumValue* -> Enums
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module gobject.Enums;
56 
57 public  import gtkc.gobjecttypes;
58 
59 private import gtkc.gobject;
60 private import glib.ConstructionException;
61 private import gobject.ObjectG;
62 
63 
64 private import glib.Str;
65 
66 
67 
68 
69 /**
70  * Description
71  * The GLib type system provides fundamental types for enumeration and
72  * flags types. (Flags types are like enumerations, but allow their
73  * values to be combined by bitwise or). A registered enumeration or
74  * flags type associates a name and a nickname with each allowed
75  * value, and the methods g_enum_get_value_by_name(),
76  * g_enum_get_value_by_nick(), g_flags_get_value_by_name() and
77  * g_flags_get_value_by_nick() can look up values by their name or
78  * nickname. When an enumeration or flags type is registered with the
79  * GLib type system, it can be used as value type for object
80  * properties, using g_param_spec_enum() or g_param_spec_flags().
81  * GObject ships with a utility called glib-mkenums that can construct
82  * suitable type registration functions from C enumeration
83  * definitions.
84  */
85 public class Enums
86 {
87 	
88 	/** the main Gtk struct */
89 	protected GEnumValue* gEnumValue;
90 	
91 	
92 	public GEnumValue* getEnumsStruct()
93 	{
94 		return gEnumValue;
95 	}
96 	
97 	
98 	/** the main Gtk struct as a void* */
99 	protected void* getStruct()
100 	{
101 		return cast(void*)gEnumValue;
102 	}
103 	
104 	/**
105 	 * Sets our main struct and passes it to the parent class
106 	 */
107 	public this (GEnumValue* gEnumValue)
108 	{
109 		this.gEnumValue = gEnumValue;
110 	}
111 	
112 	/**
113 	 */
114 	
115 	/**
116 	 * Returns the GEnumValue for a value.
117 	 * Params:
118 	 * enumClass = a GEnumClass
119 	 * value = the value to look up
120 	 * Returns: the GEnumValue for value, or NULL if value is not a member of the enumeration
121 	 */
122 	public static Enums getValue(GEnumClass* enumClass, int value)
123 	{
124 		// GEnumValue *	 g_enum_get_value (GEnumClass *enum_class,  gint value);
125 		auto p = g_enum_get_value(enumClass, value);
126 		
127 		if(p is null)
128 		{
129 			return null;
130 		}
131 		
132 		return ObjectG.getDObject!(Enums)(cast(GEnumValue*) p);
133 	}
134 	
135 	/**
136 	 * Looks up a GEnumValue by name.
137 	 * Params:
138 	 * enumClass = a GEnumClass
139 	 * name = the name to look up
140 	 * Returns: the GEnumValue with name name, or NULL if the enumeration doesn't have a member with that name
141 	 */
142 	public static Enums getValueByName(GEnumClass* enumClass, string name)
143 	{
144 		// GEnumValue *	 g_enum_get_value_by_name (GEnumClass *enum_class,  const gchar *name);
145 		auto p = g_enum_get_value_by_name(enumClass, Str.toStringz(name));
146 		
147 		if(p is null)
148 		{
149 			return null;
150 		}
151 		
152 		return ObjectG.getDObject!(Enums)(cast(GEnumValue*) p);
153 	}
154 	
155 	/**
156 	 * Looks up a GEnumValue by nickname.
157 	 * Params:
158 	 * enumClass = a GEnumClass
159 	 * nick = the nickname to look up
160 	 * Returns: the GEnumValue with nickname nick, or NULL if the enumeration doesn't have a member with that nickname
161 	 */
162 	public static Enums getValueByNick(GEnumClass* enumClass, string nick)
163 	{
164 		// GEnumValue *	 g_enum_get_value_by_nick (GEnumClass *enum_class,  const gchar *nick);
165 		auto p = g_enum_get_value_by_nick(enumClass, Str.toStringz(nick));
166 		
167 		if(p is null)
168 		{
169 			return null;
170 		}
171 		
172 		return ObjectG.getDObject!(Enums)(cast(GEnumValue*) p);
173 	}
174 	
175 	/**
176 	 * Registers a new static enumeration type with the name name.
177 	 * It is normally more convenient to let glib-mkenums generate a
178 	 * my_enum_get_type() function from a usual C enumeration definition
179 	 * than to write one yourself using g_enum_register_static().
180 	 * Params:
181 	 * name = A nul-terminated string used as the name of the new type.
182 	 * Returns: The new type identifier.
183 	 */
184 	public static GType registerStatic(string name, Enums _StaticValues)
185 	{
186 		// GType g_enum_register_static (const gchar *name,  const GEnumValue *const_static_values);
187 		return g_enum_register_static(Str.toStringz(name), (_StaticValues is null) ? null : _StaticValues.getEnumsStruct());
188 	}
189 	
190 	/**
191 	 * This function is meant to be called from the complete_type_info()
192 	 * function of a GTypePlugin implementation, as in the following
193 	 * Params:
194 	 * type = the type identifier of the type being completed
195 	 * info = the GTypeInfo struct to be filled in
196 	 */
197 	public static void completeTypeInfo(GType type, out GTypeInfo info, Enums _Values)
198 	{
199 		// void g_enum_complete_type_info (GType g_enum_type,  GTypeInfo *info,  const GEnumValue *const_values);
200 		g_enum_complete_type_info(type, &info, (_Values is null) ? null : _Values.getEnumsStruct());
201 	}
202 }