source: appstream-generator/build/girepo/gio/AsyncInitableIF.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 3 years ago

Initial release

File size: 9.0 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.AsyncInitableIF;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.AsyncResultIF;
26private import gio.Cancellable;
27private import glib.ErrorG;
28private import glib.GException;
29private import glib.Str;
30private import gobject.ObjectG;
31
32
33/**
34 * This is the asynchronous version of #GInitable; it behaves the same
35 * in all ways except that initialization is asynchronous. For more details
36 * see the descriptions on #GInitable.
37 *
38 * A class may implement both the #GInitable and #GAsyncInitable interfaces.
39 *
40 * Users of objects implementing this are not intended to use the interface
41 * method directly; instead it will be used automatically in various ways.
42 * For C applications you generally just call g_async_initable_new_async()
43 * directly, or indirectly via a foo_thing_new_async() wrapper. This will call
44 * g_async_initable_init_async() under the cover, calling back with %NULL and
45 * a set %GError on failure.
46 *
47 * A typical implementation might look something like this:
48 *
49 * |[<!-- language="C" -->
50 * enum {
51 * NOT_INITIALIZED,
52 * INITIALIZING,
53 * INITIALIZED
54 * };
55 *
56 * static void
57 * _foo_ready_cb (Foo *self)
58 * {
59 * GList *l;
60 *
61 * self->priv->state = INITIALIZED;
62 *
63 * for (l = self->priv->init_results; l != NULL; l = l->next)
64 * {
65 * GTask *task = l->data;
66 *
67 * if (self->priv->success)
68 * g_task_return_boolean (task, TRUE);
69 * else
70 * g_task_return_new_error (task, ...);
71 * g_object_unref (task);
72 * }
73 *
74 * g_list_free (self->priv->init_results);
75 * self->priv->init_results = NULL;
76 * }
77 *
78 * static void
79 * foo_init_async (GAsyncInitable       *initable,
80 * int                   io_priority,
81 * GCancellable         *cancellable,
82 * GAsyncReadyCallback   callback,
83 * gpointer              user_data)
84 * {
85 * Foo *self = FOO (initable);
86 * GTask *task;
87 *
88 * task = g_task_new (initable, cancellable, callback, user_data);
89 *
90 * switch (self->priv->state)
91 * {
92 * case NOT_INITIALIZED:
93 * _foo_get_ready (self);
94 * self->priv->init_results = g_list_append (self->priv->init_results,
95 * task);
96 * self->priv->state = INITIALIZING;
97 * break;
98 * case INITIALIZING:
99 * self->priv->init_results = g_list_append (self->priv->init_results,
100 * task);
101 * break;
102 * case INITIALIZED:
103 * if (!self->priv->success)
104 * g_task_return_new_error (task, ...);
105 * else
106 * g_task_return_boolean (task, TRUE);
107 * g_object_unref (task);
108 * break;
109 * }
110 * }
111 *
112 * static gboolean
113 * foo_init_finish (GAsyncInitable       *initable,
114 * GAsyncResult         *result,
115 * GError              **error)
116 * {
117 * g_return_val_if_fail (g_task_is_valid (result, initable), FALSE);
118 *
119 * return g_task_propagate_boolean (G_TASK (result), error);
120 * }
121 *
122 * static void
123 * foo_async_initable_iface_init (gpointer g_iface,
124 * gpointer data)
125 * {
126 * GAsyncInitableIface *iface = g_iface;
127 *
128 * iface->init_async = foo_init_async;
129 * iface->init_finish = foo_init_finish;
130 * }
131 * ]|
132 *
133 * Since: 2.22
134 */
135public interface AsyncInitableIF{
136        /** Get the main Gtk struct */
137        public GAsyncInitable* getAsyncInitableStruct();
138
139        /** the main Gtk struct as a void* */
140        protected void* getStruct();
141
142
143        /**
144         * Helper function for constructing #GAsyncInitable object. This is
145         * similar to g_object_new_valist() but also initializes the object
146         * asynchronously.
147         *
148         * When the initialization is finished, @callback will be called. You can
149         * then call g_async_initable_new_finish() to get the new object and check
150         * for any errors.
151         *
152         * Params:
153         *     objectType = a #GType supporting #GAsyncInitable.
154         *     firstPropertyName = the name of the first property, followed by
155         *         the value, and other property value pairs, and ended by %NULL.
156         *     varArgs = The var args list generated from @first_property_name.
157         *     ioPriority = the [I/O priority][io-priority] of the operation
158         *     cancellable = optional #GCancellable object, %NULL to ignore.
159         *     callback = a #GAsyncReadyCallback to call when the initialization is
160         *         finished
161         *     userData = the data to pass to callback function
162         *
163         * Since: 2.22
164         */
165        public static void newValistAsync(GType objectType, string firstPropertyName, void* varArgs, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
166
167        /**
168         * Helper function for constructing #GAsyncInitable object. This is
169         * similar to g_object_newv() but also initializes the object asynchronously.
170         *
171         * When the initialization is finished, @callback will be called. You can
172         * then call g_async_initable_new_finish() to get the new object and check
173         * for any errors.
174         *
175         * Params:
176         *     objectType = a #GType supporting #GAsyncInitable.
177         *     nParameters = the number of parameters in @parameters
178         *     parameters = the parameters to use to construct the object
179         *     ioPriority = the [I/O priority][io-priority] of the operation
180         *     cancellable = optional #GCancellable object, %NULL to ignore.
181         *     callback = a #GAsyncReadyCallback to call when the initialization is
182         *         finished
183         *     userData = the data to pass to callback function
184         *
185         * Since: 2.22
186         */
187        public static void newvAsync(GType objectType, uint nParameters, GParameter* parameters, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
188
189        /**
190         * Starts asynchronous initialization of the object implementing the
191         * interface. This must be done before any real use of the object after
192         * initial construction. If the object also implements #GInitable you can
193         * optionally call g_initable_init() instead.
194         *
195         * When the initialization is finished, @callback will be called. You can
196         * then call g_async_initable_init_finish() to get the result of the
197         * initialization.
198         *
199         * Implementations may also support cancellation. If @cancellable is not
200         * %NULL, then initialization can be cancelled by triggering the cancellable
201         * object from another thread. If the operation was cancelled, the error
202         * %G_IO_ERROR_CANCELLED will be returned. If @cancellable is not %NULL, and
203         * the object doesn't support cancellable initialization, the error
204         * %G_IO_ERROR_NOT_SUPPORTED will be returned.
205         *
206         * As with #GInitable, if the object is not initialized, or initialization
207         * returns with an error, then all operations on the object except
208         * g_object_ref() and g_object_unref() are considered to be invalid, and
209         * have undefined behaviour. They will often fail with g_critical() or
210         * g_warning(), but this must not be relied on.
211         *
212         * Implementations of this method must be idempotent: i.e. multiple calls
213         * to this function with the same argument should return the same results.
214         * Only the first call initializes the object; further calls return the result
215         * of the first call. This is so that it's safe to implement the singleton
216         * pattern in the GObject constructor function.
217         *
218         * For classes that also support the #GInitable interface, the default
219         * implementation of this method will run the g_initable_init() function
220         * in a thread, so if you want to support asynchronous initialization via
221         * threads, just implement the #GAsyncInitable interface without overriding
222         * any interface methods.
223         *
224         * Params:
225         *     ioPriority = the [I/O priority][io-priority] of the operation
226         *     cancellable = optional #GCancellable object, %NULL to ignore.
227         *     callback = a #GAsyncReadyCallback to call when the request is satisfied
228         *     userData = the data to pass to callback function
229         *
230         * Since: 2.22
231         */
232        public void initAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
233
234        /**
235         * Finishes asynchronous initialization and returns the result.
236         * See g_async_initable_init_async().
237         *
238         * Params:
239         *     res = a #GAsyncResult.
240         *
241         * Returns: %TRUE if successful. If an error has occurred, this function
242         *     will return %FALSE and set @error appropriately if present.
243         *
244         * Since: 2.22
245         *
246         * Throws: GException on failure.
247         */
248        public bool initFinish(AsyncResultIF res);
249
250        /**
251         * Finishes the async construction for the various g_async_initable_new
252         * calls, returning the created object or %NULL on error.
253         *
254         * Params:
255         *     res = the #GAsyncResult from the callback
256         *
257         * Returns: a newly created #GObject,
258         *     or %NULL on error. Free with g_object_unref().
259         *
260         * Since: 2.22
261         *
262         * Throws: GException on failure.
263         */
264        public ObjectG newFinish(AsyncResultIF res);
265}
Note: See TracBrowser for help on using the repository browser.