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