| 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 = GSimpleAsyncResult.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = SimpleAsyncResult |
|---|
| 29 |
* strct = GSimpleAsyncResult |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = SimpleAsyncResult |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: Yes |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = |
|---|
| 38 |
* implements: |
|---|
| 39 |
* - AsyncResultIF |
|---|
| 40 |
* prefixes: |
|---|
| 41 |
* - g_simple_async_result_ |
|---|
| 42 |
* - g_ |
|---|
| 43 |
* omit structs: |
|---|
| 44 |
* omit prefixes: |
|---|
| 45 |
* omit code: |
|---|
| 46 |
* omit signals: |
|---|
| 47 |
* imports: |
|---|
| 48 |
* - glib.Str |
|---|
| 49 |
* - glib.ErrorG |
|---|
| 50 |
* - glib.GException |
|---|
| 51 |
* - gobject.ObjectG |
|---|
| 52 |
* - gio.Cancellable |
|---|
| 53 |
* - gio.AsyncResultIF |
|---|
| 54 |
* - gio.AsyncResultT |
|---|
| 55 |
* structWrap: |
|---|
| 56 |
* - GCancellable* -> Cancellable |
|---|
| 57 |
* - GError* -> ErrorG |
|---|
| 58 |
* - GObject* -> ObjectG |
|---|
| 59 |
* module aliases: |
|---|
| 60 |
* local aliases: |
|---|
| 61 |
* overrides: |
|---|
| 62 |
*/ |
|---|
| 63 |
|
|---|
| 64 |
module gio.SimpleAsyncResult; |
|---|
| 65 |
|
|---|
| 66 |
public import gtkc.giotypes; |
|---|
| 67 |
|
|---|
| 68 |
private import gtkc.gio; |
|---|
| 69 |
private import glib.ConstructionException; |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
private import glib.Str; |
|---|
| 73 |
private import glib.ErrorG; |
|---|
| 74 |
private import glib.GException; |
|---|
| 75 |
private import gobject.ObjectG; |
|---|
| 76 |
private import gio.Cancellable; |
|---|
| 77 |
private import gio.AsyncResultIF; |
|---|
| 78 |
private import gio.AsyncResultT; |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
private import gobject.ObjectG; |
|---|
| 83 |
|
|---|
| 84 |
/** |
|---|
| 85 |
* Description |
|---|
| 86 |
* Implements GAsyncResult for simple cases. Most of the time, this |
|---|
| 87 |
* will be all an application needs, and will be used transparently. |
|---|
| 88 |
* Because of this, GSimpleAsyncResult is used throughout GIO for |
|---|
| 89 |
* handling asynchronous functions. |
|---|
| 90 |
* GSimpleAsyncResult handles GAsyncReadyCallbacks, error |
|---|
| 91 |
* reporting, operation cancellation and the final state of an operation, |
|---|
| 92 |
* completely transparent to the application. Results can be returned |
|---|
| 93 |
* as a pointer e.g. for functions that return data that is collected |
|---|
| 94 |
* asynchronously, a boolean value for checking the success or failure |
|---|
| 95 |
* of an operation, or a gssize for operations which return the number |
|---|
| 96 |
* of bytes modified by the operation; all of the simple return cases |
|---|
| 97 |
* are covered. |
|---|
| 98 |
* Most of the time, an application will not need to know of the details |
|---|
| 99 |
* of this API; it is handled transparently, and any necessary operations |
|---|
| 100 |
* are handled by GAsyncResult's interface. However, if implementing a |
|---|
| 101 |
* new GIO module, for writing language bindings, or for complex |
|---|
| 102 |
* applications that need better control of how asynchronous operations |
|---|
| 103 |
* are completed, it is important to understand this functionality. |
|---|
| 104 |
* GSimpleAsyncResults are tagged with the calling function to ensure |
|---|
| 105 |
* that asynchronous functions and their finishing functions are used |
|---|
| 106 |
* together correctly. |
|---|
| 107 |
* To create a new GSimpleAsyncResult, call g_simple_async_result_new(). |
|---|
| 108 |
* If the result needs to be created for a GError, use |
|---|
| 109 |
* g_simple_async_result_new_from_error() or |
|---|
| 110 |
* g_simple_async_result_new_take_error(). If a GError is not available |
|---|
| 111 |
* (e.g. the asynchronous operation's doesn't take a GError argument), |
|---|
| 112 |
* but the result still needs to be created for an error condition, use |
|---|
| 113 |
* g_simple_async_result_new_error() (or g_simple_async_result_set_error_va() |
|---|
| 114 |
* if your application or binding requires passing a variable argument list |
|---|
| 115 |
* directly), and the error can then be propagated through the use of |
|---|
| 116 |
* g_simple_async_result_propagate_error(). |
|---|
| 117 |
* An asynchronous operation can be made to ignore a cancellation event by |
|---|
| 118 |
* calling g_simple_async_result_set_handle_cancellation() with a |
|---|
| 119 |
* GSimpleAsyncResult for the operation and FALSE. This is useful for |
|---|
| 120 |
* operations that are dangerous to cancel, such as close (which would |
|---|
| 121 |
* cause a leak if cancelled before being run). |
|---|
| 122 |
* GSimpleAsyncResult can integrate into GLib's event loop, GMainLoop, |
|---|
| 123 |
* or it can use GThreads if available. |
|---|
| 124 |
* g_simple_async_result_complete() will finish an I/O task directly |
|---|
| 125 |
* from the point where it is called. g_simple_async_result_complete_in_idle() |
|---|
| 126 |
* will finish it from an idle handler in the thread-default main |
|---|
| 127 |
* context. g_simple_async_result_run_in_thread() will run the |
|---|
| 128 |
* job in a separate thread and then deliver the result to the |
|---|
| 129 |
* thread-default main context. |
|---|
| 130 |
* To set the results of an asynchronous function, |
|---|
| 131 |
* g_simple_async_result_set_op_res_gpointer(), |
|---|
| 132 |
* g_simple_async_result_set_op_res_gboolean(), and |
|---|
| 133 |
* g_simple_async_result_set_op_res_gssize() |
|---|
| 134 |
* are provided, setting the operation's result to a gpointer, gboolean, or |
|---|
| 135 |
* gssize, respectively. |
|---|
| 136 |
* Likewise, to get the result of an asynchronous function, |
|---|
| 137 |
* g_simple_async_result_get_op_res_gpointer(), |
|---|
| 138 |
* g_simple_async_result_get_op_res_gboolean(), and |
|---|
| 139 |
* g_simple_async_result_get_op_res_gssize() are |
|---|
| 140 |
* provided, getting the operation's result as a gpointer, gboolean, and |
|---|
| 141 |
* gssize, respectively. |
|---|
| 142 |
* For the details of the requirements implementations must respect, see |
|---|
| 143 |
* GAsyncResult. A typical implementation of an asynchronous operation |
|---|
| 144 |
* using GSimpleAsyncResult looks something like this: |
|---|
| 145 |
* $(DDOC_COMMENT example) |
|---|
| 146 |
*/ |
|---|
| 147 |
public class SimpleAsyncResult : ObjectG, AsyncResultIF |
|---|
| 148 |
{ |
|---|
| 149 |
|
|---|
| 150 |
/** the main Gtk struct */ |
|---|
| 151 |
protected GSimpleAsyncResult* gSimpleAsyncResult; |
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
public GSimpleAsyncResult* getSimpleAsyncResultStruct() |
|---|
| 155 |
{ |
|---|
| 156 |
return gSimpleAsyncResult; |
|---|
| 157 |
} |
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
/** the main Gtk struct as a void* */ |
|---|
| 161 |
protected override void* getStruct() |
|---|
| 162 |
{ |
|---|
| 163 |
return cast(void*)gSimpleAsyncResult; |
|---|
| 164 |
} |
|---|
| 165 |
|
|---|
| 166 |
/** |
|---|
| 167 |
* Sets our main struct and passes it to the parent class |
|---|
| 168 |
*/ |
|---|
| 169 |
public this (GSimpleAsyncResult* gSimpleAsyncResult) |
|---|
| 170 |
{ |
|---|
| 171 |
if(gSimpleAsyncResult is null) |
|---|
| 172 |
{ |
|---|
| 173 |
this = null; |
|---|
| 174 |
return; |
|---|
| 175 |
} |
|---|
| 176 |
//Check if there already is a D object for this gtk struct |
|---|
| 177 |
void* ptr = getDObject(cast(GObject*)gSimpleAsyncResult); |
|---|
| 178 |
if( ptr !is null ) |
|---|
| 179 |
{ |
|---|
| 180 |
this = cast(SimpleAsyncResult)ptr; |
|---|
| 181 |
return; |
|---|
| 182 |
} |
|---|
| 183 |
super(cast(GObject*)gSimpleAsyncResult); |
|---|
| 184 |
this.gSimpleAsyncResult = gSimpleAsyncResult; |
|---|
| 185 |
} |
|---|
| 186 |
|
|---|
| 187 |
protected override void setStruct(GObject* obj) |
|---|
| 188 |
{ |
|---|
| 189 |
super.setStruct(obj); |
|---|
| 190 |
gSimpleAsyncResult = cast(GSimpleAsyncResult*)obj; |
|---|
| 191 |
} |
|---|
| 192 |
|
|---|
| 193 |
// add the AsyncResult capabilities |
|---|
| 194 |
mixin AsyncResultT!(GSimpleAsyncResult); |
|---|
| 195 |
|
|---|
| 196 |
/** |
|---|
| 197 |
*/ |
|---|
| 198 |
|
|---|
| 199 |
/** |
|---|
| 200 |
* Creates a GSimpleAsyncResult. |
|---|
| 201 |
* Params: |
|---|
| 202 |
* sourceObject = a GObject, or NULL. [allow-none] |
|---|
| 203 |
* callback = a GAsyncReadyCallback. [scope async] |
|---|
| 204 |
* userData = user data passed to callback. [closure] |
|---|
| 205 |
* sourceTag = the asynchronous function. |
|---|
| 206 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 207 |
*/ |
|---|
| 208 |
public this (ObjectG sourceObject, GAsyncReadyCallback callback, void* userData, void* sourceTag) |
|---|
| 209 |
{ |
|---|
| 210 |
// GSimpleAsyncResult * g_simple_async_result_new (GObject *source_object, GAsyncReadyCallback callback, gpointer user_data, gpointer source_tag); |
|---|
| 211 |
auto p = g_simple_async_result_new((sourceObject is null) ? null : sourceObject.getObjectGStruct(), callback, userData, sourceTag); |
|---|
| 212 |
if(p is null) |
|---|
| 213 |
{ |
|---|
| 214 |
throw new ConstructionException("null returned by g_simple_async_result_new((sourceObject is null) ? null : sourceObject.getObjectGStruct(), callback, userData, sourceTag)"); |
|---|
| 215 |
} |
|---|
| 216 |
this(cast(GSimpleAsyncResult*) p); |
|---|
| 217 |
} |
|---|
| 218 |
|
|---|
| 219 |
/** |
|---|
| 220 |
* Creates a GSimpleAsyncResult from an error condition. |
|---|
| 221 |
* Params: |
|---|
| 222 |
* sourceObject = a GObject, or NULL. [allow-none] |
|---|
| 223 |
* callback = a GAsyncReadyCallback. [scope async] |
|---|
| 224 |
* userData = user data passed to callback. [closure] |
|---|
| 225 |
* error = a GError |
|---|
| 226 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 227 |
*/ |
|---|
| 228 |
public this (ObjectG sourceObject, GAsyncReadyCallback callback, void* userData, ErrorG error) |
|---|
| 229 |
{ |
|---|
| 230 |
// GSimpleAsyncResult * g_simple_async_result_new_from_error (GObject *source_object, GAsyncReadyCallback callback, gpointer user_data, const GError *error); |
|---|
| 231 |
auto p = g_simple_async_result_new_from_error((sourceObject is null) ? null : sourceObject.getObjectGStruct(), callback, userData, (error is null) ? null : error.getErrorGStruct()); |
|---|
| 232 |
if(p is null) |
|---|
| 233 |
{ |
|---|
| 234 |
throw new ConstructionException("null returned by g_simple_async_result_new_from_error((sourceObject is null) ? null : sourceObject.getObjectGStruct(), callback, userData, (error is null) ? null : error.getErrorGStruct())"); |
|---|
| 235 |
} |
|---|
| 236 |
this(cast(GSimpleAsyncResult*) p); |
|---|
| 237 |
} |
|---|
| 238 |
|
|---|
| 239 |
/** |
|---|
| 240 |
* Sets the operation result within the asynchronous result to a pointer. |
|---|
| 241 |
* Params: |
|---|
| 242 |
* opRes = a pointer result from an asynchronous function. |
|---|
| 243 |
* destroyOpRes = a GDestroyNotify function. |
|---|
| 244 |
*/ |
|---|
| 245 |
public void setOpResGpointer(void* opRes, GDestroyNotify destroyOpRes) |
|---|
| 246 |
{ |
|---|
| 247 |
// void g_simple_async_result_set_op_res_gpointer (GSimpleAsyncResult *simple, gpointer op_res, GDestroyNotify destroy_op_res); |
|---|
| 248 |
g_simple_async_result_set_op_res_gpointer(gSimpleAsyncResult, opRes, destroyOpRes); |
|---|
| 249 |
} |
|---|
| 250 |
|
|---|
| 251 |
/** |
|---|
| 252 |
* Gets a pointer result as returned by the asynchronous function. |
|---|
| 253 |
* Returns: a pointer from the result. |
|---|
| 254 |
*/ |
|---|
| 255 |
public void* getOpResGpointer() |
|---|
| 256 |
{ |
|---|
| 257 |
// gpointer g_simple_async_result_get_op_res_gpointer (GSimpleAsyncResult *simple); |
|---|
| 258 |
return g_simple_async_result_get_op_res_gpointer(gSimpleAsyncResult); |
|---|
| 259 |
} |
|---|
| 260 |
|
|---|
| 261 |
/** |
|---|
| 262 |
* Sets the operation result within the asynchronous result to |
|---|
| 263 |
* the given op_res. |
|---|
| 264 |
* Params: |
|---|
| 265 |
* opRes = a gssize. |
|---|
| 266 |
*/ |
|---|
| 267 |
public void setOpResGssize(gssize opRes) |
|---|
| 268 |
{ |
|---|
| 269 |
// void g_simple_async_result_set_op_res_gssize (GSimpleAsyncResult *simple, gssize op_res); |
|---|
| 270 |
g_simple_async_result_set_op_res_gssize(gSimpleAsyncResult, opRes); |
|---|
| 271 |
} |
|---|
| 272 |
|
|---|
| 273 |
/** |
|---|
| 274 |
* Gets a gssize from the asynchronous result. |
|---|
| 275 |
* Returns: a gssize returned from the asynchronous function. |
|---|
| 276 |
*/ |
|---|
| 277 |
public gssize getOpResGssize() |
|---|
| 278 |
{ |
|---|
| 279 |
// gssize g_simple_async_result_get_op_res_gssize (GSimpleAsyncResult *simple); |
|---|
| 280 |
return g_simple_async_result_get_op_res_gssize(gSimpleAsyncResult); |
|---|
| 281 |
} |
|---|
| 282 |
|
|---|
| 283 |
/** |
|---|
| 284 |
* Sets the operation result to a boolean within the asynchronous result. |
|---|
| 285 |
* Params: |
|---|
| 286 |
* opRes = a gboolean. |
|---|
| 287 |
*/ |
|---|
| 288 |
public void setOpResGboolean(int opRes) |
|---|
| 289 |
{ |
|---|
| 290 |
// void g_simple_async_result_set_op_res_gboolean (GSimpleAsyncResult *simple, gboolean op_res); |
|---|
| 291 |
g_simple_async_result_set_op_res_gboolean(gSimpleAsyncResult, opRes); |
|---|
| 292 |
} |
|---|
| 293 |
|
|---|
| 294 |
/** |
|---|
| 295 |
* Gets the operation result boolean from within the asynchronous result. |
|---|
| 296 |
* Returns: TRUE if the operation's result was TRUE, FALSE if the operation's result was FALSE. |
|---|
| 297 |
*/ |
|---|
| 298 |
public int getOpResGboolean() |
|---|
| 299 |
{ |
|---|
| 300 |
// gboolean g_simple_async_result_get_op_res_gboolean (GSimpleAsyncResult *simple); |
|---|
| 301 |
return g_simple_async_result_get_op_res_gboolean(gSimpleAsyncResult); |
|---|
| 302 |
} |
|---|
| 303 |
|
|---|
| 304 |
/** |
|---|
| 305 |
* Gets the source tag for the GSimpleAsyncResult. |
|---|
| 306 |
* Returns: a gpointer to the source object for the GSimpleAsyncResult. |
|---|
| 307 |
*/ |
|---|
| 308 |
public void* getSourceTag() |
|---|
| 309 |
{ |
|---|
| 310 |
// gpointer g_simple_async_result_get_source_tag (GSimpleAsyncResult *simple); |
|---|
| 311 |
return g_simple_async_result_get_source_tag(gSimpleAsyncResult); |
|---|
| 312 |
} |
|---|
| 313 |
|
|---|
| 314 |
/** |
|---|
| 315 |
* Ensures that the data passed to the _finish function of an async |
|---|
| 316 |
* operation is consistent. Three checks are performed. |
|---|
| 317 |
* First, result is checked to ensure that it is really a |
|---|
| 318 |
* GSimpleAsyncResult. Second, source is checked to ensure that it |
|---|
| 319 |
* matches the source object of result. Third, source_tag is |
|---|
| 320 |
* checked to ensure that it is either NULL (as it is when the result was |
|---|
| 321 |
* created by g_simple_async_report_error_in_idle() or |
|---|
| 322 |
* g_simple_async_report_gerror_in_idle()) or equal to the |
|---|
| 323 |
* source_tag argument given to g_simple_async_result_new() (which, by |
|---|
| 324 |
* convention, is a pointer to the _async function corresponding to the |
|---|
| 325 |
* _finish function from which this function is called). |
|---|
| 326 |
* Since 2.20 |
|---|
| 327 |
* Params: |
|---|
| 328 |
* result = the GAsyncResult passed to the _finish function. |
|---|
| 329 |
* source = the GObject passed to the _finish function. |
|---|
| 330 |
* sourceTag = the asynchronous function. |
|---|
| 331 |
* Returns: TRUE if all checks passed or FALSE if any failed. |
|---|
| 332 |
*/ |
|---|
| 333 |
public static int isValid(GAsyncResult* result, ObjectG source, void* sourceTag) |
|---|
| 334 |
{ |
|---|
| 335 |
// gboolean g_simple_async_result_is_valid (GAsyncResult *result, GObject *source, gpointer source_tag); |
|---|
| 336 |
return g_simple_async_result_is_valid(result, (source is null) ? null : source.getObjectGStruct(), sourceTag); |
|---|
| 337 |
} |
|---|
| 338 |
|
|---|
| 339 |
/** |
|---|
| 340 |
* Sets whether to handle cancellation within the asynchronous operation. |
|---|
| 341 |
* Params: |
|---|
| 342 |
* handleCancellation = a gboolean. |
|---|
| 343 |
*/ |
|---|
| 344 |
public void setHandleCancellation(int handleCancellation) |
|---|
| 345 |
{ |
|---|
| 346 |
// void g_simple_async_result_set_handle_cancellation (GSimpleAsyncResult *simple, gboolean handle_cancellation); |
|---|
| 347 |
g_simple_async_result_set_handle_cancellation(gSimpleAsyncResult, handleCancellation); |
|---|
| 348 |
} |
|---|
| 349 |
|
|---|
| 350 |
/** |
|---|
| 351 |
* Completes an asynchronous I/O job immediately. Must be called in |
|---|
| 352 |
* the thread where the asynchronous result was to be delivered, as it |
|---|
| 353 |
* invokes the callback directly. If you are in a different thread use |
|---|
| 354 |
* g_simple_async_result_complete_in_idle(). |
|---|
| 355 |
* Calling this function takes a reference to simple for as long as |
|---|
| 356 |
* is needed to complete the call. |
|---|
| 357 |
*/ |
|---|
| 358 |
public void complete() |
|---|
| 359 |
{ |
|---|
| 360 |
// void g_simple_async_result_complete (GSimpleAsyncResult *simple); |
|---|
| 361 |
g_simple_async_result_complete(gSimpleAsyncResult); |
|---|
| 362 |
} |
|---|
| 363 |
|
|---|
| 364 |
/** |
|---|
| 365 |
* Completes an asynchronous function in an idle handler in the thread-default main |
|---|
| 366 |
* loop of the thread that simple was initially created in. |
|---|
| 367 |
* Calling this function takes a reference to simple for as long as |
|---|
| 368 |
* is needed to complete the call. |
|---|
| 369 |
*/ |
|---|
| 370 |
public void completeInIdle() |
|---|
| 371 |
{ |
|---|
| 372 |
// void g_simple_async_result_complete_in_idle (GSimpleAsyncResult *simple); |
|---|
| 373 |
g_simple_async_result_complete_in_idle(gSimpleAsyncResult); |
|---|
| 374 |
} |
|---|
| 375 |
|
|---|
| 376 |
/** |
|---|
| 377 |
* Runs the asynchronous job in a separate thread and then calls |
|---|
| 378 |
* g_simple_async_result_complete_in_idle() on simple to return |
|---|
| 379 |
* the result to the appropriate main loop. |
|---|
| 380 |
* Calling this function takes a reference to simple for as long as |
|---|
| 381 |
* is needed to run the job and report its completion. |
|---|
| 382 |
* Params: |
|---|
| 383 |
* func = a GSimpleAsyncThreadFunc. |
|---|
| 384 |
* ioPriority = the io priority of the request. |
|---|
| 385 |
* cancellable = optional GCancellable object, NULL to ignore. [allow-none] |
|---|
| 386 |
*/ |
|---|
| 387 |
public void runInThread(GSimpleAsyncThreadFunc func, int ioPriority, Cancellable cancellable) |
|---|
| 388 |
{ |
|---|
| 389 |
// void g_simple_async_result_run_in_thread (GSimpleAsyncResult *simple, GSimpleAsyncThreadFunc func, int io_priority, GCancellable *cancellable); |
|---|
| 390 |
g_simple_async_result_run_in_thread(gSimpleAsyncResult, func, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct()); |
|---|
| 391 |
} |
|---|
| 392 |
|
|---|
| 393 |
/** |
|---|
| 394 |
* Sets the result from a GError. |
|---|
| 395 |
* Params: |
|---|
| 396 |
* error = GError. |
|---|
| 397 |
*/ |
|---|
| 398 |
public void setFromError(ErrorG error) |
|---|
| 399 |
{ |
|---|
| 400 |
// void g_simple_async_result_set_from_error (GSimpleAsyncResult *simple, const GError *error); |
|---|
| 401 |
g_simple_async_result_set_from_error(gSimpleAsyncResult, (error is null) ? null : error.getErrorGStruct()); |
|---|
| 402 |
} |
|---|
| 403 |
|
|---|
| 404 |
/** |
|---|
| 405 |
* Sets the result from error, and takes over the caller's ownership |
|---|
| 406 |
* of error, so the caller does not need to free it any more. |
|---|
| 407 |
* Since 2.28 |
|---|
| 408 |
* Params: |
|---|
| 409 |
* error = a GError |
|---|
| 410 |
*/ |
|---|
| 411 |
public void takeError(ErrorG error) |
|---|
| 412 |
{ |
|---|
| 413 |
// void g_simple_async_result_take_error (GSimpleAsyncResult *simple, GError *error); |
|---|
| 414 |
g_simple_async_result_take_error(gSimpleAsyncResult, (error is null) ? null : error.getErrorGStruct()); |
|---|
| 415 |
} |
|---|
| 416 |
|
|---|
| 417 |
/** |
|---|
| 418 |
* Propagates an error from within the simple asynchronous result to |
|---|
| 419 |
* a given destination. |
|---|
| 420 |
* Returns: TRUE if the error was propagated to dest. FALSE otherwise. |
|---|
| 421 |
*/ |
|---|
| 422 |
public int propagateError() |
|---|
| 423 |
{ |
|---|
| 424 |
// gboolean g_simple_async_result_propagate_error (GSimpleAsyncResult *simple, GError **dest); |
|---|
| 425 |
GError* err = null; |
|---|
| 426 |
|
|---|
| 427 |
auto p = g_simple_async_result_propagate_error(gSimpleAsyncResult, &err); |
|---|
| 428 |
|
|---|
| 429 |
if (err !is null) |
|---|
| 430 |
{ |
|---|
| 431 |
throw new GException( new ErrorG(err) ); |
|---|
| 432 |
} |
|---|
| 433 |
|
|---|
| 434 |
return p; |
|---|
| 435 |
} |
|---|
| 436 |
|
|---|
| 437 |
/** |
|---|
| 438 |
* Sets an error within the asynchronous result without a GError. |
|---|
| 439 |
* Unless writing a binding, see g_simple_async_result_set_error(). |
|---|
| 440 |
* Params: |
|---|
| 441 |
* domain = a GQuark (usually G_IO_ERROR). |
|---|
| 442 |
* code = an error code. |
|---|
| 443 |
* format = a formatted error reporting string. |
|---|
| 444 |
* args = va_list of arguments. |
|---|
| 445 |
*/ |
|---|
| 446 |
public void setErrorVa(GQuark domain, int code, string format, void* args) |
|---|
| 447 |
{ |
|---|
| 448 |
// void g_simple_async_result_set_error_va (GSimpleAsyncResult *simple, GQuark domain, gint code, const char *format, va_list args); |
|---|
| 449 |
g_simple_async_result_set_error_va(gSimpleAsyncResult, domain, code, Str.toStringz(format), args); |
|---|
| 450 |
} |
|---|
| 451 |
|
|---|
| 452 |
/** |
|---|
| 453 |
* Reports an error in an idle function. Similar to |
|---|
| 454 |
* g_simple_async_report_error_in_idle(), but takes a GError rather |
|---|
| 455 |
* than building a new one. |
|---|
| 456 |
* Params: |
|---|
| 457 |
* object = a GObject, or NULL. [allow-none] |
|---|
| 458 |
* callback = a GAsyncReadyCallback. [scope async] |
|---|
| 459 |
* userData = user data passed to callback. [closure] |
|---|
| 460 |
* error = the GError to report |
|---|
| 461 |
*/ |
|---|
| 462 |
public static void simpleAsyncReportGerrorInIdle(ObjectG object, GAsyncReadyCallback callback, void* userData, ErrorG error) |
|---|
| 463 |
{ |
|---|
| 464 |
// void g_simple_async_report_gerror_in_idle (GObject *object, GAsyncReadyCallback callback, gpointer user_data, const GError *error); |
|---|
| 465 |
g_simple_async_report_gerror_in_idle((object is null) ? null : object.getObjectGStruct(), callback, userData, (error is null) ? null : error.getErrorGStruct()); |
|---|
| 466 |
} |
|---|
| 467 |
|
|---|
| 468 |
/** |
|---|
| 469 |
* Reports an error in an idle function. Similar to |
|---|
| 470 |
* g_simple_async_report_gerror_in_idle(), but takes over the caller's |
|---|
| 471 |
* ownership of error, so the caller does not have to free it any more. |
|---|
| 472 |
* Since 2.28 |
|---|
| 473 |
* Params: |
|---|
| 474 |
* object = a GObject, or NULL. [allow-none] |
|---|
| 475 |
* callback = a GAsyncReadyCallback. |
|---|
| 476 |
* userData = user data passed to callback. |
|---|
| 477 |
* error = the GError to report |
|---|
| 478 |
*/ |
|---|
| 479 |
public static void simpleAsyncReportTakeGerrorInIdle(ObjectG object, GAsyncReadyCallback callback, void* userData, ErrorG error) |
|---|
| 480 |
{ |
|---|
| 481 |
// void g_simple_async_report_take_gerror_in_idle (GObject *object, GAsyncReadyCallback callback, gpointer user_data, GError *error); |
|---|
| 482 |
g_simple_async_report_take_gerror_in_idle((object is null) ? null : object.getObjectGStruct(), callback, userData, (error is null) ? null : error.getErrorGStruct()); |
|---|
| 483 |
} |
|---|
| 484 |
} |
|---|