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