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.IconT;
26 
27 public  import gio.Icon;
28 public  import gio.IconIF;
29 public  import glib.ConstructionException;
30 public  import glib.ErrorG;
31 public  import glib.GException;
32 public  import glib.Str;
33 public  import glib.Variant;
34 public  import gobject.ObjectG;
35 public  import gtkc.gio;
36 public  import gtkc.giotypes;
37 
38 
39 /**
40  * #GIcon is a very minimal interface for icons. It provides functions
41  * for checking the equality of two icons, hashing of icons and
42  * serializing an icon to and from strings.
43  * 
44  * #GIcon does not provide the actual pixmap for the icon as this is out
45  * of GIO's scope, however implementations of #GIcon may contain the name
46  * of an icon (see #GThemedIcon), or the path to an icon (see #GLoadableIcon).
47  * 
48  * To obtain a hash of a #GIcon, see g_icon_hash().
49  * 
50  * To check if two #GIcons are equal, see g_icon_equal().
51  * 
52  * For serializing a #GIcon, use g_icon_serialize() and
53  * g_icon_deserialize().
54  * 
55  * If you want to consume #GIcon (for example, in a toolkit) you must
56  * be prepared to handle at least the three following cases:
57  * #GLoadableIcon, #GThemedIcon and #GEmblemedIcon.  It may also make
58  * sense to have fast-paths for other cases (like handling #GdkPixbuf
59  * directly, for example) but all compliant #GIcon implementations
60  * outside of GIO must implement #GLoadableIcon.
61  * 
62  * If your application or library provides one or more #GIcon
63  * implementations you need to ensure that your new implementation also
64  * implements #GLoadableIcon.  Additionally, you must provide an
65  * implementation of g_icon_serialize() that gives a result that is
66  * understood by g_icon_deserialize(), yielding one of the built-in icon
67  * types.
68  */
69 public template IconT(TStruct)
70 {
71 	/** Get the main Gtk struct */
72 	public GIcon* getIconStruct()
73 	{
74 		return cast(GIcon*)getStruct();
75 	}
76 
77 	/**
78 	 */
79 
80 	/**
81 	 * Deserializes a #GIcon previously serialized using g_icon_serialize().
82 	 *
83 	 * Params:
84 	 *     value = a #GVariant created with g_icon_serialize()
85 	 *
86 	 * Return: a #GIcon, or %NULL when deserialization fails.
87 	 *
88 	 * Since: 2.38
89 	 */
90 	public static IconIF deserialize(Variant value)
91 	{
92 		auto p = g_icon_deserialize((value is null) ? null : value.getVariantStruct());
93 		
94 		if(p is null)
95 		{
96 			return null;
97 		}
98 		
99 		return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p);
100 	}
101 
102 	/**
103 	 * Gets a hash for an icon.
104 	 *
105 	 * Params:
106 	 *     icon = #gconstpointer to an icon object.
107 	 *
108 	 * Return: a #guint containing a hash for the @icon, suitable for
109 	 *     use in a #GHashTable or similar data structure.
110 	 */
111 	public static uint hash(void* icon)
112 	{
113 		return g_icon_hash(icon);
114 	}
115 
116 	/**
117 	 * Checks if two icons are equal.
118 	 *
119 	 * Params:
120 	 *     icon2 = pointer to the second #GIcon.
121 	 *
122 	 * Return: %TRUE if @icon1 is equal to @icon2. %FALSE otherwise.
123 	 */
124 	public bool equal(IconIF icon2)
125 	{
126 		return g_icon_equal(getIconStruct(), (icon2 is null) ? null : icon2.getIconStruct()) != 0;
127 	}
128 
129 	/**
130 	 * Serializes a #GIcon into a #GVariant. An equivalent #GIcon can be retrieved
131 	 * back by calling g_icon_deserialize() on the returned value.
132 	 * As serialization will avoid using raw icon data when possible, it only
133 	 * makes sense to transfer the #GVariant between processes on the same machine,
134 	 * (as opposed to over the network), and within the same file system namespace.
135 	 *
136 	 * Return: a #GVariant, or %NULL when serialization fails.
137 	 *
138 	 * Since: 2.38
139 	 */
140 	public Variant serialize()
141 	{
142 		auto p = g_icon_serialize(getIconStruct());
143 		
144 		if(p is null)
145 		{
146 			return null;
147 		}
148 		
149 		return new Variant(cast(GVariant*) p);
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 	 *
158 	 * The encoding of the returned string is proprietary to #GIcon except
159 	 * in the following two cases
160 	 *
161 	 * - If @icon is a #GFileIcon, the returned string is a native path
162 	 * (such as `/path/to/my icon.png`) without escaping
163 	 * if the #GFile for @icon is a native file.  If the file is not
164 	 * native, the returned string is the result of g_file_get_uri()
165 	 * (such as `sftp://path/to/my%20icon.png`).
166 	 *
167 	 * - If @icon is a #GThemedIcon with exactly one name, the encoding is
168 	 * simply the name (such as `network-server`).
169 	 *
170 	 * Return: An allocated NUL-terminated UTF8 string or
171 	 *     %NULL if @icon can't be serialized. Use g_free() to free.
172 	 *
173 	 * Since: 2.20
174 	 */
175 	public override string toString()
176 	{
177 		return Str.toString(g_icon_to_string(getIconStruct()));
178 	}
179 }