Add new error codes for when compilation fails and make compilation error
[platform/upstream/glib.git] / gio / gicon.c
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, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  */
22
23 #include <config.h>
24 #include "gicon.h"
25
26 #include "glibintl.h"
27
28 #include "gioalias.h"
29
30 /**
31  * SECTION:gicon
32  * @short_description: Interface for icons
33  *
34  * #GIcon is a very minimal interface for icons. It provides functions 
35  * for checking the equality of two icons and hashing of icons.
36  * 
37  * #GIcon does not provide the actual pixmap for the icon as this is out 
38  * of GIO's scope, however implementations of #GIcon may contain the name 
39  * of an icon (see #GThemedIcon), or the path to an icon (see #GLoadableIcon). 
40  * 
41  * To obtain a hash of a #GIcon, see g_icon_hash().
42  * 
43  * To check if two #GIcons are equal, see g_icon_equal().
44  **/
45
46 static void g_icon_base_init (gpointer g_class);
47 static void g_icon_class_init (gpointer g_class,
48                                gpointer class_data);
49
50 GType
51 g_icon_get_type (void)
52 {
53   static GType icon_type = 0;
54
55   if (! icon_type)
56     {
57       static const GTypeInfo icon_info =
58       {
59         sizeof (GIconIface), /* class_size */
60         g_icon_base_init,   /* base_init */
61         NULL,           /* base_finalize */
62         g_icon_class_init,
63         NULL,           /* class_finalize */
64         NULL,           /* class_data */
65         0,
66         0,              /* n_preallocs */
67         NULL
68       };
69
70       icon_type =
71         g_type_register_static (G_TYPE_INTERFACE, I_("GIcon"),
72                                 &icon_info, 0);
73
74       g_type_interface_add_prerequisite (icon_type, G_TYPE_OBJECT);
75     }
76
77   return icon_type;
78 }
79
80 static void
81 g_icon_class_init (gpointer g_class,
82                    gpointer class_data)
83 {
84 }
85
86 static void
87 g_icon_base_init (gpointer g_class)
88 {
89 }
90
91 /**
92  * g_icon_hash:
93  * @icon: #gconstpointer to an icon object.
94  * 
95  * Gets a hash for an icon.
96  * 
97  * Returns: a #guint containing a hash for the @icon, suitable for 
98  * use in a #GHashTable or similar data structure.
99  **/
100 guint
101 g_icon_hash (gconstpointer icon)
102 {
103   GIconIface *iface;
104
105   g_return_val_if_fail (G_IS_ICON (icon), 0);
106
107   iface = G_ICON_GET_IFACE (icon);
108
109   return (* iface->hash) ((GIcon *)icon);
110 }
111
112 /**
113  * g_icon_equal:
114  * @icon1: pointer to the first #GIcon.
115  * @icon2: pointer to the second #GIcon.
116  * 
117  * Checks if two icons are equal.
118  * 
119  * Returns: %TRUE if @icon1 is equal to @icon2. %FALSE otherwise.
120  **/
121 gboolean
122 g_icon_equal (GIcon *icon1,
123               GIcon *icon2)
124 {
125   GIconIface *iface;
126
127   if (icon1 == NULL && icon2 == NULL)
128     return TRUE;
129
130   if (icon1 == NULL || icon2 == NULL)
131     return FALSE;
132   
133   if (G_TYPE_FROM_INSTANCE (icon1) != G_TYPE_FROM_INSTANCE (icon2))
134     return FALSE;
135
136   iface = G_ICON_GET_IFACE (icon1);
137   
138   return (* iface->equal) (icon1, icon2);
139 }
140
141 #define __G_ICON_C__
142 #include "gioaliasdef.c"