]> Pileus Git - ~andy/gtk/blob - gtk/a11y/gtkspinneraccessible.c
a11y: create focus cell accessibles when they get focused
[~andy/gtk] / gtk / a11y / gtkspinneraccessible.c
1 /* GTK - The GIMP Toolkit
2  *
3  * Copyright (C) 2007 John Stowers, Neil Jagdish Patel.
4  * Copyright (C) 2009 Bastien Nocera, David Zeuthen
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA  02111-1307, USA.
20  *
21  * Code adapted from egg-spinner
22  * by Christian Hergert <christian.hergert@gmail.com>
23  */
24
25 #include "config.h"
26
27 #include <gtk/gtk.h>
28 #include "gtkintl.h"
29 #include "gtkspinneraccessible.h"
30
31 static void atk_image_interface_init (AtkImageIface *iface);
32
33 G_DEFINE_TYPE_WITH_CODE (GtkSpinnerAccessible, _gtk_spinner_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
34                          G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init));
35
36 static void
37 gtk_spinner_accessible_initialize (AtkObject *accessible,
38                                    gpointer   widget)
39 {
40   ATK_OBJECT_CLASS (_gtk_spinner_accessible_parent_class)->initialize (accessible, widget);
41
42   atk_object_set_name (accessible, C_("throbbing progress animation widget", "Spinner"));
43   atk_object_set_description (accessible, _("Provides visual indication of progress"));
44   atk_object_set_role (accessible, ATK_ROLE_ANIMATION);
45 }
46
47 static void
48 _gtk_spinner_accessible_class_init (GtkSpinnerAccessibleClass *klass)
49 {
50   AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
51
52   atk_class->initialize = gtk_spinner_accessible_initialize;
53 }
54
55 static void
56 _gtk_spinner_accessible_init (GtkSpinnerAccessible *self)
57 {
58 }
59
60 static void
61 gtk_spinner_accessible_image_get_size (AtkImage *image,
62                                        gint     *width,
63                                        gint     *height)
64 {
65   GtkWidget *widget;
66
67   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image));
68   if (widget == NULL)
69     {
70       *width = 0;
71       *height = 0;
72       return;
73     }
74
75   *width = gtk_widget_get_allocated_width (widget);
76   *height = gtk_widget_get_allocated_height (widget);
77 }
78
79 static void
80 atk_image_interface_init (AtkImageIface *iface)
81 {
82   iface->get_image_size = gtk_spinner_accessible_image_get_size;
83 }