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 
71 public import glib.Str;
72 public import glib.ErrorG;
73 public import glib.GException;
74 public import gobject.ObjectG;
75 public import gio.AsyncResultIF;
76 public import gio.Cancellable;
77 
78 
79 
80 
81 /**
82  * This is the asynchronous version of GInitable; it behaves the same
83  * in all ways except that initialization is asynchronous. For more details
84  * see the descriptions on GInitable.
85  *
86  * A class may implement both the GInitable and GAsyncInitable interfaces.
87  *
88  * Users of objects implementing this are not intended to use the interface
89  * method directly; instead it will be used automatically in various ways.
90  * For C applications you generally just call g_async_initable_new_async()
91  * directly, or indirectly via a foo_thing_new_async() wrapper. This will call
92  * g_async_initable_init_async() under the cover, calling back with NULL and
93  * a set GError on failure.
94  *
95  * A typical implementation might look something like this:
96  *
97  * $(DDOC_COMMENT example)
98  */
99 public template AsyncInitableT(TStruct)
100 {
101 	
102 	/** the main Gtk struct */
103 	protected GAsyncInitable* gAsyncInitable;
104 	
105 	
106 	public GAsyncInitable* getAsyncInitableTStruct()
107 	{
108 		return cast(GAsyncInitable*)getStruct();
109 	}
110 	
111 	
112 	/**
113 	 */
114 	
115 	/**
116 	 * Starts asynchronous initialization of the object implementing the
117 	 * interface. This must be done before any real use of the object after
118 	 * initial construction. If the object also implements GInitable you can
119 	 * optionally call g_initable_init() instead.
120 	 * When the initialization is finished, callback will be called. You can
121 	 * then call g_async_initable_init_finish() to get the result of the
122 	 * initialization.
123 	 * Implementations may also support cancellation. If cancellable is not
124 	 * NULL, then initialization can be cancelled by triggering the cancellable
125 	 * object from another thread. If the operation was cancelled, the error
126 	 * G_IO_ERROR_CANCELLED will be returned. If cancellable is not NULL, and
127 	 * the object doesn't support cancellable initialization, the error
128 	 * G_IO_ERROR_NOT_SUPPORTED will be returned.
129 	 * As with GInitable, if the object is not initialized, or initialization
130 	 * Since 2.22
131 	 * Params:
132 	 * ioPriority = the I/O priority
133 	 * of the operation.
134 	 * cancellable = optional GCancellable object, NULL to ignore.
135 	 * callback = a GAsyncReadyCallback to call when the request is satisfied
136 	 * userData = the data to pass to callback function
137 	 * 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.
138 	 */
139 	public void gAsyncInitableInitAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
140 	{
141 		// void g_async_initable_init_async (GAsyncInitable *initable,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
142 		g_async_initable_init_async(getAsyncInitableTStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
143 	}
144 	
145 	/**
146 	 * Finishes asynchronous initialization and returns the result.
147 	 * See g_async_initable_init_async().
148 	 * Since 2.22
149 	 * Params:
150 	 * res = a GAsyncResult.
151 	 * Returns: TRUE if successful. If an error has occurred, this function will return FALSE and set error appropriately if present.
152 	 * Throws: GException on failure.
153 	 */
154 	public int gAsyncInitableInitFinish(AsyncResultIF res)
155 	{
156 		// gboolean g_async_initable_init_finish (GAsyncInitable *initable,  GAsyncResult *res,  GError **error);
157 		GError* err = null;
158 		
159 		auto p = g_async_initable_init_finish(getAsyncInitableTStruct(), (res is null) ? null : res.getAsyncResultTStruct(), &err);
160 		
161 		if (err !is null)
162 		{
163 			throw new GException( new ErrorG(err) );
164 		}
165 		
166 		return p;
167 	}
168 	
169 	/**
170 	 * Finishes the async construction for the various g_async_initable_new
171 	 * calls, returning the created object or NULL on error.
172 	 * Since 2.22
173 	 * Params:
174 	 * res = the GAsyncResult from the callback
175 	 * Returns: a newly created GObject, or NULL on error. Free with g_object_unref(). [type GObject.Object][transfer full]
176 	 * Throws: GException on failure.
177 	 */
178 	public ObjectG gAsyncInitableNewFinish(AsyncResultIF res)
179 	{
180 		// GObject * g_async_initable_new_finish (GAsyncInitable *initable,  GAsyncResult *res,  GError **error);
181 		GError* err = null;
182 		
183 		auto p = g_async_initable_new_finish(getAsyncInitableTStruct(), (res is null) ? null : res.getAsyncResultTStruct(), &err);
184 		
185 		if (err !is null)
186 		{
187 			throw new GException( new ErrorG(err) );
188 		}
189 		
190 		
191 		if(p is null)
192 		{
193 			return null;
194 		}
195 		
196 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
197 	}
198 	
199 	/**
200 	 * Helper function for constructing GAsyncInitable object. This is
201 	 * similar to g_object_new_valist() but also initializes the object
202 	 * asynchronously.
203 	 * When the initialization is finished, callback will be called. You can
204 	 * then call g_async_initable_new_finish() to get the new object and check
205 	 * for any errors.
206 	 * Since 2.22
207 	 * Params:
208 	 * objectType = a GType supporting GAsyncInitable.
209 	 * firstPropertyName = the name of the first property, followed by
210 	 * the value, and other property value pairs, and ended by NULL.
211 	 * varArgs = The var args list generated from first_property_name.
212 	 * ioPriority = the I/O priority
213 	 * of the operation.
214 	 * cancellable = optional GCancellable object, NULL to ignore.
215 	 * callback = a GAsyncReadyCallback to call when the initialization is
216 	 * finished
217 	 * userData = the data to pass to callback function
218 	 */
219 	public static void gAsyncInitableNewValistAsync(GType objectType, string firstPropertyName, void* varArgs, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
220 	{
221 		// 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);
222 		g_async_initable_new_valist_async(objectType, Str.toStringz(firstPropertyName), varArgs, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
223 	}
224 	
225 	/**
226 	 * Helper function for constructing GAsyncInitable object. This is
227 	 * similar to g_object_newv() but also initializes the object asynchronously.
228 	 * When the initialization is finished, callback will be called. You can
229 	 * then call g_async_initable_new_finish() to get the new object and check
230 	 * for any errors.
231 	 * Since 2.22
232 	 * Params:
233 	 * objectType = a GType supporting GAsyncInitable.
234 	 * parameters = the parameters to use to construct the object
235 	 * ioPriority = the I/O priority
236 	 * of the operation.
237 	 * cancellable = optional GCancellable object, NULL to ignore.
238 	 * callback = a GAsyncReadyCallback to call when the initialization is
239 	 * finished
240 	 * userData = the data to pass to callback function
241 	 */
242 	public static void gAsyncInitableNewvAsync(GType objectType, GParameter[] parameters, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
243 	{
244 		// void g_async_initable_newv_async (GType object_type,  guint n_parameters,  GParameter *parameters,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
245 		g_async_initable_newv_async(objectType, cast(int) parameters.length, parameters.ptr, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
246 	}
247 }