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