1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
3 /* GIO - GLib Input, Output and Streaming Library
5 * Copyright (C) 2006-2007 Red Hat, Inc.
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 of the License, or (at your option) any later version.
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.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 * Boston, MA 02111-1307, USA.
22 * Author: Matthias Clasen <mclasen@redhat.com>
29 #include "gemblemedicon.h"
35 * SECTION:gemblemedicon
36 * @short_description: Icon with emblems
38 * @see_also: #GIcon, #GLoadableIcon, #GThemedIcon
40 * #GEmblemedIcon is an implementation of #GIcon that supports
41 * adding an emblem to an icon. To add multiple emblems to an
42 * icon, you can create nested #GemblemedIcon<!-- -->s.
44 * Note that #GEmblemedIcon allows no control over the position
45 * of the emblems. It is up to the rendering code to pick a position.
48 static void g_emblemed_icon_icon_iface_init (GIconIface *iface);
52 GObject parent_instance;
58 struct _GEmblemedIconClass
60 GObjectClass parent_class;
63 G_DEFINE_TYPE_WITH_CODE (GEmblemedIcon, g_emblemed_icon, G_TYPE_OBJECT,
64 G_IMPLEMENT_INTERFACE (G_TYPE_ICON,
65 g_emblemed_icon_icon_iface_init))
69 g_emblemed_icon_finalize (GObject *object)
71 GEmblemedIcon *emblemed;
73 emblemed = G_EMBLEMED_ICON (object);
75 g_object_unref (emblemed->icon);
76 g_object_unref (emblemed->emblem);
78 (*G_OBJECT_CLASS (g_emblemed_icon_parent_class)->finalize) (object);
82 g_emblemed_icon_class_init (GEmblemedIconClass *klass)
84 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
85 gobject_class->finalize = g_emblemed_icon_finalize;
89 g_emblemed_icon_init (GEmblemedIcon *emblemed)
94 * g_emblemed_icon_new:
98 * Creates a new emblemed icon for @icon with emblem @emblem.
100 * Returns: a new #GEmblemedIcon.
105 g_emblemed_icon_new (GIcon *icon,
108 GEmblemedIcon *emblemed;
110 g_return_val_if_fail (icon != NULL, NULL);
111 g_return_val_if_fail (emblem != NULL, NULL);
113 emblemed = G_EMBLEMED_ICON (g_object_new (G_TYPE_EMBLEMED_ICON, NULL));
114 emblemed->icon = g_object_ref (icon);
115 emblemed->emblem = g_object_ref (emblem);
117 return G_ICON (emblemed);
121 * g_emblemed_icon_get_icon:
122 * @icon: a #GEmblemedIcon.
124 * Gets the main icon for @icon.
126 * Returns: a #GIcon that is owend by @icon
131 g_emblemed_icon_get_icon (GEmblemedIcon *icon)
133 g_return_val_if_fail (G_IS_EMBLEMED_ICON (icon), NULL);
139 * g_emblemed_icon_get_emblem:
140 * @icon: a #GEmblemedIcon.
142 * Gets the emblem for @icon.
144 * Returns: a #GIcon that is owned by @icon
149 g_emblemed_icon_get_emblem (GEmblemedIcon *icon)
151 g_return_val_if_fail (G_IS_EMBLEMED_ICON (icon), NULL);
157 g_emblemed_icon_hash (GIcon *icon)
159 GEmblemedIcon *emblemed = G_EMBLEMED_ICON (icon);
162 hash = g_icon_hash (emblemed->icon);
163 hash ^= g_icon_hash (emblemed->emblem);
169 g_emblemed_icon_equal (GIcon *icon1,
172 GEmblemedIcon *emblemed1 = G_EMBLEMED_ICON (icon1);
173 GEmblemedIcon *emblemed2 = G_EMBLEMED_ICON (icon2);
175 return g_icon_equal (emblemed1->icon, emblemed2->icon) &&
176 g_icon_equal (emblemed1->emblem, emblemed2->emblem);
180 g_emblemed_icon_icon_iface_init (GIconIface *iface)
182 iface->hash = g_emblemed_icon_hash;
183 iface->equal = g_emblemed_icon_equal;
186 #define __G_EMBLEMED_ICON_C__
187 #include "gioaliasdef.c"