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 module gobject.Enums; 26 27 private import glib.Str; 28 private import gtkc.gobject; 29 public import gtkc.gobjecttypes; 30 31 32 /** */ 33 public struct Enums 34 { 35 36 /** 37 * This function is meant to be called from the `complete_type_info` 38 * function of a #GTypePlugin implementation, as in the following 39 * example: 40 * 41 * |[<!-- language="C" --> 42 * static void 43 * my_enum_complete_type_info (GTypePlugin *plugin, 44 * GType g_type, 45 * GTypeInfo *info, 46 * GTypeValueTable *value_table) 47 * { 48 * static const GEnumValue values[] = { 49 * { MY_ENUM_FOO, "MY_ENUM_FOO", "foo" }, 50 * { MY_ENUM_BAR, "MY_ENUM_BAR", "bar" }, 51 * { 0, NULL, NULL } 52 * }; 53 * 54 * g_enum_complete_type_info (type, info, values); 55 * } 56 * ]| 57 * 58 * Params: 59 * gEnumType = the type identifier of the type being completed 60 * info = the #GTypeInfo struct to be filled in 61 * constValues = An array of #GEnumValue structs for the possible 62 * enumeration values. The array is terminated by a struct with all 63 * members being 0. 64 */ 65 public static void completeTypeInfo(GType gEnumType, out GTypeInfo info, GEnumValue* constValues) 66 { 67 g_enum_complete_type_info(gEnumType, &info, constValues); 68 } 69 70 /** 71 * Returns the #GEnumValue for a value. 72 * 73 * Params: 74 * enumClass = a #GEnumClass 75 * value = the value to look up 76 * 77 * Return: the #GEnumValue for @value, or %NULL 78 * if @value is not a member of the enumeration 79 */ 80 public static GEnumValue* getValue(GEnumClass* enumClass, int value) 81 { 82 return g_enum_get_value(enumClass, value); 83 } 84 85 /** 86 * Looks up a #GEnumValue by name. 87 * 88 * Params: 89 * enumClass = a #GEnumClass 90 * name = the name to look up 91 * 92 * Return: the #GEnumValue with name @name, 93 * or %NULL if the enumeration doesn't have a member 94 * with that name 95 */ 96 public static GEnumValue* getValueByName(GEnumClass* enumClass, string name) 97 { 98 return g_enum_get_value_by_name(enumClass, Str.toStringz(name)); 99 } 100 101 /** 102 * Looks up a #GEnumValue by nickname. 103 * 104 * Params: 105 * enumClass = a #GEnumClass 106 * nick = the nickname to look up 107 * 108 * Return: the #GEnumValue with nickname @nick, 109 * or %NULL if the enumeration doesn't have a member 110 * with that nickname 111 */ 112 public static GEnumValue* getValueByNick(GEnumClass* enumClass, string nick) 113 { 114 return g_enum_get_value_by_nick(enumClass, Str.toStringz(nick)); 115 } 116 117 /** 118 * Registers a new static enumeration type with the name @name. 119 * 120 * It is normally more convenient to let [glib-mkenums][glib-mkenums], 121 * generate a my_enum_get_type() function from a usual C enumeration 122 * definition than to write one yourself using g_enum_register_static(). 123 * 124 * Params: 125 * name = A nul-terminated string used as the name of the new type. 126 * constStaticValues = An array of #GEnumValue structs for the possible 127 * enumeration values. The array is terminated by a struct with all 128 * members being 0. GObject keeps a reference to the data, so it cannot 129 * be stack-allocated. 130 * 131 * Return: The new type identifier. 132 */ 133 public static GType registerStatic(string name, GEnumValue* constStaticValues) 134 { 135 return g_enum_register_static(Str.toStringz(name), constStaticValues); 136 } 137 }