From e6251f0248f7626e6d10d27e64d54cd1010d6895 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 2 Jul 2011 15:48:55 -0400 Subject: [PATCH] Move GtkSpinnerAccessible to a11y/ --- gtk/a11y/Makefile.am | 2 + gtk/a11y/gtkspinneraccessible.c | 83 +++++++++++++++++++++++++++++++++ gtk/a11y/gtkspinneraccessible.h | 51 ++++++++++++++++++++ gtk/gtkspinner.c | 64 +------------------------ 4 files changed, 137 insertions(+), 63 deletions(-) create mode 100644 gtk/a11y/gtkspinneraccessible.c create mode 100644 gtk/a11y/gtkspinneraccessible.h diff --git a/gtk/a11y/Makefile.am b/gtk/a11y/Makefile.am index 47ec89f818..03fd239734 100644 --- a/gtk/a11y/Makefile.am +++ b/gtk/a11y/Makefile.am @@ -40,6 +40,7 @@ gail_c_sources = \ gtkscrollbaraccessible.c \ gtkscrolledwindowaccessible.c \ gtkspinbuttonaccessible.c \ + gtkspinneraccessible.c \ gtksubmenuitemaccessible.c \ gtkstatusbaraccessible.c \ gailtextcell.c \ @@ -92,6 +93,7 @@ gail_private_h_sources = \ gtkscrollbaraccessible.h \ gtkscrolledwindowaccessible.h \ gtkspinbuttonaccessible.h \ + gtkspinneraccessible.h \ gtksubmenuitemaccessible.h \ gtkstatusbaraccessible.h \ gailtextcell.h \ diff --git a/gtk/a11y/gtkspinneraccessible.c b/gtk/a11y/gtkspinneraccessible.c new file mode 100644 index 0000000000..761ab5ab82 --- /dev/null +++ b/gtk/a11y/gtkspinneraccessible.c @@ -0,0 +1,83 @@ +/* GTK - The GIMP Toolkit + * + * Copyright (C) 2007 John Stowers, Neil Jagdish Patel. + * Copyright (C) 2009 Bastien Nocera, David Zeuthen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Code adapted from egg-spinner + * by Christian Hergert + */ + +#include "config.h" + +#include +#include "gtkintl.h" +#include "gtkspinneraccessible.h" + +static void atk_image_interface_init (AtkImageIface *iface); + +G_DEFINE_TYPE_WITH_CODE (GtkSpinnerAccessible, gtk_spinner_accessible, GTK_TYPE_WIDGET_ACCESSIBLE, + G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init)); + +static void +gtk_spinner_accessible_initialize (AtkObject *accessible, + gpointer widget) +{ + ATK_OBJECT_CLASS (gtk_spinner_accessible_parent_class)->initialize (accessible, widget); + + atk_object_set_name (accessible, C_("throbbing progress animation widget", "Spinner")); + atk_object_set_description (accessible, _("Provides visual indication of progress")); + atk_object_set_role (accessible, ATK_ROLE_ANIMATION); +} + +static void +gtk_spinner_accessible_class_init (GtkSpinnerAccessibleClass *klass) +{ + AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass); + + atk_class->initialize = gtk_spinner_accessible_initialize; +} + +static void +gtk_spinner_accessible_init (GtkSpinnerAccessible *self) +{ +} + +static void +gtk_spinner_accessible_image_get_size (AtkImage *image, + gint *width, + gint *height) +{ + GtkWidget *widget; + + widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image)); + if (widget == NULL) + { + *width = 0; + *height = 0; + return; + } + + *width = gtk_widget_get_allocated_width (widget); + *height = gtk_widget_get_allocated_height (widget); +} + +static void +atk_image_interface_init (AtkImageIface *iface) +{ + iface->get_image_size = gtk_spinner_accessible_image_get_size; +} diff --git a/gtk/a11y/gtkspinneraccessible.h b/gtk/a11y/gtkspinneraccessible.h new file mode 100644 index 0000000000..f52cd28e37 --- /dev/null +++ b/gtk/a11y/gtkspinneraccessible.h @@ -0,0 +1,51 @@ +/* GAIL - The GNOME Accessibility Implementation Library + * Copyright 2011 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GTK_SPINNER_ACCESSIBLE_H__ +#define __GTK_SPINNER_ACCESSIBLE_H__ + +#include "gtkwidgetaccessible.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_SPINNER_ACCESSIBLE (gtk_spinner_accessible_get_type ()) +#define GTK_SPINNER_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SPINNER_ACCESSIBLE, GtkSpinnerAccessible)) +#define GTK_SPINNER_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SPINNER_ACCESSIBLE, GtkSpinnerAccessibleClass)) +#define GTK_IS_SPINNER_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SPINNER_ACCESSIBLE)) +#define GTK_IS_SPINNER_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SPINNER_ACCESSIBLE)) +#define GTK_SPINNER_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SPINNER_ACCESSIBLE, GtkSpinnerAccessibleClass)) + +typedef struct _GtkSpinnerAccessible GtkSpinnerAccessible; +typedef struct _GtkSpinnerAccessibleClass GtkSpinnerAccessibleClass; + +struct _GtkSpinnerAccessible +{ + GtkWidgetAccessible parent; +}; + +struct _GtkSpinnerAccessibleClass +{ + GtkWidgetAccessibleClass parent_class; +}; + +GType gtk_spinner_accessible_get_type (void); + +G_END_DECLS + +#endif /* __GTK_SPINNER_ACCESSIBLE_H__ */ diff --git a/gtk/gtkspinner.c b/gtk/gtkspinner.c index 34d41046a9..8a5e360262 100644 --- a/gtk/gtkspinner.c +++ b/gtk/gtkspinner.c @@ -84,7 +84,6 @@ static void gtk_spinner_get_preferred_height (GtkWidget *widget, gint *minimum_size, gint *natural_size); -GType _gtk_spinner_accessible_get_type (void); G_DEFINE_TYPE (GtkSpinner, gtk_spinner, GTK_TYPE_WIDGET) @@ -118,7 +117,7 @@ gtk_spinner_class_init (GtkSpinnerClass *klass) FALSE, G_PARAM_READWRITE)); - gtk_widget_class_set_accessible_type (widget_class, _gtk_spinner_accessible_get_type ()); + gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SPINNER_ACCESSIBLE); } static void @@ -239,67 +238,6 @@ gtk_spinner_set_active (GtkSpinner *spinner, } } -/* accessible implementation */ - -static void -gtk_spinner_accessible_image_get_size (AtkImage *image, - gint *width, - gint *height) -{ - GtkAllocation allocation; - GtkWidget *widget; - - widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image)); - if (widget == NULL) - { - *width = *height = 0; - } - else - { - gtk_widget_get_allocation (widget, &allocation); - *width = allocation.width; - *height = allocation.height; - } -} - -static void -gtk_spinner_accessible_image_iface_init (AtkImageIface *iface) -{ - iface->get_image_size = gtk_spinner_accessible_image_get_size; -} - -/* dummy typedef */ -typedef GtkWidgetAccessible GtkSpinnerAccessible; -typedef GtkWidgetAccessibleClass GtkSpinnerAccessibleClass; - -G_DEFINE_TYPE_WITH_CODE (GtkSpinnerAccessible, _gtk_spinner_accessible, GTK_TYPE_WIDGET_ACCESSIBLE, - G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, - gtk_spinner_accessible_image_iface_init)); - -static void -gtk_spinner_accessible_initialize (AtkObject *accessible, - gpointer widget) -{ - ATK_OBJECT_CLASS (_gtk_spinner_accessible_parent_class)->initialize (accessible, widget); - - atk_object_set_name (accessible, C_("throbbing progress animation widget", "Spinner")); - atk_object_set_description (accessible, _("Provides visual indication of progress")); - atk_object_set_role (accessible, ATK_ROLE_ANIMATION); -} - -static void -_gtk_spinner_accessible_class_init (GtkSpinnerAccessibleClass *klass) -{ - AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass); - - atk_class->initialize = gtk_spinner_accessible_initialize; -} - -static void -_gtk_spinner_accessible_init (GtkSpinnerAccessible *self) -{ -} - /** * gtk_spinner_new: *