source: appstream-generator/build/girepo/gio/IconT.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 5.3 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.IconT;
22
23public  import gi.gio;
24public  import gi.giotypes;
25public  import gio.Icon;
26public  import gio.IconIF;
27public  import glib.ConstructionException;
28public  import glib.ErrorG;
29public  import glib.GException;
30public  import glib.Str;
31public  import glib.Variant;
32public  import gobject.ObjectG;
33
34
35/**
36 * #GIcon is a very minimal interface for icons. It provides functions
37 * for checking the equality of two icons, hashing of icons and
38 * serializing an icon to and from strings.
39 *
40 * #GIcon does not provide the actual pixmap for the icon as this is out
41 * of GIO's scope, however implementations of #GIcon may contain the name
42 * of an icon (see #GThemedIcon), or the path to an icon (see #GLoadableIcon).
43 *
44 * To obtain a hash of a #GIcon, see g_icon_hash().
45 *
46 * To check if two #GIcons are equal, see g_icon_equal().
47 *
48 * For serializing a #GIcon, use g_icon_serialize() and
49 * g_icon_deserialize().
50 *
51 * If you want to consume #GIcon (for example, in a toolkit) you must
52 * be prepared to handle at least the three following cases:
53 * #GLoadableIcon, #GThemedIcon and #GEmblemedIcon.  It may also make
54 * sense to have fast-paths for other cases (like handling #GdkPixbuf
55 * directly, for example) but all compliant #GIcon implementations
56 * outside of GIO must implement #GLoadableIcon.
57 *
58 * If your application or library provides one or more #GIcon
59 * implementations you need to ensure that your new implementation also
60 * implements #GLoadableIcon.  Additionally, you must provide an
61 * implementation of g_icon_serialize() that gives a result that is
62 * understood by g_icon_deserialize(), yielding one of the built-in icon
63 * types.
64 */
65public template IconT(TStruct)
66{
67        /** Get the main Gtk struct */
68        public GIcon* getIconStruct()
69        {
70                return cast(GIcon*)getStruct();
71        }
72
73
74        /**
75         * Deserializes a #GIcon previously serialized using g_icon_serialize().
76         *
77         * Params:
78         *     value = a #GVariant created with g_icon_serialize()
79         *
80         * Returns: a #GIcon, or %NULL when deserialization fails.
81         *
82         * Since: 2.38
83         */
84        public static IconIF deserialize(Variant value)
85        {
86                auto p = g_icon_deserialize((value is null) ? null : value.getVariantStruct());
87               
88                if(p is null)
89                {
90                        return null;
91                }
92               
93                return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p, true);
94        }
95
96        /**
97         * Gets a hash for an icon.
98         *
99         * Params:
100         *     icon = #gconstpointer to an icon object.
101         *
102         * Returns: a #guint containing a hash for the @icon, suitable for
103         *     use in a #GHashTable or similar data structure.
104         */
105        public static uint hash(void* icon)
106        {
107                return g_icon_hash(icon);
108        }
109
110        /**
111         * Checks if two icons are equal.
112         *
113         * Params:
114         *     icon2 = pointer to the second #GIcon.
115         *
116         * Returns: %TRUE if @icon1 is equal to @icon2. %FALSE otherwise.
117         */
118        public bool equal(IconIF icon2)
119        {
120                return g_icon_equal(getIconStruct(), (icon2 is null) ? null : icon2.getIconStruct()) != 0;
121        }
122
123        /**
124         * Serializes a #GIcon into a #GVariant. An equivalent #GIcon can be retrieved
125         * back by calling g_icon_deserialize() on the returned value.
126         * As serialization will avoid using raw icon data when possible, it only
127         * makes sense to transfer the #GVariant between processes on the same machine,
128         * (as opposed to over the network), and within the same file system namespace.
129         *
130         * Returns: a #GVariant, or %NULL when serialization fails.
131         *
132         * Since: 2.38
133         */
134        public Variant serialize()
135        {
136                auto p = g_icon_serialize(getIconStruct());
137               
138                if(p is null)
139                {
140                        return null;
141                }
142               
143                return new Variant(cast(GVariant*) p, true);
144        }
145
146        /**
147         * Generates a textual representation of @icon that can be used for
148         * serialization such as when passing @icon to a different process or
149         * saving it to persistent storage. Use g_icon_new_for_string() to
150         * get @icon back from the returned string.
151         *
152         * The encoding of the returned string is proprietary to #GIcon except
153         * in the following two cases
154         *
155         * - If @icon is a #GFileIcon, the returned string is a native path
156         * (such as `/path/to/my icon.png`) without escaping
157         * if the #GFile for @icon is a native file.  If the file is not
158         * native, the returned string is the result of g_file_get_uri()
159         * (such as `sftp://path/to/my%20icon.png`).
160         *
161         * - If @icon is a #GThemedIcon with exactly one name, the encoding is
162         * simply the name (such as `network-server`).
163         *
164         * Returns: An allocated NUL-terminated UTF8 string or
165         *     %NULL if @icon can't be serialized. Use g_free() to free.
166         *
167         * Since: 2.20
168         */
169        public override string toString()
170        {
171                auto retStr = g_icon_to_string(getIconStruct());
172               
173                scope(exit) Str.freeString(retStr);
174                return Str.toString(retStr);
175        }
176}
Note: See TracBrowser for help on using the repository browser.