]> Pileus Git - ~andy/gtk/blob - modules/other/gail/gailarrow.c
5f712340fa1deb6c8d5e7bcaae09c239395fd77a
[~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 <gtk/gtk.h>
21 #include "gailarrow.h"
22
23 static void gail_arrow_class_init       (GailArrowClass *klass);
24 static void gail_arrow_init             (GailArrow      *arrow);
25
26 /* AtkImage */
27 static void  atk_image_interface_init   (AtkImageIface  *iface);
28 static G_CONST_RETURN gchar* gail_arrow_get_image_description 
29                                         (AtkImage       *obj);
30 static gboolean gail_arrow_set_image_description 
31                                         (AtkImage       *obj,
32                                         const gchar    *description);
33 static void  gail_arrow_finalize       (GObject         *object);
34
35 G_DEFINE_TYPE_WITH_CODE (GailArrow, gail_arrow, GAIL_TYPE_WIDGET,
36                          G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
37
38 static void      
39 gail_arrow_class_init           (GailArrowClass *klass)
40 {
41   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
42
43   gobject_class->finalize = gail_arrow_finalize;
44 }
45
46 static void
47 gail_arrow_init (GailArrow *arrow)
48 {
49   arrow->image_description = NULL;
50 }
51
52 AtkObject* 
53 gail_arrow_new (GtkWidget *widget)
54 {
55   GObject *object;
56   AtkObject *accessible;
57
58   g_return_val_if_fail (GTK_IS_ARROW (widget), NULL);
59
60   object = g_object_new (GAIL_TYPE_ARROW, NULL);
61
62   accessible = ATK_OBJECT (object);
63   atk_object_initialize (accessible, widget);
64   accessible->role = ATK_ROLE_ICON;
65
66   return accessible;
67 }
68
69 static void
70 atk_image_interface_init (AtkImageIface *iface)
71 {
72   iface->get_image_description = gail_arrow_get_image_description;
73   iface->set_image_description = gail_arrow_set_image_description;
74 }
75
76 static G_CONST_RETURN gchar* 
77 gail_arrow_get_image_description (AtkImage       *obj)
78 {
79   GailArrow* arrow;
80
81   g_return_val_if_fail(GAIL_IS_ARROW(obj), NULL);
82
83   arrow = GAIL_ARROW (obj);
84
85   return arrow->image_description;
86 }
87
88 static gboolean 
89 gail_arrow_set_image_description (AtkImage       *obj,
90                                   const gchar    *description)
91 {
92   GailArrow* arrow;
93
94   g_return_val_if_fail(GAIL_IS_ARROW(obj), FALSE);
95
96   arrow = GAIL_ARROW (obj);
97   g_free (arrow->image_description);
98
99   arrow->image_description = g_strdup (description);
100
101   return TRUE;
102
103 }
104
105 /*
106  * static void  
107  * gail_arrow_get_image_size (AtkImage       *obj,
108  *                          gint           *height,
109  *                          gint           *width)
110  *
111  * We dont implement this function for GailArrow as gtk hardcodes the size 
112  * of the arrow to be 7x5 and it is not possible to query this.
113  */
114
115 static void
116 gail_arrow_finalize (GObject      *object)
117 {
118   GailArrow *arrow = GAIL_ARROW (object);
119
120   g_free (arrow->image_description);
121   G_OBJECT_CLASS (gail_arrow_parent_class)->finalize (object);
122 }