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