]> Pileus Git - ~andy/gtk/blob - modules/other/gail/gailarrow.c
9253d8476988adc48e2b2259e66022481e0b883f
[~andy/gtk] / modules / other / gail / gailarrow.c
1 /* GAIL - The GNOME Accessibility Implementation Library
2  * Copyright 2001 Sun Microsystems Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "config.h"
21
22 #include <gtk/gtk.h>
23 #include "gailarrow.h"
24
25 static void gail_arrow_class_init       (GailArrowClass *klass);
26 static void gail_arrow_init             (GailArrow      *arrow);
27 static void gail_arrow_initialize       (AtkObject      *accessible,
28                                          gpointer        data);
29
30 /* AtkImage */
31 static void  atk_image_interface_init   (AtkImageIface  *iface);
32 static const gchar* gail_arrow_get_image_description
33                                         (AtkImage       *obj);
34 static gboolean gail_arrow_set_image_description 
35                                         (AtkImage       *obj,
36                                         const gchar    *description);
37 static void  gail_arrow_finalize       (GObject         *object);
38
39 G_DEFINE_TYPE_WITH_CODE (GailArrow, gail_arrow, GAIL_TYPE_WIDGET,
40                          G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
41
42 static void      
43 gail_arrow_class_init           (GailArrowClass *klass)
44 {
45   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
46   AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
47
48   atk_object_class->initialize = gail_arrow_initialize;
49
50   gobject_class->finalize = gail_arrow_finalize;
51 }
52
53 static void
54 gail_arrow_init (GailArrow *arrow)
55 {
56   arrow->image_description = NULL;
57 }
58
59 static void
60 gail_arrow_initialize (AtkObject *accessible,
61                        gpointer data)
62 {
63   ATK_OBJECT_CLASS (gail_arrow_parent_class)->initialize (accessible, data);
64
65   accessible->role = ATK_ROLE_ICON;
66 }
67
68 static void
69 atk_image_interface_init (AtkImageIface *iface)
70 {
71   iface->get_image_description = gail_arrow_get_image_description;
72   iface->set_image_description = gail_arrow_set_image_description;
73 }
74
75 static const gchar*
76 gail_arrow_get_image_description (AtkImage       *obj)
77 {
78   GailArrow* arrow;
79
80   g_return_val_if_fail(GAIL_IS_ARROW(obj), NULL);
81
82   arrow = GAIL_ARROW (obj);
83
84   return arrow->image_description;
85 }
86
87 static gboolean 
88 gail_arrow_set_image_description (AtkImage       *obj,
89                                   const gchar    *description)
90 {
91   GailArrow* arrow;
92
93   g_return_val_if_fail(GAIL_IS_ARROW(obj), FALSE);
94
95   arrow = GAIL_ARROW (obj);
96   g_free (arrow->image_description);
97
98   arrow->image_description = g_strdup (description);
99
100   return TRUE;
101
102 }
103
104 /*
105  * static void  
106  * gail_arrow_get_image_size (AtkImage       *obj,
107  *                          gint           *height,
108  *                          gint           *width)
109  *
110  * We dont implement this function for GailArrow as gtk hardcodes the size 
111  * of the arrow to be 7x5 and it is not possible to query this.
112  */
113
114 static void
115 gail_arrow_finalize (GObject      *object)
116 {
117   GailArrow *arrow = GAIL_ARROW (object);
118
119   g_free (arrow->image_description);
120   G_OBJECT_CLASS (gail_arrow_parent_class)->finalize (object);
121 }