Added. Added. Added. Added.
[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 static void g_icon_base_init (gpointer g_class);
31 static void g_icon_class_init (gpointer g_class,
32                                gpointer class_data);
33
34 GType
35 g_icon_get_type (void)
36 {
37   static GType icon_type = 0;
38
39   if (! icon_type)
40     {
41       static const GTypeInfo icon_info =
42       {
43         sizeof (GIconIface), /* class_size */
44         g_icon_base_init,   /* base_init */
45         NULL,           /* base_finalize */
46         g_icon_class_init,
47         NULL,           /* class_finalize */
48         NULL,           /* class_data */
49         0,
50         0,              /* n_preallocs */
51         NULL
52       };
53
54       icon_type =
55         g_type_register_static (G_TYPE_INTERFACE, I_("GIcon"),
56                                 &icon_info, 0);
57
58       g_type_interface_add_prerequisite (icon_type, G_TYPE_OBJECT);
59     }
60
61   return icon_type;
62 }
63
64 static void
65 g_icon_class_init (gpointer g_class,
66                    gpointer class_data)
67 {
68 }
69
70 static void
71 g_icon_base_init (gpointer g_class)
72 {
73 }
74
75 /**
76  * g_icon_hash:
77  * @icon: #gconstpointer to an icon object.
78  * 
79  * Gets a hash for an icon.
80  * 
81  * Returns: a #guint containing a hash for the @icon, suitable for 
82  * use in a #GHashTable or similar data structure.
83  **/
84 guint
85 g_icon_hash (gconstpointer icon)
86 {
87   GIconIface *iface;
88
89   g_return_val_if_fail (G_IS_ICON (icon), 0);
90
91   iface = G_ICON_GET_IFACE (icon);
92
93   return (* iface->hash) ((GIcon *)icon);
94 }
95
96 /**
97  * g_icon_equal:
98  * @icon1: pointer to the first #GIcon.
99  * @icon2: pointer to the second #GIcon.
100  * 
101  * Checks if two icons are equal.
102  * 
103  * Returns: %TRUE if @icon1 is equal to @icon2. %FALSE otherwise.
104  **/
105 gboolean
106 g_icon_equal (GIcon *icon1,
107               GIcon *icon2)
108 {
109   GIconIface *iface;
110
111   if (icon1 == NULL && icon2 == NULL)
112     return TRUE;
113
114   if (icon1 == NULL || icon2 == NULL)
115     return FALSE;
116   
117   if (G_TYPE_FROM_INSTANCE (icon1) != G_TYPE_FROM_INSTANCE (icon2))
118     return FALSE;
119
120   iface = G_ICON_GET_IFACE (icon1);
121   
122   return (* iface->equal) (icon1, icon2);
123 }
124
125 #define __G_ICON_C__
126 #include "gioaliasdef.c"