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 private import glib.Str; 64 65 66 67 /** 68 * The GLib type system provides fundamental types for enumeration and 69 * flags types. (Flags types are like enumerations, but allow their 70 * values to be combined by bitwise or). A registered enumeration or 71 * flags type associates a name and a nickname with each allowed 72 * value, and the methods g_enum_get_value_by_name(), 73 * g_enum_get_value_by_nick(), g_flags_get_value_by_name() and 74 * g_flags_get_value_by_nick() can look up values by their name or 75 * nickname. When an enumeration or flags type is registered with the 76 * GLib type system, it can be used as value type for object 77 * properties, using g_param_spec_enum() or g_param_spec_flags(). 78 * 79 * GObject ships with a utility called glib-mkenums that can construct 80 * suitable type registration functions from C enumeration 81 * definitions. 82 */ 83 public class Enums 84 { 85 86 /** the main Gtk struct */ 87 protected GEnumValue* gEnumValue; 88 89 90 /** Get the main Gtk struct */ 91 public GEnumValue* getEnumsStruct() 92 { 93 return gEnumValue; 94 } 95 96 97 /** the main Gtk struct as a void* */ 98 protected void* getStruct() 99 { 100 return cast(void*)gEnumValue; 101 } 102 103 /** 104 * Sets our main struct and passes it to the parent class 105 */ 106 public this (GEnumValue* gEnumValue) 107 { 108 this.gEnumValue = gEnumValue; 109 } 110 111 /** 112 */ 113 114 /** 115 * Returns the GEnumValue for a value. 116 * Params: 117 * enumClass = a GEnumClass 118 * value = the value to look up 119 * Returns: the GEnumValue for value, or NULL if value is not a member of the enumeration 120 */ 121 public static Enums getValue(GEnumClass* enumClass, int value) 122 { 123 // GEnumValue * g_enum_get_value (GEnumClass *enum_class, gint value); 124 auto p = g_enum_get_value(enumClass, value); 125 126 if(p is null) 127 { 128 return null; 129 } 130 131 return ObjectG.getDObject!(Enums)(cast(GEnumValue*) p); 132 } 133 134 /** 135 * Looks up a GEnumValue by name. 136 * Params: 137 * enumClass = a GEnumClass 138 * name = the name to look up 139 * Returns: the GEnumValue with name name, or NULL if the enumeration doesn't have a member with that name 140 */ 141 public static Enums getValueByName(GEnumClass* enumClass, string name) 142 { 143 // GEnumValue * g_enum_get_value_by_name (GEnumClass *enum_class, const gchar *name); 144 auto p = g_enum_get_value_by_name(enumClass, Str.toStringz(name)); 145 146 if(p is null) 147 { 148 return null; 149 } 150 151 return ObjectG.getDObject!(Enums)(cast(GEnumValue*) p); 152 } 153 154 /** 155 * Looks up a GEnumValue by nickname. 156 * Params: 157 * enumClass = a GEnumClass 158 * nick = the nickname to look up 159 * Returns: the GEnumValue with nickname nick, or NULL if the enumeration doesn't have a member with that nickname 160 */ 161 public static Enums getValueByNick(GEnumClass* enumClass, string nick) 162 { 163 // GEnumValue * g_enum_get_value_by_nick (GEnumClass *enum_class, const gchar *nick); 164 auto p = g_enum_get_value_by_nick(enumClass, Str.toStringz(nick)); 165 166 if(p is null) 167 { 168 return null; 169 } 170 171 return ObjectG.getDObject!(Enums)(cast(GEnumValue*) p); 172 } 173 174 /** 175 * Registers a new static enumeration type with the name name. 176 * It is normally more convenient to let glib-mkenums generate a 177 * my_enum_get_type() function from a usual C enumeration definition 178 * than to write one yourself using g_enum_register_static(). 179 * Params: 180 * name = A nul-terminated string used as the name of the new type. 181 * Returns: The new type identifier. 182 */ 183 public static GType registerStatic(string name, Enums _StaticValues) 184 { 185 // GType g_enum_register_static (const gchar *name, const GEnumValue *const_static_values); 186 return g_enum_register_static(Str.toStringz(name), (_StaticValues is null) ? null : _StaticValues.getEnumsStruct()); 187 } 188 189 /** 190 * This function is meant to be called from the complete_type_info 191 * function of a GTypePlugin implementation, as in the following 192 * Params: 193 * type = the type identifier of the type being completed 194 * info = the GTypeInfo struct to be filled in 195 */ 196 public static void completeTypeInfo(GType type, out GTypeInfo info, Enums _Values) 197 { 198 // void g_enum_complete_type_info (GType g_enum_type, GTypeInfo *info, const GEnumValue *const_values); 199 g_enum_complete_type_info(type, &info, (_Values is null) ? null : _Values.getEnumsStruct()); 200 } 201 }