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 * Inserts a #GParamSpec in the pool. 70 * 71 * Params: 72 * pspec = the #GParamSpec to insert 73 * ownerType = a #GType identifying the owner of @pspec 74 */ 75 public void insert(ParamSpec pspec, GType ownerType) 76 { 77 g_param_spec_pool_insert(gParamSpecPool, (pspec is null) ? null : pspec.getParamSpecStruct(), ownerType); 78 } 79 80 /** 81 * Gets an array of all #GParamSpecs owned by @owner_type in 82 * the pool. 83 * 84 * Params: 85 * ownerType = the owner to look for 86 * 87 * Return: a newly 88 * allocated array containing pointers to all #GParamSpecs 89 * owned by @owner_type in the pool 90 */ 91 public ParamSpec[] list(GType ownerType) 92 { 93 uint nPspecsP; 94 95 auto p = g_param_spec_pool_list(gParamSpecPool, ownerType, &nPspecsP); 96 97 if(p is null) 98 { 99 return null; 100 } 101 102 ParamSpec[] arr = new ParamSpec[nPspecsP]; 103 for(int i = 0; i < nPspecsP; i++) 104 { 105 arr[i] = ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p[i]); 106 } 107 108 return arr; 109 } 110 111 /** 112 * Gets an #GList of all #GParamSpecs owned by @owner_type in 113 * the pool. 114 * 115 * Params: 116 * ownerType = the owner to look for 117 * 118 * Return: a 119 * #GList of all #GParamSpecs owned by @owner_type in 120 * the pool#GParamSpecs. 121 */ 122 public ListG listOwned(GType ownerType) 123 { 124 auto p = g_param_spec_pool_list_owned(gParamSpecPool, ownerType); 125 126 if(p is null) 127 { 128 return null; 129 } 130 131 return new ListG(cast(GList*) p); 132 } 133 134 /** 135 * Looks up a #GParamSpec in the pool. 136 * 137 * Params: 138 * paramName = the name to look for 139 * ownerType = the owner to look for 140 * walkAncestors = If %TRUE, also try to find a #GParamSpec with @param_name 141 * owned by an ancestor of @owner_type. 142 * 143 * Return: The found #GParamSpec, or %NULL if no 144 * matching #GParamSpec was found. 145 */ 146 public ParamSpec lookup(string paramName, GType ownerType, bool walkAncestors) 147 { 148 auto p = g_param_spec_pool_lookup(gParamSpecPool, Str.toStringz(paramName), ownerType, walkAncestors); 149 150 if(p is null) 151 { 152 return null; 153 } 154 155 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p); 156 } 157 158 /** 159 * Removes a #GParamSpec from the pool. 160 * 161 * Params: 162 * pspec = the #GParamSpec to remove 163 */ 164 public void remove(ParamSpec pspec) 165 { 166 g_param_spec_pool_remove(gParamSpecPool, (pspec is null) ? null : pspec.getParamSpecStruct()); 167 } 168 169 /** 170 * Creates a new #GParamSpecPool. 171 * 172 * If @type_prefixing is %TRUE, lookups in the newly created pool will 173 * allow to specify the owner as a colon-separated prefix of the 174 * property name, like "GtkContainer:border-width". This feature is 175 * deprecated, so you should always set @type_prefixing to %FALSE. 176 * 177 * Params: 178 * typePrefixing = Whether the pool will support type-prefixed property names. 179 * 180 * Return: a newly allocated #GParamSpecPool. 181 * 182 * Throws: ConstructionException GTK+ fails to create the object. 183 */ 184 public this(bool typePrefixing) 185 { 186 auto p = g_param_spec_pool_new(typePrefixing); 187 188 if(p is null) 189 { 190 throw new ConstructionException("null returned by new"); 191 } 192 193 this(cast(GParamSpecPool*) p); 194 } 195 }