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