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 = GIcon.html 27 * outPack = gio 28 * outFile = IconT 29 * strct = GIcon 30 * realStrct= 31 * ctorStrct= 32 * clss = IconT 33 * interf = IconIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - g_icon_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * - g_icon_new_for_string 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - glib.ErrorG 50 * - glib.GException 51 * - glib.Variant 52 * - gio.IconIF 53 * - gio.Icon 54 * structWrap: 55 * - GIcon* -> IconIF 56 * - GVariant* -> Variant 57 * module aliases: 58 * local aliases: 59 * overrides: 60 * - toString 61 */ 62 63 module gio.IconT; 64 65 public import gtkc.giotypes; 66 67 public import gtkc.gio; 68 public import glib.ConstructionException; 69 public import gobject.ObjectG; 70 71 72 public import glib.Str; 73 public import glib.ErrorG; 74 public import glib.GException; 75 public import glib.Variant; 76 public import gio.IconIF; 77 public import gio.Icon; 78 79 80 81 82 /** 83 * GIcon is a very minimal interface for icons. It provides functions 84 * for checking the equality of two icons, hashing of icons and 85 * serializing an icon to and from strings. 86 * 87 * GIcon does not provide the actual pixmap for the icon as this is out 88 * of GIO's scope, however implementations of GIcon may contain the name 89 * of an icon (see GThemedIcon), or the path to an icon (see GLoadableIcon). 90 * 91 * To obtain a hash of a GIcon, see g_icon_hash(). 92 * 93 * To check if two GIcons are equal, see g_icon_equal(). 94 * 95 * For serializing a GIcon, use g_icon_serialize() and 96 * g_icon_deserialize(). 97 * 98 * If you want to consume GIcon (for example, in a toolkit) you must 99 * be prepared to handle at least the three following cases: 100 * GLoadableIcon, GThemedIcon and GEmblemedIcon. It may also make 101 * sense to have fast-paths for other cases (like handling GdkPixbuf 102 * directly, for example) but all compliant GIcon implementations 103 * outside of GIO must implement GLoadableIcon. 104 * 105 * If your application or library provides one or more GIcon 106 * implementations you need to ensure that your new implementation also 107 * implements GLoadableIcon. Additionally, you must provide an 108 * implementation of g_icon_serialize() that gives a result that is 109 * understood by g_icon_deserialize(), yielding one of the built-in icon 110 * types. 111 */ 112 public template IconT(TStruct) 113 { 114 115 /** the main Gtk struct */ 116 protected GIcon* gIcon; 117 118 119 public GIcon* getIconTStruct() 120 { 121 return cast(GIcon*)getStruct(); 122 } 123 124 125 /** 126 */ 127 128 /** 129 * Gets a hash for an icon. 130 * Virtual: hash 131 * Params: 132 * icon = gconstpointer to an icon object. 133 * Returns: a guint containing a hash for the icon, suitable for use in a GHashTable or similar data structure. 134 */ 135 public static uint hash(void* icon) 136 { 137 // guint g_icon_hash (gconstpointer icon); 138 return g_icon_hash(icon); 139 } 140 141 /** 142 * Checks if two icons are equal. 143 * Params: 144 * icon2 = pointer to the second GIcon. [allow-none] 145 * Returns: TRUE if icon1 is equal to icon2. FALSE otherwise. 146 */ 147 public int equal(IconIF icon2) 148 { 149 // gboolean g_icon_equal (GIcon *icon1, GIcon *icon2); 150 return g_icon_equal(getIconTStruct(), (icon2 is null) ? null : icon2.getIconTStruct()); 151 } 152 153 /** 154 * Generates a textual representation of icon that can be used for 155 * serialization such as when passing icon to a different process or 156 * saving it to persistent storage. Use g_icon_new_for_string() to 157 * get icon back from the returned string. 158 * The encoding of the returned string is proprietary to GIcon except 159 * in the following two cases 160 * If icon is a GFileIcon, the returned string is a native path 161 * (such as /path/to/my icon.png) without escaping 162 * if the GFile for icon is a native file. If the file is not 163 * native, the returned string is the result of g_file_get_uri() 164 * (such as sftp://path/to/my%20icon.png). 165 * If icon is a GThemedIcon with exactly one name, the encoding is 166 * simply the name (such as network-server). 167 * Virtual: to_tokens 168 * Since 2.20 169 * Returns: An allocated NUL-terminated UTF8 string or NULL if icon can't be serialized. Use g_free() to free. 170 */ 171 public override string toString() 172 { 173 // gchar * g_icon_to_string (GIcon *icon); 174 return Str.toString(g_icon_to_string(getIconTStruct())); 175 } 176 177 /** 178 * Serializes a GIcon into a GVariant. An equivalent GIcon can be retrieved 179 * back by calling g_icon_deserialize() on the returned value. 180 * As serialization will avoid using raw icon data when possible, it only 181 * makes sense to transfer the GVariant between processes on the same machine, 182 * (as opposed to over the network), and within the same file system namespace. 183 * Since 2.38 184 * Returns: a GVariant, or NULL when serialization fails. [transfer full] 185 */ 186 public Variant serialize() 187 { 188 // GVariant * g_icon_serialize (GIcon *icon); 189 auto p = g_icon_serialize(getIconTStruct()); 190 191 if(p is null) 192 { 193 return null; 194 } 195 196 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 197 } 198 199 /** 200 * Deserializes a GIcon previously serialized using g_icon_serialize(). 201 * Since 2.38 202 * Params: 203 * value = a GVariant created with g_icon_serialize() 204 * Returns: a GIcon, or NULL when deserialization fails. [transfer full] 205 */ 206 public static IconIF deserialize(Variant value) 207 { 208 // GIcon * g_icon_deserialize (GVariant *value); 209 auto p = g_icon_deserialize((value is null) ? null : value.getVariantStruct()); 210 211 if(p is null) 212 { 213 return null; 214 } 215 216 return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p); 217 } 218 }