gicon.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* GIO - GLib Input, Output and Streaming Library
  2. *
  3. * Copyright (C) 2006-2007 Red Hat, Inc.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. *
  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.
  11. *
  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.
  16. *
  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/>.
  19. *
  20. * Author: Alexander Larsson <alexl@redhat.com>
  21. */
  22. #ifndef __G_ICON_H__
  23. #define __G_ICON_H__
  24. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  25. #error "Only <gio/gio.h> can be included directly."
  26. #endif
  27. #include <gio/giotypes.h>
  28. G_BEGIN_DECLS
  29. #define G_TYPE_ICON (g_icon_get_type ())
  30. #define G_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_ICON, GIcon))
  31. #define G_IS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_ICON))
  32. #define G_ICON_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_ICON, GIconIface))
  33. typedef struct _GIconIface GIconIface;
  34. /**
  35. * GIconIface:
  36. * @g_iface: The parent interface.
  37. * @hash: A hash for a given #GIcon.
  38. * @equal: Checks if two #GIcons are equal.
  39. * @to_tokens: Serializes a #GIcon into tokens. The tokens must not
  40. * contain any whitespace. Don't implement if the #GIcon can't be
  41. * serialized (Since 2.20).
  42. * @from_tokens: Constructs a #GIcon from tokens. Set the #GError if
  43. * the tokens are malformed. Don't implement if the #GIcon can't be
  44. * serialized (Since 2.20).
  45. * @serialize: Serializes a #GIcon into a #GVariant. Since: 2.38
  46. *
  47. * GIconIface is used to implement GIcon types for various
  48. * different systems. See #GThemedIcon and #GLoadableIcon for
  49. * examples of how to implement this interface.
  50. */
  51. struct _GIconIface
  52. {
  53. GTypeInterface g_iface;
  54. /* Virtual Table */
  55. guint (* hash) (GIcon *icon);
  56. gboolean (* equal) (GIcon *icon1,
  57. GIcon *icon2);
  58. /**
  59. * GIconIface::to_tokens:
  60. * @icon: The #GIcon
  61. * @tokens: (element-type utf8) (out caller-allocates):
  62. * The array to fill with tokens
  63. * @out_version: (out): version of serialized tokens
  64. *
  65. * Serializes the @icon into string tokens.
  66. * This is can be invoked when g_icon_new_for_string() is called.
  67. *
  68. * Returns: %TRUE if serialization took place, %FALSE otherwise
  69. *
  70. * Since: 2.20
  71. */
  72. gboolean (* to_tokens) (GIcon *icon,
  73. GPtrArray *tokens,
  74. gint *out_version);
  75. /**
  76. * GIconIface::from_tokens:
  77. * @tokens: (array length=num_tokens): An array of tokens
  78. * @num_tokens: The number of tokens in @tokens
  79. * @version: Version of the serialized tokens
  80. * @error: Return location for errors, or %NULL to ignore
  81. *
  82. * Constructs a #GIcon from a list of @tokens.
  83. *
  84. * Returns: (nullable) (transfer full): the #GIcon or %NULL on error
  85. *
  86. * Since: 2.20
  87. */
  88. GIcon * (* from_tokens) (gchar **tokens,
  89. gint num_tokens,
  90. gint version,
  91. GError **error);
  92. GVariant * (* serialize) (GIcon *icon);
  93. };
  94. GIO_AVAILABLE_IN_ALL
  95. GType g_icon_get_type (void) G_GNUC_CONST;
  96. GIO_AVAILABLE_IN_ALL
  97. guint g_icon_hash (gconstpointer icon);
  98. GIO_AVAILABLE_IN_ALL
  99. gboolean g_icon_equal (GIcon *icon1,
  100. GIcon *icon2);
  101. GIO_AVAILABLE_IN_ALL
  102. gchar *g_icon_to_string (GIcon *icon);
  103. GIO_AVAILABLE_IN_ALL
  104. GIcon *g_icon_new_for_string (const gchar *str,
  105. GError **error);
  106. GIO_AVAILABLE_IN_2_38
  107. GVariant * g_icon_serialize (GIcon *icon);
  108. GIO_AVAILABLE_IN_2_38
  109. GIcon * g_icon_deserialize (GVariant *value);
  110. G_END_DECLS
  111. #endif /* __G_ICON_H__ */