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 gio.InitableIF; 26 27 private import gio.Cancellable; 28 private import gio.c.functions; 29 public import gio.c.types; 30 private import glib.ConstructionException; 31 private import glib.ErrorG; 32 private import glib.GException; 33 private import glib.Str; 34 private import gobject.ObjectG; 35 36 37 /** 38 * #GInitable is implemented by objects that can fail during 39 * initialization. If an object implements this interface then 40 * it must be initialized as the first thing after construction, 41 * either via g_initable_init() or g_async_initable_init_async() 42 * (the latter is only available if it also implements #GAsyncInitable). 43 * 44 * If the object is not initialized, or initialization returns with an 45 * error, then all operations on the object except g_object_ref() and 46 * g_object_unref() are considered to be invalid, and have undefined 47 * behaviour. They will often fail with g_critical() or g_warning(), but 48 * this must not be relied on. 49 * 50 * Users of objects implementing this are not intended to use 51 * the interface method directly, instead it will be used automatically 52 * in various ways. For C applications you generally just call 53 * g_initable_new() directly, or indirectly via a foo_thing_new() wrapper. 54 * This will call g_initable_init() under the cover, returning %NULL and 55 * setting a #GError on failure (at which point the instance is 56 * unreferenced). 57 * 58 * For bindings in languages where the native constructor supports 59 * exceptions the binding could check for objects implementing %GInitable 60 * during normal construction and automatically initialize them, throwing 61 * an exception on failure. 62 * 63 * Since: 2.22 64 */ 65 public interface InitableIF{ 66 /** Get the main Gtk struct */ 67 public GInitable* getInitableStruct(bool transferOwnership = false); 68 69 /** the main Gtk struct as a void* */ 70 protected void* getStruct(); 71 72 73 /** */ 74 public static GType getType() 75 { 76 return g_initable_get_type(); 77 } 78 79 /** 80 * Initializes the object implementing the interface. 81 * 82 * This method is intended for language bindings. If writing in C, 83 * g_initable_new() should typically be used instead. 84 * 85 * The object must be initialized before any real use after initial 86 * construction, either with this function or g_async_initable_init_async(). 87 * 88 * Implementations may also support cancellation. If @cancellable is not %NULL, 89 * then initialization can be cancelled by triggering the cancellable object 90 * from another thread. If the operation was cancelled, the error 91 * %G_IO_ERROR_CANCELLED will be returned. If @cancellable is not %NULL and 92 * the object doesn't support cancellable initialization the error 93 * %G_IO_ERROR_NOT_SUPPORTED will be returned. 94 * 95 * If the object is not initialized, or initialization returns with an 96 * error, then all operations on the object except g_object_ref() and 97 * g_object_unref() are considered to be invalid, and have undefined 98 * behaviour. See the [introduction][ginitable] for more details. 99 * 100 * Callers should not assume that a class which implements #GInitable can be 101 * initialized multiple times, unless the class explicitly documents itself as 102 * supporting this. Generally, a class’ implementation of init() can assume 103 * (and assert) that it will only be called once. Previously, this documentation 104 * recommended all #GInitable implementations should be idempotent; that 105 * recommendation was relaxed in GLib 2.54. 106 * 107 * If a class explicitly supports being initialized multiple times, it is 108 * recommended that the method is idempotent: multiple calls with the same 109 * arguments should return the same results. Only the first call initializes 110 * the object; further calls return the result of the first call. 111 * 112 * One reason why a class might need to support idempotent initialization is if 113 * it is designed to be used via the singleton pattern, with a 114 * #GObjectClass.constructor that sometimes returns an existing instance. 115 * In this pattern, a caller would expect to be able to call g_initable_init() 116 * on the result of g_object_new(), regardless of whether it is in fact a new 117 * instance. 118 * 119 * Params: 120 * cancellable = optional #GCancellable object, %NULL to ignore. 121 * 122 * Returns: %TRUE if successful. If an error has occurred, this function will 123 * return %FALSE and set @error appropriately if present. 124 * 125 * Since: 2.22 126 * 127 * Throws: GException on failure. 128 */ 129 public bool init(Cancellable cancellable); 130 }