Move GtkSpinnerAccessible to a11y/

This commit is contained in:
Matthias Clasen 2011-07-02 15:48:55 -04:00
parent f839379d01
commit e6251f0248
4 changed files with 137 additions and 63 deletions

View File

@ -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 \

View File

@ -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 <christian.hergert@gmail.com>
*/
#include "config.h"
#include <gtk/gtk.h>
#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;
}

View File

@ -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__ */

View File

@ -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:
*