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 module gio.LoadableIconT; 26 27 public import gio.AsyncResultIF; 28 public import gio.Cancellable; 29 public import gio.InputStream; 30 public import glib.ErrorG; 31 public import glib.GException; 32 public import glib.Str; 33 public import gobject.ObjectG; 34 public import gtkc.gio; 35 public import gtkc.giotypes; 36 37 38 /** 39 * Extends the #GIcon interface and adds the ability to 40 * load icons from streams. 41 */ 42 public template LoadableIconT(TStruct) 43 { 44 /** Get the main Gtk struct */ 45 public GLoadableIcon* getLoadableIconStruct(bool transferOwnership = false) 46 { 47 if (transferOwnership) 48 ownedRef = false; 49 return cast(GLoadableIcon*)getStruct(); 50 } 51 52 53 /** 54 * Loads a loadable icon. For the asynchronous version of this function, 55 * see g_loadable_icon_load_async(). 56 * 57 * Params: 58 * size = an integer. 59 * type = a location to store the type of the loaded 60 * icon, %NULL to ignore. 61 * cancellable = optional #GCancellable object, %NULL to 62 * ignore. 63 * 64 * Returns: a #GInputStream to read the icon from. 65 * 66 * Throws: GException on failure. 67 */ 68 public InputStream load(int size, out string type, Cancellable cancellable) 69 { 70 char* outtype = null; 71 GError* err = null; 72 73 auto p = g_loadable_icon_load(getLoadableIconStruct(), size, &outtype, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 74 75 if (err !is null) 76 { 77 throw new GException( new ErrorG(err) ); 78 } 79 80 type = Str.toString(outtype); 81 82 if(p is null) 83 { 84 return null; 85 } 86 87 return ObjectG.getDObject!(InputStream)(cast(GInputStream*) p, true); 88 } 89 90 /** 91 * Loads an icon asynchronously. To finish this function, see 92 * g_loadable_icon_load_finish(). For the synchronous, blocking 93 * version of this function, see g_loadable_icon_load(). 94 * 95 * Params: 96 * size = an integer. 97 * cancellable = optional #GCancellable object, %NULL to ignore. 98 * callback = a #GAsyncReadyCallback to call when the 99 * request is satisfied 100 * userData = the data to pass to callback function 101 */ 102 public void loadAsync(int size, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 103 { 104 g_loadable_icon_load_async(getLoadableIconStruct(), size, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 105 } 106 107 /** 108 * Finishes an asynchronous icon load started in g_loadable_icon_load_async(). 109 * 110 * Params: 111 * res = a #GAsyncResult. 112 * type = a location to store the type of the loaded 113 * icon, %NULL to ignore. 114 * 115 * Returns: a #GInputStream to read the icon from. 116 * 117 * Throws: GException on failure. 118 */ 119 public InputStream loadFinish(AsyncResultIF res, out string type) 120 { 121 char* outtype = null; 122 GError* err = null; 123 124 auto p = g_loadable_icon_load_finish(getLoadableIconStruct(), (res is null) ? null : res.getAsyncResultStruct(), &outtype, &err); 125 126 if (err !is null) 127 { 128 throw new GException( new ErrorG(err) ); 129 } 130 131 type = Str.toString(outtype); 132 133 if(p is null) 134 { 135 return null; 136 } 137 138 return ObjectG.getDObject!(InputStream)(cast(GInputStream*) p, true); 139 } 140 }