root/trunk/src/gio/InitableT.d

Revision 938, 7.0 kB (checked in by Mike Wey, 3 months ago)

Update Gio to 2.28.

Line 
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  = GInitable.html
27  * outPack = gio
28  * outFile = InitableT
29  * strct   = GInitable
30  * realStrct=
31  * ctorStrct=
32  * clss    = InitableT
33  * interf  = InitableIF
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.Cancellable
52  * structWrap:
53  *  - GCancellable* -> Cancellable
54  *  - GObject* -> ObjectG
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59
60 module gio.InitableT;
61
62 public  import gtkc.giotypes;
63
64 public import gtkc.gio;
65 public import glib.ConstructionException;
66
67
68 public import glib.Str;
69 public import glib.ErrorG;
70 public import glib.GException;
71 public import gobject.ObjectG;
72 public import gio.Cancellable;
73
74
75
76
77 /**
78  * Description
79  * GInitable is implemented by objects that can fail during
80  * initialization. If an object implements this interface the
81  * g_initable_init() function must be called as the first thing
82  * after construction. If g_initable_init() is not called, or if
83  * it returns an error, all further operations on the object
84  * should fail, generally with a G_IO_ERROR_NOT_INITIALIZED error.
85  * Users of objects implementing this are not intended to use
86  * the interface method directly, instead it will be used automatically
87  * in various ways. For C applications you generally just call
88  * g_initable_new() directly, or indirectly via a foo_thing_new() wrapper.
89  * This will call g_initable_init() under the cover, returning NULL and
90  * setting a GError on failure (at which point the instance is
91  * unreferenced).
92  * For bindings in languages where the native constructor supports
93  * exceptions the binding could check for objects implemention GInitable
94  * during normal construction and automatically initialize them, throwing
95  * an exception on failure.
96  */
97 public template InitableT(TStruct)
98 {
99    
100     /** the main Gtk struct */
101     protected GInitable* gInitable;
102    
103    
104     public GInitable* getInitableTStruct()
105     {
106         return cast(GInitable*)getStruct();
107     }
108    
109    
110     /**
111      */
112    
113     /**
114      * Initializes the object implementing the interface. This must be
115      * done before any real use of the object after initial construction.
116      * Implementations may also support cancellation. If cancellable is not NULL,
117      * then initialization can be cancelled by triggering the cancellable object
118      * from another thread. If the operation was cancelled, the error
119      * G_IO_ERROR_CANCELLED will be returned. If cancellable is not NULL and
120      * the object doesn't support cancellable initialization the error
121      * G_IO_ERROR_NOT_SUPPORTED will be returned.
122      * If this function is not called, or returns with an error then all
123      * operations on the object should fail, generally returning the
124      * error G_IO_ERROR_NOT_INITIALIZED.
125      * Implementations of this method must be idempotent, i.e. multiple calls
126      * to this function with the same argument should return the same results.
127      * Only the first call initializes the object, further calls return the result
128      * of the first call. This is so that its safe to implement the singleton
129      * pattern in the GObject constructor function.
130      * Since 2.22
131      * Params:
132      * cancellable = optional GCancellable object, NULL to ignore.
133      * Returns: TRUE if successful. If an error has occurred, this function will return FALSE and set error appropriately if present.
134      * Throws: GException on failure.
135      */
136     public int init(Cancellable cancellable)
137     {
138         // gboolean g_initable_init (GInitable *initable,  GCancellable *cancellable,  GError **error);
139         GError* err = null;
140        
141         auto p = g_initable_init(getInitableTStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
142        
143         if (err !is null)
144         {
145             throw new GException( new ErrorG(err) );
146         }
147        
148         return p;
149     }
150    
151     /**
152      * Helper function for constructing GInitiable object. This is
153      * similar to g_object_new_valist() but also initializes the object
154      * and returns NULL, setting an error on failure.
155      * Since 2.22
156      * Params:
157      * objectType = a GType supporting GInitable.
158      * firstPropertyName = the name of the first property, followed by
159      * the value, and other property value pairs, and ended by NULL.
160      * varArgs = The var args list generated from first_property_name.
161      * cancellable = optional GCancellable object, NULL to ignore.
162      * Returns: a newly allocated GObject, or NULL on error. [transfer full]
163      * Throws: GException on failure.
164      */
165     public static ObjectG newValist(GType objectType, string firstPropertyName, void* varArgs, Cancellable cancellable)
166     {
167         // GObject * g_initable_new_valist (GType object_type,  const gchar *first_property_name,  va_list var_args,  GCancellable *cancellable,  GError **error);
168         GError* err = null;
169        
170         auto p = g_initable_new_valist(objectType, Str.toStringz(firstPropertyName), varArgs, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
171        
172         if (err !is null)
173         {
174             throw new GException( new ErrorG(err) );
175         }
176        
177         if(p is null)
178         {
179             return null;
180         }
181         return new ObjectG(cast(GObject*) p);
182     }
183    
184     /**
185      * Helper function for constructing GInitiable object. This is
186      * similar to g_object_newv() but also initializes the object
187      * and returns NULL, setting an error on failure.
188      * Since 2.22
189      * Params:
190      * objectType = a GType supporting GInitable.
191      * parameters = the parameters to use to construct the object
192      * cancellable = optional GCancellable object, NULL to ignore.
193      * Returns: a newly allocated GObject, or NULL on error. [transfer full]
194      * Throws: GException on failure.
195      */
196     public static void* newv(GType objectType, GParameter[] parameters, Cancellable cancellable)
197     {
198         // gpointer g_initable_newv (GType object_type,  guint n_parameters,  GParameter *parameters,  GCancellable *cancellable,  GError **error);
199         GError* err = null;
200        
201         auto p = g_initable_newv(objectType, cast(int) parameters.length, parameters.ptr, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
202        
203         if (err !is null)
204         {
205             throw new GException( new ErrorG(err) );
206         }
207        
208         return p;
209     }
210 }
Note: See TracBrowser for help on using the browser.