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 = GLoadableIcon.html 27 * outPack = gio 28 * outFile = LoadableIconT 29 * strct = GLoadableIcon 30 * realStrct= 31 * ctorStrct= 32 * clss = LoadableIconT 33 * interf = LoadableIconIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - g_loadable_icon_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - glib.ErrorG 49 * - glib.GException 50 * - gio.AsyncResultIF 51 * - gio.Cancellable 52 * - gio.InputStream 53 * structWrap: 54 * - GAsyncResult* -> AsyncResultIF 55 * - GCancellable* -> Cancellable 56 * - GInputStream* -> InputStream 57 * module aliases: 58 * local aliases: 59 * overrides: 60 */ 61 62 module gio.LoadableIconT; 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 gio.AsyncResultIF; 75 public import gio.Cancellable; 76 public import gio.InputStream; 77 78 79 80 81 /** 82 * Description 83 * Extends the GIcon interface and adds the ability to 84 * load icons from streams. 85 */ 86 public template LoadableIconT(TStruct) 87 { 88 89 /** the main Gtk struct */ 90 protected GLoadableIcon* gLoadableIcon; 91 92 93 public GLoadableIcon* getLoadableIconTStruct() 94 { 95 return cast(GLoadableIcon*)getStruct(); 96 } 97 98 99 /** 100 */ 101 102 /** 103 * Loads a loadable icon. For the asynchronous version of this function, 104 * see g_loadable_icon_load_async(). 105 * Params: 106 * size = an integer. 107 * type = a location to store the type of the 108 * loaded icon, NULL to ignore. [out][allow-none] 109 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 110 * Returns: a GInputStream to read the icon from. [transfer full] 111 * Throws: GException on failure. 112 */ 113 public InputStream load(int size, out string type, Cancellable cancellable) 114 { 115 // GInputStream * g_loadable_icon_load (GLoadableIcon *icon, int size, char **type, GCancellable *cancellable, GError **error); 116 char* outtype = null; 117 GError* err = null; 118 119 auto p = g_loadable_icon_load(getLoadableIconTStruct(), size, &outtype, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 120 121 if (err !is null) 122 { 123 throw new GException( new ErrorG(err) ); 124 } 125 126 type = Str.toString(outtype); 127 128 if(p is null) 129 { 130 return null; 131 } 132 133 return ObjectG.getDObject!(InputStream)(cast(GInputStream*) p); 134 } 135 136 /** 137 * Loads an icon asynchronously. To finish this function, see 138 * g_loadable_icon_load_finish(). For the synchronous, blocking 139 * version of this function, see g_loadable_icon_load(). 140 * Params: 141 * size = an integer. 142 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 143 * callback = a GAsyncReadyCallback to call when the 144 * request is satisfied. [scope async] 145 * userData = the data to pass to callback function. [closure] 146 */ 147 public void loadAsync(int size, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 148 { 149 // void g_loadable_icon_load_async (GLoadableIcon *icon, int size, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 150 g_loadable_icon_load_async(getLoadableIconTStruct(), size, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 151 } 152 153 /** 154 * Finishes an asynchronous icon load started in g_loadable_icon_load_async(). 155 * Params: 156 * res = a GAsyncResult. 157 * type = a location to store the type of the loaded icon, NULL to ignore. 158 * Returns: a GInputStream to read the icon from. [transfer full] 159 * Throws: GException on failure. 160 */ 161 public InputStream loadFinish(AsyncResultIF res, out string type) 162 { 163 // GInputStream * g_loadable_icon_load_finish (GLoadableIcon *icon, GAsyncResult *res, char **type, GError **error); 164 char* outtype = null; 165 GError* err = null; 166 167 auto p = g_loadable_icon_load_finish(getLoadableIconTStruct(), (res is null) ? null : res.getAsyncResultTStruct(), &outtype, &err); 168 169 if (err !is null) 170 { 171 throw new GException( new ErrorG(err) ); 172 } 173 174 type = Str.toString(outtype); 175 176 if(p is null) 177 { 178 return null; 179 } 180 181 return ObjectG.getDObject!(InputStream)(cast(GInputStream*) p); 182 } 183 }