1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * SPDX-License-Identifier: LGPL-2.1-or-later
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 * Author: Alexander Larsson <alexl@redhat.com>
26 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
27 #error "Only <gio/gio.h> can be included directly."
30 #include <gio/giotypes.h>
34 #define G_TYPE_ICON (g_icon_get_type ())
35 #define G_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_ICON, GIcon))
36 #define G_IS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_ICON))
37 #define G_ICON_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_ICON, GIconIface))
42 * An abstract type that specifies an icon.
44 typedef struct _GIconIface GIconIface;
48 * @g_iface: The parent interface.
49 * @hash: A hash for a given #GIcon.
50 * @equal: Checks if two #GIcons are equal.
51 * @to_tokens: Serializes a #GIcon into tokens. The tokens must not
52 * contain any whitespace. Don't implement if the #GIcon can't be
53 * serialized (Since 2.20).
54 * @from_tokens: Constructs a #GIcon from tokens. Set the #GError if
55 * the tokens are malformed. Don't implement if the #GIcon can't be
56 * serialized (Since 2.20).
57 * @serialize: Serializes a #GIcon into a #GVariant. Since: 2.38
59 * GIconIface is used to implement GIcon types for various
60 * different systems. See #GThemedIcon and #GLoadableIcon for
61 * examples of how to implement this interface.
65 GTypeInterface g_iface;
69 guint (* hash) (GIcon *icon);
70 gboolean (* equal) (GIcon *icon1,
74 * GIconIface::to_tokens:
76 * @tokens: (element-type utf8) (out caller-allocates):
77 * The array to fill with tokens
78 * @out_version: (out): version of serialized tokens
80 * Serializes the @icon into string tokens.
81 * This is can be invoked when g_icon_new_for_string() is called.
83 * Returns: %TRUE if serialization took place, %FALSE otherwise
87 gboolean (* to_tokens) (GIcon *icon,
92 * GIconIface::from_tokens:
93 * @tokens: (array length=num_tokens): An array of tokens
94 * @num_tokens: The number of tokens in @tokens
95 * @version: Version of the serialized tokens
96 * @error: Return location for errors, or %NULL to ignore
98 * Constructs a #GIcon from a list of @tokens.
100 * Returns: (nullable) (transfer full): the #GIcon or %NULL on error
104 GIcon * (* from_tokens) (gchar **tokens,
109 GVariant * (* serialize) (GIcon *icon);
113 GType g_icon_get_type (void) G_GNUC_CONST;
116 guint g_icon_hash (gconstpointer icon);
118 gboolean g_icon_equal (GIcon *icon1,
121 gchar *g_icon_to_string (GIcon *icon);
123 GIcon *g_icon_new_for_string (const gchar *str,
126 GIO_AVAILABLE_IN_2_38
127 GVariant * g_icon_serialize (GIcon *icon);
128 GIO_AVAILABLE_IN_2_38
129 GIcon * g_icon_deserialize (GVariant *value);
133 #endif /* __G_ICON_H__ */