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