gicon.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* GIO - GLib Input, Output and Streaming Library
  2. *
  3. * Copyright (C) 2006-2007 Red Hat, Inc.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library 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 GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General
  16. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * Author: Alexander Larsson <alexl@redhat.com>
  19. */
  20. #ifndef __G_ICON_H__
  21. #define __G_ICON_H__
  22. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  23. #error "Only <gio/gio.h> can be included directly."
  24. #endif
  25. #include <gio/giotypes.h>
  26. G_BEGIN_DECLS
  27. #define G_TYPE_ICON (g_icon_get_type ())
  28. #define G_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_ICON, GIcon))
  29. #define G_IS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_ICON))
  30. #define G_ICON_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_ICON, GIconIface))
  31. /**
  32. * GIcon:
  33. *
  34. * An abstract type that specifies an icon.
  35. **/
  36. typedef struct _GIconIface GIconIface;
  37. /**
  38. * GIconIface:
  39. * @g_iface: The parent interface.
  40. * @hash: A hash for a given #GIcon.
  41. * @equal: Checks if two #GIcons are equal.
  42. * @to_tokens: Serializes a #GIcon into tokens. The tokens must not
  43. * contain any whitespace. Don't implement if the #GIcon can't be
  44. * serialized (Since 2.20).
  45. * @from_tokens: Constructs a #GIcon from tokens. Set the #GError if
  46. * the tokens are malformed. Don't implement if the #GIcon can't be
  47. * serialized (Since 2.20).
  48. * @serialize: Serializes a #GIcon into a #GVariant. Since: 2.38
  49. *
  50. * GIconIface is used to implement GIcon types for various
  51. * different systems. See #GThemedIcon and #GLoadableIcon for
  52. * examples of how to implement this interface.
  53. */
  54. struct _GIconIface
  55. {
  56. GTypeInterface g_iface;
  57. /* Virtual Table */
  58. guint (* hash) (GIcon *icon);
  59. gboolean (* equal) (GIcon *icon1,
  60. GIcon *icon2);
  61. gboolean (* to_tokens) (GIcon *icon,
  62. GPtrArray *tokens,
  63. gint *out_version);
  64. GIcon * (* from_tokens) (gchar **tokens,
  65. gint num_tokens,
  66. gint version,
  67. GError **error);
  68. GVariant * (* serialize) (GIcon *icon);
  69. };
  70. GLIB_AVAILABLE_IN_ALL
  71. GType g_icon_get_type (void) G_GNUC_CONST;
  72. GLIB_AVAILABLE_IN_ALL
  73. guint g_icon_hash (gconstpointer icon);
  74. GLIB_AVAILABLE_IN_ALL
  75. gboolean g_icon_equal (GIcon *icon1,
  76. GIcon *icon2);
  77. GLIB_AVAILABLE_IN_ALL
  78. gchar *g_icon_to_string (GIcon *icon);
  79. GLIB_AVAILABLE_IN_ALL
  80. GIcon *g_icon_new_for_string (const gchar *str,
  81. GError **error);
  82. GLIB_AVAILABLE_IN_2_38
  83. GVariant * g_icon_serialize (GIcon *icon);
  84. GLIB_AVAILABLE_IN_2_38
  85. GIcon * g_icon_deserialize (GVariant *value);
  86. G_END_DECLS
  87. #endif /* __G_ICON_H__ */