]> Pileus Git - ~andy/gtk/blob - modules/other/gail/gailpixmap.c
Include gtkspinner.h in GtkStyle
[~andy/gtk] / modules / other / gail / gailpixmap.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 #undef GTK_DISABLE_DEPRECATED
23
24 #include <gtk/gtk.h>
25
26 #include "gailpixmap.h"
27
28 static void      gail_pixmap_class_init         (GailPixmapClass *klass);
29 static void      gail_pixmap_init               (GailPixmap      *pixmap);
30 static void      gail_pixmap_initialize         (AtkObject       *accessible,
31                                                  gpointer         data);
32
33 /* AtkImage */
34 static void  atk_image_interface_init   (AtkImageIface  *iface);
35 static G_CONST_RETURN gchar* gail_pixmap_get_image_description 
36                                         (AtkImage       *obj);
37 static void  gail_pixmap_get_image_position    
38                                         (AtkImage       *obj,
39                                          gint           *x,
40                                          gint           *y,
41                                          AtkCoordType   coord_type);
42 static void  gail_pixmap_get_image_size (AtkImage       *obj,
43                                          gint           *width,
44                                          gint           *height);
45 static gboolean gail_pixmap_set_image_description 
46                                         (AtkImage       *obj,
47                                         const gchar    *description);
48 static void  gail_pixmap_finalize       (GObject         *object);
49
50 G_DEFINE_TYPE_WITH_CODE (GailPixmap, gail_pixmap, GAIL_TYPE_WIDGET,
51                          G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
52
53 static void      
54 gail_pixmap_class_init (GailPixmapClass *klass)
55 {
56   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
57   AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
58  
59   atk_object_class->initialize = gail_pixmap_initialize;
60
61   gobject_class->finalize = gail_pixmap_finalize;
62 }
63
64 static void
65 gail_pixmap_init (GailPixmap *pixmap)
66 {
67   pixmap->image_description = NULL;
68 }
69
70 static void
71 gail_pixmap_initialize (AtkObject *accessible,
72                         gpointer  data)
73 {
74   ATK_OBJECT_CLASS (gail_pixmap_parent_class)->initialize (accessible, data);
75
76   accessible->role = ATK_ROLE_ICON;
77 }
78
79 static void
80 atk_image_interface_init (AtkImageIface *iface)
81 {
82   iface->get_image_description = gail_pixmap_get_image_description;
83   iface->get_image_position = gail_pixmap_get_image_position;
84   iface->get_image_size = gail_pixmap_get_image_size;
85   iface->set_image_description = gail_pixmap_set_image_description;
86 }
87
88 static G_CONST_RETURN gchar* 
89 gail_pixmap_get_image_description (AtkImage       *obj)
90 {
91   GailPixmap* pixmap;
92
93   g_return_val_if_fail (GAIL_IS_PIXMAP (obj), NULL);
94
95   pixmap = GAIL_PIXMAP (obj);
96
97   return pixmap->image_description;
98 }
99
100 static void
101 gail_pixmap_get_image_position (AtkImage       *obj,
102                                 gint           *x,
103                                 gint           *y,
104                                 AtkCoordType   coord_type)
105 {
106   atk_component_get_position (ATK_COMPONENT (obj), x, y, coord_type);
107 }
108
109 static void  
110 gail_pixmap_get_image_size (AtkImage       *obj,
111                             gint           *width,
112                             gint           *height)
113 {
114   GtkWidget *widget;
115   GtkPixmap *pixmap;
116  
117   *width = -1;
118   *height = -1;
119
120   g_return_if_fail (GAIL_IS_PIXMAP (obj));
121
122   widget = GTK_ACCESSIBLE (obj)->widget;
123   if (widget == 0)
124     /* State is defunct */
125     return;
126
127   g_return_if_fail (GTK_IS_PIXMAP (widget));
128
129   pixmap = GTK_PIXMAP (widget);
130
131   if (pixmap->pixmap)
132     gdk_drawable_get_size (pixmap->pixmap, width, height);
133 }
134
135 static gboolean 
136 gail_pixmap_set_image_description (AtkImage       *obj,
137                                    const gchar    *description)
138
139   GailPixmap* pixmap;
140
141   g_return_val_if_fail (GAIL_IS_PIXMAP (obj), FALSE);
142
143   pixmap = GAIL_PIXMAP (obj);
144   g_free (pixmap->image_description);
145
146   pixmap->image_description = g_strdup (description);
147
148   return TRUE;
149 }
150
151 static void
152 gail_pixmap_finalize (GObject      *object)
153 {
154   GailPixmap *pixmap = GAIL_PIXMAP (object);
155
156   g_free (pixmap->image_description);
157   G_OBJECT_CLASS (gail_pixmap_parent_class)->finalize (object);
158 }