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 glib.MemorySlice; 29 private import glib.c.functions; 30 public import glib.c.types; 31 private import gtkd.Loader; 32 33 34 /** 35 * The #GHook struct represents a single hook function in a #GHookList. 36 */ 37 public final class Hook 38 { 39 /** the main Gtk struct */ 40 protected GHook* gHook; 41 protected bool ownedRef; 42 43 /** Get the main Gtk struct */ 44 public GHook* getHookStruct(bool transferOwnership = false) 45 { 46 if (transferOwnership) 47 ownedRef = false; 48 return gHook; 49 } 50 51 /** the main Gtk struct as a void* */ 52 protected void* getStruct() 53 { 54 return cast(void*)gHook; 55 } 56 57 /** 58 * Sets our main struct and passes it to the parent class. 59 */ 60 public this (GHook* gHook, bool ownedRef = false) 61 { 62 this.gHook = gHook; 63 this.ownedRef = ownedRef; 64 } 65 66 ~this () 67 { 68 if ( Linker.isLoaded(LIBRARY_GLIB) && ownedRef ) 69 sliceFree(gHook); 70 } 71 72 73 /** 74 * data which is passed to func when this hook is invoked 75 */ 76 public @property void* data() 77 { 78 return gHook.data; 79 } 80 81 /** Ditto */ 82 public @property void data(void* value) 83 { 84 gHook.data = value; 85 } 86 87 /** 88 * pointer to the next hook in the list 89 */ 90 public @property Hook next() 91 { 92 return new Hook(gHook.next, false); 93 } 94 95 /** Ditto */ 96 public @property void next(Hook value) 97 { 98 gHook.next = value.getHookStruct(); 99 } 100 101 /** 102 * pointer to the previous hook in the list 103 */ 104 public @property Hook prev() 105 { 106 return new Hook(gHook.prev, false); 107 } 108 109 /** Ditto */ 110 public @property void prev(Hook value) 111 { 112 gHook.prev = value.getHookStruct(); 113 } 114 115 /** 116 * the reference count of this hook 117 */ 118 public @property uint refCount() 119 { 120 return gHook.refCount; 121 } 122 123 /** Ditto */ 124 public @property void refCount(uint value) 125 { 126 gHook.refCount = value; 127 } 128 129 /** 130 * the id of this hook, which is unique within its list 131 */ 132 public @property gulong hookId() 133 { 134 return gHook.hookId; 135 } 136 137 /** Ditto */ 138 public @property void hookId(gulong value) 139 { 140 gHook.hookId = value; 141 } 142 143 /** 144 * flags which are set for this hook. See #GHookFlagMask for 145 * predefined flags 146 */ 147 public @property uint flags() 148 { 149 return gHook.flags; 150 } 151 152 /** Ditto */ 153 public @property void flags(uint value) 154 { 155 gHook.flags = value; 156 } 157 158 /** 159 * the function to call when this hook is invoked. The possible 160 * signatures for this function are #GHookFunc and #GHookCheckFunc 161 */ 162 public @property void* func() 163 { 164 return gHook.func; 165 } 166 167 /** Ditto */ 168 public @property void func(void* value) 169 { 170 gHook.func = value; 171 } 172 173 /** 174 * the default @finalize_hook function of a #GHookList calls 175 * this member of the hook that is being finalized 176 */ 177 public @property GDestroyNotify destroy() 178 { 179 return gHook.destroy; 180 } 181 182 /** Ditto */ 183 public @property void destroy(GDestroyNotify value) 184 { 185 gHook.destroy = value; 186 } 187 188 /** 189 * Compares the ids of two #GHook elements, returning a negative value 190 * if the second id is greater than the first. 191 * 192 * Params: 193 * sibling = a #GHook to compare with @new_hook 194 * 195 * Returns: a value <= 0 if the id of @sibling is >= the id of @new_hook 196 */ 197 public int compareIds(Hook sibling) 198 { 199 return g_hook_compare_ids(gHook, (sibling is null) ? null : sibling.getHookStruct()); 200 } 201 202 /** 203 * Allocates space for a #GHook and initializes it. 204 * 205 * Params: 206 * hookList = a #GHookList 207 * 208 * Returns: a new #GHook 209 */ 210 public static Hook alloc(HookList hookList) 211 { 212 auto __p = g_hook_alloc((hookList is null) ? null : hookList.getHookListStruct()); 213 214 if(__p is null) 215 { 216 return null; 217 } 218 219 return new Hook(cast(GHook*) __p); 220 } 221 222 /** 223 * Destroys a #GHook, given its ID. 224 * 225 * Params: 226 * hookList = a #GHookList 227 * hookId = a hook ID 228 * 229 * Returns: %TRUE if the #GHook was found in the #GHookList and destroyed 230 */ 231 public static bool destroy(HookList hookList, gulong hookId) 232 { 233 return g_hook_destroy((hookList is null) ? null : hookList.getHookListStruct(), hookId) != 0; 234 } 235 236 /** 237 * Removes one #GHook from a #GHookList, marking it 238 * inactive and calling g_hook_unref() on it. 239 * 240 * Params: 241 * hookList = a #GHookList 242 * hook = the #GHook to remove 243 */ 244 public static void destroyLink(HookList hookList, Hook hook) 245 { 246 g_hook_destroy_link((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct()); 247 } 248 249 /** 250 * Finds a #GHook in a #GHookList using the given function to 251 * test for a match. 252 * 253 * Params: 254 * hookList = a #GHookList 255 * needValids = %TRUE if #GHook elements which have been destroyed 256 * should be skipped 257 * func = the function to call for each #GHook, which should return 258 * %TRUE when the #GHook has been found 259 * data = the data to pass to @func 260 * 261 * Returns: the found #GHook or %NULL if no matching #GHook is found 262 */ 263 public static Hook find(HookList hookList, bool needValids, GHookFindFunc func, void* data) 264 { 265 auto __p = g_hook_find((hookList is null) ? null : hookList.getHookListStruct(), needValids, func, data); 266 267 if(__p is null) 268 { 269 return null; 270 } 271 272 return new Hook(cast(GHook*) __p); 273 } 274 275 /** 276 * Finds a #GHook in a #GHookList with the given data. 277 * 278 * Params: 279 * hookList = a #GHookList 280 * needValids = %TRUE if #GHook elements which have been destroyed 281 * should be skipped 282 * data = the data to find 283 * 284 * Returns: the #GHook with the given @data or %NULL if no matching 285 * #GHook is found 286 */ 287 public static Hook findData(HookList hookList, bool needValids, void* data) 288 { 289 auto __p = g_hook_find_data((hookList is null) ? null : hookList.getHookListStruct(), needValids, data); 290 291 if(__p is null) 292 { 293 return null; 294 } 295 296 return new Hook(cast(GHook*) __p); 297 } 298 299 /** 300 * Finds a #GHook in a #GHookList with the given function. 301 * 302 * Params: 303 * hookList = a #GHookList 304 * needValids = %TRUE if #GHook elements which have been destroyed 305 * should be skipped 306 * func = the function to find 307 * 308 * Returns: the #GHook with the given @func or %NULL if no matching 309 * #GHook is found 310 */ 311 public static Hook findFunc(HookList hookList, bool needValids, void* func) 312 { 313 auto __p = g_hook_find_func((hookList is null) ? null : hookList.getHookListStruct(), needValids, func); 314 315 if(__p is null) 316 { 317 return null; 318 } 319 320 return new Hook(cast(GHook*) __p); 321 } 322 323 /** 324 * Finds a #GHook in a #GHookList with the given function and data. 325 * 326 * Params: 327 * hookList = a #GHookList 328 * needValids = %TRUE if #GHook elements which have been destroyed 329 * should be skipped 330 * func = the function to find 331 * data = the data to find 332 * 333 * Returns: the #GHook with the given @func and @data or %NULL if 334 * no matching #GHook is found 335 */ 336 public static Hook findFuncData(HookList hookList, bool needValids, void* func, void* data) 337 { 338 auto __p = g_hook_find_func_data((hookList is null) ? null : hookList.getHookListStruct(), needValids, func, data); 339 340 if(__p is null) 341 { 342 return null; 343 } 344 345 return new Hook(cast(GHook*) __p); 346 } 347 348 /** 349 * Returns the first #GHook in a #GHookList which has not been destroyed. 350 * The reference count for the #GHook is incremented, so you must call 351 * g_hook_unref() to restore it when no longer needed. (Or call 352 * g_hook_next_valid() if you are stepping through the #GHookList.) 353 * 354 * Params: 355 * hookList = a #GHookList 356 * mayBeInCall = %TRUE if hooks which are currently running 357 * (e.g. in another thread) are considered valid. If set to %FALSE, 358 * these are skipped 359 * 360 * Returns: the first valid #GHook, or %NULL if none are valid 361 */ 362 public static Hook firstValid(HookList hookList, bool mayBeInCall) 363 { 364 auto __p = g_hook_first_valid((hookList is null) ? null : hookList.getHookListStruct(), mayBeInCall); 365 366 if(__p is null) 367 { 368 return null; 369 } 370 371 return new Hook(cast(GHook*) __p); 372 } 373 374 /** 375 * Calls the #GHookList @finalize_hook function if it exists, 376 * and frees the memory allocated for the #GHook. 377 * 378 * Params: 379 * hookList = a #GHookList 380 * hook = the #GHook to free 381 */ 382 public static void free(HookList hookList, Hook hook) 383 { 384 g_hook_free((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct()); 385 } 386 387 /** 388 * Returns the #GHook with the given id, or %NULL if it is not found. 389 * 390 * Params: 391 * hookList = a #GHookList 392 * hookId = a hook id 393 * 394 * Returns: the #GHook with the given id, or %NULL if it is not found 395 */ 396 public static Hook get(HookList hookList, gulong hookId) 397 { 398 auto __p = g_hook_get((hookList is null) ? null : hookList.getHookListStruct(), hookId); 399 400 if(__p is null) 401 { 402 return null; 403 } 404 405 return new Hook(cast(GHook*) __p); 406 } 407 408 /** 409 * Inserts a #GHook into a #GHookList, before a given #GHook. 410 * 411 * Params: 412 * hookList = a #GHookList 413 * sibling = the #GHook to insert the new #GHook before 414 * hook = the #GHook to insert 415 */ 416 public static void insertBefore(HookList hookList, Hook sibling, Hook hook) 417 { 418 g_hook_insert_before((hookList is null) ? null : hookList.getHookListStruct(), (sibling is null) ? null : sibling.getHookStruct(), (hook is null) ? null : hook.getHookStruct()); 419 } 420 421 /** 422 * Inserts a #GHook into a #GHookList, sorted by the given function. 423 * 424 * Params: 425 * hookList = a #GHookList 426 * hook = the #GHook to insert 427 * func = the comparison function used to sort the #GHook elements 428 */ 429 public static void insertSorted(HookList hookList, Hook hook, GHookCompareFunc func) 430 { 431 g_hook_insert_sorted((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct(), func); 432 } 433 434 /** 435 * Returns the next #GHook in a #GHookList which has not been destroyed. 436 * The reference count for the #GHook is incremented, so you must call 437 * g_hook_unref() to restore it when no longer needed. (Or continue to call 438 * g_hook_next_valid() until %NULL is returned.) 439 * 440 * Params: 441 * hookList = a #GHookList 442 * hook = the current #GHook 443 * mayBeInCall = %TRUE if hooks which are currently running 444 * (e.g. in another thread) are considered valid. If set to %FALSE, 445 * these are skipped 446 * 447 * Returns: the next valid #GHook, or %NULL if none are valid 448 */ 449 public static Hook nextValid(HookList hookList, Hook hook, bool mayBeInCall) 450 { 451 auto __p = g_hook_next_valid((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct(), mayBeInCall); 452 453 if(__p is null) 454 { 455 return null; 456 } 457 458 return new Hook(cast(GHook*) __p); 459 } 460 461 /** 462 * Prepends a #GHook on the start of a #GHookList. 463 * 464 * Params: 465 * hookList = a #GHookList 466 * hook = the #GHook to add to the start of @hook_list 467 */ 468 public static void prepend(HookList hookList, Hook hook) 469 { 470 g_hook_prepend((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct()); 471 } 472 473 alias doref = ref_; 474 /** 475 * Increments the reference count for a #GHook. 476 * 477 * Params: 478 * hookList = a #GHookList 479 * hook = the #GHook to increment the reference count of 480 * 481 * Returns: the @hook that was passed in (since 2.6) 482 */ 483 public static Hook ref_(HookList hookList, Hook hook) 484 { 485 auto __p = g_hook_ref((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct()); 486 487 if(__p is null) 488 { 489 return null; 490 } 491 492 return new Hook(cast(GHook*) __p); 493 } 494 495 /** 496 * Decrements the reference count of a #GHook. 497 * If the reference count falls to 0, the #GHook is removed 498 * from the #GHookList and g_hook_free() is called to free it. 499 * 500 * Params: 501 * hookList = a #GHookList 502 * hook = the #GHook to unref 503 */ 504 public static void unref(HookList hookList, Hook hook) 505 { 506 g_hook_unref((hookList is null) ? null : hookList.getHookListStruct(), (hook is null) ? null : hook.getHookStruct()); 507 } 508 }