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 public import glib.Str; 71 public import glib.ErrorG; 72 public import glib.GException; 73 public import gio.AsyncResultIF; 74 public import gio.Cancellable; 75 public import gio.InputStream; 76 77 78 79 /** 80 * Extends the GIcon interface and adds the ability to 81 * load icons from streams. 82 */ 83 public template LoadableIconT(TStruct) 84 { 85 86 /** the main Gtk struct */ 87 protected GLoadableIcon* gLoadableIcon; 88 89 90 /** Get the main Gtk struct */ 91 public GLoadableIcon* getLoadableIconTStruct() 92 { 93 return cast(GLoadableIcon*)getStruct(); 94 } 95 96 97 /** 98 */ 99 100 /** 101 * Loads a loadable icon. For the asynchronous version of this function, 102 * see g_loadable_icon_load_async(). 103 * Params: 104 * size = an integer. 105 * type = a location to store the type of the 106 * loaded icon, NULL to ignore. [out][allow-none] 107 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 108 * Returns: a GInputStream to read the icon from. [transfer full] 109 * Throws: GException on failure. 110 */ 111 public InputStream load(int size, out string type, Cancellable cancellable) 112 { 113 // GInputStream * g_loadable_icon_load (GLoadableIcon *icon, int size, char **type, GCancellable *cancellable, GError **error); 114 char* outtype = null; 115 GError* err = null; 116 117 auto p = g_loadable_icon_load(getLoadableIconTStruct(), size, &outtype, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 118 119 if (err !is null) 120 { 121 throw new GException( new ErrorG(err) ); 122 } 123 124 type = Str.toString(outtype); 125 126 if(p is null) 127 { 128 return null; 129 } 130 131 return ObjectG.getDObject!(InputStream)(cast(GInputStream*) p); 132 } 133 134 /** 135 * Loads an icon asynchronously. To finish this function, see 136 * g_loadable_icon_load_finish(). For the synchronous, blocking 137 * version of this function, see g_loadable_icon_load(). 138 * Params: 139 * size = an integer. 140 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 141 * callback = a GAsyncReadyCallback to call when the 142 * request is satisfied. [scope async] 143 * userData = the data to pass to callback function. [closure] 144 */ 145 public void loadAsync(int size, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 146 { 147 // void g_loadable_icon_load_async (GLoadableIcon *icon, int size, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 148 g_loadable_icon_load_async(getLoadableIconTStruct(), size, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 149 } 150 151 /** 152 * Finishes an asynchronous icon load started in g_loadable_icon_load_async(). 153 * Params: 154 * res = a GAsyncResult. 155 * type = a location to store the type of the 156 * loaded icon, NULL to ignore. [out][allow-none] 157 * Returns: a GInputStream to read the icon from. [transfer full] 158 * Throws: GException on failure. 159 */ 160 public InputStream loadFinish(AsyncResultIF res, out string type) 161 { 162 // GInputStream * g_loadable_icon_load_finish (GLoadableIcon *icon, GAsyncResult *res, char **type, GError **error); 163 char* outtype = null; 164 GError* err = null; 165 166 auto p = g_loadable_icon_load_finish(getLoadableIconTStruct(), (res is null) ? null : res.getAsyncResultTStruct(), &outtype, &err); 167 168 if (err !is null) 169 { 170 throw new GException( new ErrorG(err) ); 171 } 172 173 type = Str.toString(outtype); 174 175 if(p is null) 176 { 177 return null; 178 } 179 180 return ObjectG.getDObject!(InputStream)(cast(GInputStream*) p); 181 } 182 }