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