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