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