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 glib.Hook;
26 
27 private import glib.HookList;
28 private import gtkc.glib;
29 public  import gtkc.glibtypes;
30 
31 
32 /**
33  * The #GHook struct represents a single hook function in a #GHookList.
34  */
35 public class Hook
36 {
37 	/** the main Gtk struct */
38 	protected GHook* gHook;
39 
40 	/** Get the main Gtk struct */
41 	public GHook* getHookStruct()
42 	{
43 		return gHook;
44 	}
45 
46 	/** the main Gtk struct as a void* */
47 	protected void* getStruct()
48 	{
49 		return cast(void*)gHook;
50 	}
51 
52 	/**
53 	 * Sets our main struct and passes it to the parent class.
54 	 */
55 	public this (GHook* gHook)
56 	{
57 		this.gHook = gHook;
58 	}
59 
60 	/**
61 	 */
62 
63 	/**
64 	 * Compares the ids of two #GHook elements, returning a negative value
65 	 * if the second id is greater than the first.
66 	 *
67 	 * Params:
68 	 *     sibling = a #GHook to compare with @new_hook
69 	 *
70 	 * Return: a value <= 0 if the id of @sibling is >= the id of @new_hook
71 	 */
72 	public int compareIds(Hook sibling)
73 	{
74 		return g_hook_compare_ids(gHook, (sibling is null) ? null : sibling.getHookStruct());
75 	}
76 
77 	/**
78 	 * Allocates space for a #GHook and initializes it.
79 	 *
80 	 * Params:
81 	 *     hookList = a #GHookList
82 	 *
83 	 * Return: a new #GHook
84 	 */
85 	public static Hook alloc(HookList hookList)
86 	{
87 		auto p = g_hook_alloc((hookList is null) ? null : hookList.getHookListStruct());
88 		
89 		if(p is null)
90 		{
91 			return null;
92 		}
93 		
94 		return new Hook(cast(GHook*) p);
95 	}
96 
97 	/**
98 	 * Destroys a #GHook, given its ID.
99 	 *
100 	 * Params:
101 	 *     hookList = a #GHookList
102 	 *     hookId = a hook ID
103 	 *
104 	 * Return: %TRUE if the #GHook was found in the #GHookList and destroyed
105 	 */
106 	public static bool destroy(HookList hookList, gulong hookId)
107 	{
108 		return g_hook_destroy((hookList is null) ? null : hookList.getHookListStruct(), hookId) != 0;
109 	}
110 
111 	/**
112 	 * Removes one #GHook from a #GHookList, marking it
113 	 * inactive and calling g_hook_unref() on it.
114 	 *
115 	 * Params:
116 	 *     hookList = a #GHookList
117 	 *     hook = the #GHook to remove
118 	 */
119 	public static void destroyLink(HookList hookList, Hook hook)
120 	{
121 		g_hook_destroy_link((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct());
122 	}
123 
124 	/**
125 	 * Finds a #GHook in a #GHookList using the given function to
126 	 * test for a match.
127 	 *
128 	 * Params:
129 	 *     hookList = a #GHookList
130 	 *     needValids = %TRUE if #GHook elements which have been destroyed
131 	 *         should be skipped
132 	 *     func = the function to call for each #GHook, which should return
133 	 *         %TRUE when the #GHook has been found
134 	 *     data = the data to pass to @func
135 	 *
136 	 * Return: the found #GHook or %NULL if no matching #GHook is found
137 	 */
138 	public static Hook find(HookList hookList, bool needValids, GHookFindFunc func, void* data)
139 	{
140 		auto p = g_hook_find((hookList is null) ? null : hookList.getHookListStruct(), needValids, func, data);
141 		
142 		if(p is null)
143 		{
144 			return null;
145 		}
146 		
147 		return new Hook(cast(GHook*) p);
148 	}
149 
150 	/**
151 	 * Finds a #GHook in a #GHookList with the given data.
152 	 *
153 	 * Params:
154 	 *     hookList = a #GHookList
155 	 *     needValids = %TRUE if #GHook elements which have been destroyed
156 	 *         should be skipped
157 	 *     data = the data to find
158 	 *
159 	 * Return: the #GHook with the given @data or %NULL if no matching
160 	 *     #GHook is found
161 	 */
162 	public static Hook findData(HookList hookList, bool needValids, void* data)
163 	{
164 		auto p = g_hook_find_data((hookList is null) ? null : hookList.getHookListStruct(), needValids, data);
165 		
166 		if(p is null)
167 		{
168 			return null;
169 		}
170 		
171 		return new Hook(cast(GHook*) p);
172 	}
173 
174 	/**
175 	 * Finds a #GHook in a #GHookList with the given function.
176 	 *
177 	 * Params:
178 	 *     hookList = a #GHookList
179 	 *     needValids = %TRUE if #GHook elements which have been destroyed
180 	 *         should be skipped
181 	 *     func = the function to find
182 	 *
183 	 * Return: the #GHook with the given @func or %NULL if no matching
184 	 *     #GHook is found
185 	 */
186 	public static Hook findFunc(HookList hookList, bool needValids, void* func)
187 	{
188 		auto p = g_hook_find_func((hookList is null) ? null : hookList.getHookListStruct(), needValids, func);
189 		
190 		if(p is null)
191 		{
192 			return null;
193 		}
194 		
195 		return new Hook(cast(GHook*) p);
196 	}
197 
198 	/**
199 	 * Finds a #GHook in a #GHookList with the given function and data.
200 	 *
201 	 * Params:
202 	 *     hookList = a #GHookList
203 	 *     needValids = %TRUE if #GHook elements which have been destroyed
204 	 *         should be skipped
205 	 *     func = the function to find
206 	 *     data = the data to find
207 	 *
208 	 * Return: the #GHook with the given @func and @data or %NULL if
209 	 *     no matching #GHook is found
210 	 */
211 	public static Hook findFuncData(HookList hookList, bool needValids, void* func, void* data)
212 	{
213 		auto p = g_hook_find_func_data((hookList is null) ? null : hookList.getHookListStruct(), needValids, func, data);
214 		
215 		if(p is null)
216 		{
217 			return null;
218 		}
219 		
220 		return new Hook(cast(GHook*) p);
221 	}
222 
223 	/**
224 	 * Returns the first #GHook in a #GHookList which has not been destroyed.
225 	 * The reference count for the #GHook is incremented, so you must call
226 	 * g_hook_unref() to restore it when no longer needed. (Or call
227 	 * g_hook_next_valid() if you are stepping through the #GHookList.)
228 	 *
229 	 * Params:
230 	 *     hookList = a #GHookList
231 	 *     mayBeInCall = %TRUE if hooks which are currently running
232 	 *         (e.g. in another thread) are considered valid. If set to %FALSE,
233 	 *         these are skipped
234 	 *
235 	 * Return: the first valid #GHook, or %NULL if none are valid
236 	 */
237 	public static Hook firstValid(HookList hookList, bool mayBeInCall)
238 	{
239 		auto p = g_hook_first_valid((hookList is null) ? null : hookList.getHookListStruct(), mayBeInCall);
240 		
241 		if(p is null)
242 		{
243 			return null;
244 		}
245 		
246 		return new Hook(cast(GHook*) p);
247 	}
248 
249 	/**
250 	 * Calls the #GHookList @finalize_hook function if it exists,
251 	 * and frees the memory allocated for the #GHook.
252 	 *
253 	 * Params:
254 	 *     hookList = a #GHookList
255 	 *     hook = the #GHook to free
256 	 */
257 	public static void free(HookList hookList, Hook hook)
258 	{
259 		g_hook_free((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct());
260 	}
261 
262 	/**
263 	 * Returns the #GHook with the given id, or %NULL if it is not found.
264 	 *
265 	 * Params:
266 	 *     hookList = a #GHookList
267 	 *     hookId = a hook id
268 	 *
269 	 * Return: the #GHook with the given id, or %NULL if it is not found
270 	 */
271 	public static Hook get(HookList hookList, gulong hookId)
272 	{
273 		auto p = g_hook_get((hookList is null) ? null : hookList.getHookListStruct(), hookId);
274 		
275 		if(p is null)
276 		{
277 			return null;
278 		}
279 		
280 		return new Hook(cast(GHook*) p);
281 	}
282 
283 	/**
284 	 * Inserts a #GHook into a #GHookList, before a given #GHook.
285 	 *
286 	 * Params:
287 	 *     hookList = a #GHookList
288 	 *     sibling = the #GHook to insert the new #GHook before
289 	 *     hook = the #GHook to insert
290 	 */
291 	public static void insertBefore(HookList hookList, Hook sibling, Hook hook)
292 	{
293 		g_hook_insert_before((hookList is null) ? null : hookList.getHookListStruct(), (sibling is null) ? null : sibling.getHookStruct(), (hook is null) ? null : hook.getHookStruct());
294 	}
295 
296 	/**
297 	 * Inserts a #GHook into a #GHookList, sorted by the given function.
298 	 *
299 	 * Params:
300 	 *     hookList = a #GHookList
301 	 *     hook = the #GHook to insert
302 	 *     func = the comparison function used to sort the #GHook elements
303 	 */
304 	public static void insertSorted(HookList hookList, Hook hook, GHookCompareFunc func)
305 	{
306 		g_hook_insert_sorted((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct(), func);
307 	}
308 
309 	/**
310 	 * Returns the next #GHook in a #GHookList which has not been destroyed.
311 	 * The reference count for the #GHook is incremented, so you must call
312 	 * g_hook_unref() to restore it when no longer needed. (Or continue to call
313 	 * g_hook_next_valid() until %NULL is returned.)
314 	 *
315 	 * Params:
316 	 *     hookList = a #GHookList
317 	 *     hook = the current #GHook
318 	 *     mayBeInCall = %TRUE if hooks which are currently running
319 	 *         (e.g. in another thread) are considered valid. If set to %FALSE,
320 	 *         these are skipped
321 	 *
322 	 * Return: the next valid #GHook, or %NULL if none are valid
323 	 */
324 	public static Hook nextValid(HookList hookList, Hook hook, bool mayBeInCall)
325 	{
326 		auto p = g_hook_next_valid((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct(), mayBeInCall);
327 		
328 		if(p is null)
329 		{
330 			return null;
331 		}
332 		
333 		return new Hook(cast(GHook*) p);
334 	}
335 
336 	/**
337 	 * Prepends a #GHook on the start of a #GHookList.
338 	 *
339 	 * Params:
340 	 *     hookList = a #GHookList
341 	 *     hook = the #GHook to add to the start of @hook_list
342 	 */
343 	public static void prepend(HookList hookList, Hook hook)
344 	{
345 		g_hook_prepend((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct());
346 	}
347 
348 	/**
349 	 * Increments the reference count for a #GHook.
350 	 *
351 	 * Params:
352 	 *     hookList = a #GHookList
353 	 *     hook = the #GHook to increment the reference count of
354 	 *
355 	 * Return: the @hook that was passed in (since 2.6)
356 	 */
357 	public static Hook doref(HookList hookList, Hook hook)
358 	{
359 		auto p = g_hook_ref((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct());
360 		
361 		if(p is null)
362 		{
363 			return null;
364 		}
365 		
366 		return new Hook(cast(GHook*) p);
367 	}
368 
369 	/**
370 	 * Decrements the reference count of a #GHook.
371 	 * If the reference count falls to 0, the #GHook is removed
372 	 * from the #GHookList and g_hook_free() is called to free it.
373 	 *
374 	 * Params:
375 	 *     hookList = a #GHookList
376 	 *     hook = the #GHook to unref
377 	 */
378 	public static void unref(HookList hookList, Hook hook)
379 	{
380 		g_hook_unref((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct());
381 	}
382 }