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  * Conversion parameters:
26  * inFile  = GAsyncInitable.html
27  * outPack = gio
28  * outFile = AsyncInitableT
29  * strct   = GAsyncInitable
30  * realStrct=
31  * ctorStrct=
32  * clss    = AsyncInitableT
33  * interf  = AsyncInitableIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- g_initable_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.ErrorG
49  * 	- glib.GException
50  * 	- gobject.ObjectG
51  * 	- gio.AsyncResultIF
52  * 	- gio.Cancellable
53  * structWrap:
54  * 	- GAsyncResult* -> AsyncResultIF
55  * 	- GCancellable* -> Cancellable
56  * 	- GObject* -> ObjectG
57  * module aliases:
58  * local aliases:
59  * overrides:
60  */
61 
62 module gio.AsyncInitableT;
63 
64 public  import gtkc.giotypes;
65 
66 public import gtkc.gio;
67 public import glib.ConstructionException;
68 public import gobject.ObjectG;
69 
70 public import glib.Str;
71 public import glib.ErrorG;
72 public import glib.GException;
73 public import gobject.ObjectG;
74 public import gio.AsyncResultIF;
75 public import gio.Cancellable;
76 
77 
78 
79 /**
80  * This is the asynchronous version of GInitable; it behaves the same
81  * in all ways except that initialization is asynchronous. For more details
82  * see the descriptions on GInitable.
83  *
84  * A class may implement both the GInitable and GAsyncInitable interfaces.
85  *
86  * Users of objects implementing this are not intended to use the interface
87  * method directly; instead it will be used automatically in various ways.
88  * For C applications you generally just call g_async_initable_new_async()
89  * directly, or indirectly via a foo_thing_new_async() wrapper. This will call
90  * g_async_initable_init_async() under the cover, calling back with NULL and
91  * a set GError on failure.
92  *
93  * A typical implementation might look something like this:
94  *
95  * $(DDOC_COMMENT example)
96  */
97 public template AsyncInitableT(TStruct)
98 {
99 	
100 	/** the main Gtk struct */
101 	protected GAsyncInitable* gAsyncInitable;
102 	
103 	
104 	/** Get the main Gtk struct */
105 	public GAsyncInitable* getAsyncInitableTStruct()
106 	{
107 		return cast(GAsyncInitable*)getStruct();
108 	}
109 	
110 	
111 	/**
112 	 */
113 	
114 	/**
115 	 * Starts asynchronous initialization of the object implementing the
116 	 * interface. This must be done before any real use of the object after
117 	 * initial construction. If the object also implements GInitable you can
118 	 * optionally call g_initable_init() instead.
119 	 * When the initialization is finished, callback will be called. You can
120 	 * then call g_async_initable_init_finish() to get the result of the
121 	 * initialization.
122 	 * Implementations may also support cancellation. If cancellable is not
123 	 * NULL, then initialization can be cancelled by triggering the cancellable
124 	 * object from another thread. If the operation was cancelled, the error
125 	 * G_IO_ERROR_CANCELLED will be returned. If cancellable is not NULL, and
126 	 * the object doesn't support cancellable initialization, the error
127 	 * G_IO_ERROR_NOT_SUPPORTED will be returned.
128 	 * As with GInitable, if the object is not initialized, or initialization
129 	 * Since 2.22
130 	 * Params:
131 	 * ioPriority = the I/O priority
132 	 * of the operation.
133 	 * cancellable = optional GCancellable object, NULL to ignore.
134 	 * callback = a GAsyncReadyCallback to call when the request is satisfied
135 	 * userData = the data to pass to callback function
136 	 * Returns: with an error, then all operations on the object except g_object_ref() and g_object_unref() are considered to be invalid, and have undefined behaviour. They will often fail with g_critical() or g_warning(), but this must not be relied on. Implementations of this method must be idempotent: i.e. multiple calls to this function with the same argument should return the same results. Only the first call initializes the object; further calls return the result of the first call. This is so that it's safe to implement the singleton pattern in the GObject constructor function. For classes that also support the GInitable interface, the default implementation of this method will run the g_initable_init() function in a thread, so if you want to support asynchronous initialization via threads, just implement the GAsyncInitable interface without overriding any interface methods.
137 	 */
138 	public void gAsyncInitableInitAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
139 	{
140 		// void g_async_initable_init_async (GAsyncInitable *initable,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
141 		g_async_initable_init_async(getAsyncInitableTStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
142 	}
143 	
144 	/**
145 	 * Finishes asynchronous initialization and returns the result.
146 	 * See g_async_initable_init_async().
147 	 * Since 2.22
148 	 * Params:
149 	 * res = a GAsyncResult.
150 	 * Returns: TRUE if successful. If an error has occurred, this function will return FALSE and set error appropriately if present.
151 	 * Throws: GException on failure.
152 	 */
153 	public int gAsyncInitableInitFinish(AsyncResultIF res)
154 	{
155 		// gboolean g_async_initable_init_finish (GAsyncInitable *initable,  GAsyncResult *res,  GError **error);
156 		GError* err = null;
157 		
158 		auto p = g_async_initable_init_finish(getAsyncInitableTStruct(), (res is null) ? null : res.getAsyncResultTStruct(), &err);
159 		
160 		if (err !is null)
161 		{
162 			throw new GException( new ErrorG(err) );
163 		}
164 		
165 		return p;
166 	}
167 	
168 	/**
169 	 * Finishes the async construction for the various g_async_initable_new
170 	 * calls, returning the created object or NULL on error.
171 	 * Since 2.22
172 	 * Params:
173 	 * res = the GAsyncResult from the callback
174 	 * Returns: a newly created GObject, or NULL on error. Free with g_object_unref(). [type GObject.Object][transfer full]
175 	 * Throws: GException on failure.
176 	 */
177 	public ObjectG gAsyncInitableNewFinish(AsyncResultIF res)
178 	{
179 		// GObject * g_async_initable_new_finish (GAsyncInitable *initable,  GAsyncResult *res,  GError **error);
180 		GError* err = null;
181 		
182 		auto p = g_async_initable_new_finish(getAsyncInitableTStruct(), (res is null) ? null : res.getAsyncResultTStruct(), &err);
183 		
184 		if (err !is null)
185 		{
186 			throw new GException( new ErrorG(err) );
187 		}
188 		
189 		
190 		if(p is null)
191 		{
192 			return null;
193 		}
194 		
195 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
196 	}
197 	
198 	/**
199 	 * Helper function for constructing GAsyncInitable object. This is
200 	 * similar to g_object_new_valist() but also initializes the object
201 	 * asynchronously.
202 	 * When the initialization is finished, callback will be called. You can
203 	 * then call g_async_initable_new_finish() to get the new object and check
204 	 * for any errors.
205 	 * Since 2.22
206 	 * Params:
207 	 * objectType = a GType supporting GAsyncInitable.
208 	 * firstPropertyName = the name of the first property, followed by
209 	 * the value, and other property value pairs, and ended by NULL.
210 	 * varArgs = The var args list generated from first_property_name.
211 	 * ioPriority = the I/O priority
212 	 * of the operation.
213 	 * cancellable = optional GCancellable object, NULL to ignore.
214 	 * callback = a GAsyncReadyCallback to call when the initialization is
215 	 * finished
216 	 * userData = the data to pass to callback function
217 	 */
218 	public static void gAsyncInitableNewValistAsync(GType objectType, string firstPropertyName, void* varArgs, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
219 	{
220 		// void g_async_initable_new_valist_async (GType object_type,  const gchar *first_property_name,  va_list var_args,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
221 		g_async_initable_new_valist_async(objectType, Str.toStringz(firstPropertyName), varArgs, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
222 	}
223 	
224 	/**
225 	 * Helper function for constructing GAsyncInitable object. This is
226 	 * similar to g_object_newv() but also initializes the object asynchronously.
227 	 * When the initialization is finished, callback will be called. You can
228 	 * then call g_async_initable_new_finish() to get the new object and check
229 	 * for any errors.
230 	 * Since 2.22
231 	 * Params:
232 	 * objectType = a GType supporting GAsyncInitable.
233 	 * parameters = the parameters to use to construct the object
234 	 * ioPriority = the I/O priority
235 	 * of the operation.
236 	 * cancellable = optional GCancellable object, NULL to ignore.
237 	 * callback = a GAsyncReadyCallback to call when the initialization is
238 	 * finished
239 	 * userData = the data to pass to callback function
240 	 */
241 	public static void gAsyncInitableNewvAsync(GType objectType, GParameter[] parameters, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
242 	{
243 		// void g_async_initable_newv_async (GType object_type,  guint n_parameters,  GParameter *parameters,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
244 		g_async_initable_newv_async(objectType, cast(int) parameters.length, parameters.ptr, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
245 	}
246 }