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.ParamSpecPool; 26 27 private import glib.ConstructionException; 28 private import glib.ListG; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gobject.ParamSpec; 32 private import gtkc.gobject; 33 public import gtkc.gobjecttypes; 34 35 36 /** 37 * A #GParamSpecPool maintains a collection of #GParamSpecs which can be 38 * quickly accessed by owner and name. The implementation of the #GObject property 39 * system uses such a pool to store the #GParamSpecs of the properties all object 40 * types. 41 */ 42 public class ParamSpecPool 43 { 44 /** the main Gtk struct */ 45 protected GParamSpecPool* gParamSpecPool; 46 47 /** Get the main Gtk struct */ 48 public GParamSpecPool* getParamSpecPoolStruct() 49 { 50 return gParamSpecPool; 51 } 52 53 /** the main Gtk struct as a void* */ 54 protected void* getStruct() 55 { 56 return cast(void*)gParamSpecPool; 57 } 58 59 /** 60 * Sets our main struct and passes it to the parent class. 61 */ 62 public this (GParamSpecPool* gParamSpecPool) 63 { 64 this.gParamSpecPool = gParamSpecPool; 65 } 66 67 /** 68 */ 69 70 /** 71 * Inserts a #GParamSpec in the pool. 72 * 73 * Params: 74 * pspec = the #GParamSpec to insert 75 * ownerType = a #GType identifying the owner of @pspec 76 */ 77 public void insert(ParamSpec pspec, GType ownerType) 78 { 79 g_param_spec_pool_insert(gParamSpecPool, (pspec is null) ? null : pspec.getParamSpecStruct(), ownerType); 80 } 81 82 /** 83 * Gets an array of all #GParamSpecs owned by @owner_type in 84 * the pool. 85 * 86 * Params: 87 * ownerType = the owner to look for 88 * nPspecsP = return location for the length of the returned array 89 * 90 * Return: a newly 91 * allocated array containing pointers to all #GParamSpecs 92 * owned by @owner_type in the pool 93 */ 94 public ParamSpec[] list(GType ownerType) 95 { 96 uint nPspecsP; 97 98 auto p = g_param_spec_pool_list(gParamSpecPool, ownerType, &nPspecsP); 99 100 if(p is null) 101 { 102 return null; 103 } 104 105 ParamSpec[] arr = new ParamSpec[nPspecsP]; 106 for(int i = 0; i < nPspecsP; i++) 107 { 108 arr[i] = ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p[i]); 109 } 110 111 return arr; 112 } 113 114 /** 115 * Gets an #GList of all #GParamSpecs owned by @owner_type in 116 * the pool. 117 * 118 * Params: 119 * ownerType = the owner to look for 120 * 121 * Return: a 122 * #GList of all #GParamSpecs owned by @owner_type in 123 * the pool#GParamSpecs. 124 */ 125 public ListG listOwned(GType ownerType) 126 { 127 auto p = g_param_spec_pool_list_owned(gParamSpecPool, ownerType); 128 129 if(p is null) 130 { 131 return null; 132 } 133 134 return new ListG(cast(GList*) p); 135 } 136 137 /** 138 * Looks up a #GParamSpec in the pool. 139 * 140 * Params: 141 * paramName = the name to look for 142 * ownerType = the owner to look for 143 * walkAncestors = If %TRUE, also try to find a #GParamSpec with @param_name 144 * owned by an ancestor of @owner_type. 145 * 146 * Return: The found #GParamSpec, or %NULL if no 147 * matching #GParamSpec was found. 148 */ 149 public ParamSpec lookup(string paramName, GType ownerType, bool walkAncestors) 150 { 151 auto p = g_param_spec_pool_lookup(gParamSpecPool, Str.toStringz(paramName), ownerType, walkAncestors); 152 153 if(p is null) 154 { 155 return null; 156 } 157 158 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p); 159 } 160 161 /** 162 * Removes a #GParamSpec from the pool. 163 * 164 * Params: 165 * pspec = the #GParamSpec to remove 166 */ 167 public void remove(ParamSpec pspec) 168 { 169 g_param_spec_pool_remove(gParamSpecPool, (pspec is null) ? null : pspec.getParamSpecStruct()); 170 } 171 172 /** 173 * Creates a new #GParamSpecPool. 174 * 175 * If @type_prefixing is %TRUE, lookups in the newly created pool will 176 * allow to specify the owner as a colon-separated prefix of the 177 * property name, like "GtkContainer:border-width". This feature is 178 * deprecated, so you should always set @type_prefixing to %FALSE. 179 * 180 * Params: 181 * typePrefixing = Whether the pool will support type-prefixed property names. 182 * 183 * Return: a newly allocated #GParamSpecPool. 184 * 185 * Throws: ConstructionException GTK+ fails to create the object. 186 */ 187 public this(bool typePrefixing) 188 { 189 auto p = g_param_spec_pool_new(typePrefixing); 190 191 if(p is null) 192 { 193 throw new ConstructionException("null returned by new"); 194 } 195 196 this(cast(GParamSpecPool*) p); 197 } 198 }