Convert GailRadioButton to GtkRadioButtonAccessible

This commit is contained in:
Matthias Clasen 2011-06-27 23:24:22 -04:00
parent 369b4a605e
commit e2847d9637
7 changed files with 174 additions and 188 deletions

View File

@ -31,7 +31,7 @@ gail_c_sources = \
gailnotebookpage.c \
gtkpanedaccessible.c \
gtkprogressbaraccessible.c \
gailradiobutton.c \
gtkradiobuttonaccessible.c \
gailradiomenuitem.c \
gailradiosubmenuitem.c \
gtkrangeaccessible.c \
@ -83,7 +83,7 @@ gail_private_h_sources = \
gailnotebookpage.h \
gtkpanedaccessible.h \
gtkprogressbaraccessible.h \
gailradiobutton.h \
gtkradiobuttonaccessible.h \
gailradiomenuitem.h \
gailradiosubmenuitem.h \
gtkrangeaccessible.h \

View File

@ -37,7 +37,6 @@
#include "gailmenushell.h"
#include "gailmenuitem.h"
#include "gailnotebook.h"
#include "gailradiobutton.h"
#include "gailradiomenuitem.h"
#include "gailrenderercell.h"
#include "gailscalebutton.h"
@ -110,7 +109,6 @@ GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_SCALE_BUTTON, GailScaleButton, gail_scale_butt
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_STATUSBAR, GailStatusbar, gail_statusbar, GTK_TYPE_STATUSBAR)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_NOTEBOOK, GailNotebook, gail_notebook, GTK_TYPE_NOTEBOOK)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_TREE_VIEW, GailTreeView, gail_tree_view, GTK_TYPE_TREE_VIEW)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_RADIO_BUTTON, GailRadioButton, gail_radio_button, GTK_TYPE_RADIO_BUTTON)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_SCROLLED_WINDOW, GailScrolledWindow, gail_scrolled_window, GTK_TYPE_SCROLLED_WINDOW)
GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_CHECK_MENU_ITEM, GailCheckMenuItem, gail_check_menu_item, gail_check_menu_item_new)
GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_RADIO_MENU_ITEM, GailRadioMenuItem, gail_radio_menu_item, gail_radio_menu_item_new)
@ -876,7 +874,6 @@ gail_accessibility_module_init (void)
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_TOGGLE, gail_boolean_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_PIXBUF, gail_image_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER, gail_renderer_cell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_RADIO_BUTTON, gail_radio_button);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SCROLLED_WINDOW, gail_scrolled_window);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CHECK_MENU_ITEM, gail_check_menu_item);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_RADIO_MENU_ITEM, gail_radio_menu_item);

View File

@ -1,130 +0,0 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* 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.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gailradiobutton.h"
static void gail_radio_button_class_init (GailRadioButtonClass *klass);
static void gail_radio_button_init (GailRadioButton *radio_button);
static void gail_radio_button_initialize (AtkObject *accessible,
gpointer data);
static AtkRelationSet* gail_radio_button_ref_relation_set (AtkObject *obj);
G_DEFINE_TYPE (GailRadioButton, gail_radio_button, GAIL_TYPE_TOGGLE_BUTTON)
static void
gail_radio_button_class_init (GailRadioButtonClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->initialize = gail_radio_button_initialize;
class->ref_relation_set = gail_radio_button_ref_relation_set;
}
static void
gail_radio_button_init (GailRadioButton *radio_button)
{
radio_button->old_group = NULL;
}
static void
gail_radio_button_initialize (AtkObject *accessible,
gpointer data)
{
ATK_OBJECT_CLASS (gail_radio_button_parent_class)->initialize (accessible, data);
accessible->role = ATK_ROLE_RADIO_BUTTON;
}
AtkRelationSet*
gail_radio_button_ref_relation_set (AtkObject *obj)
{
GtkWidget *widget;
AtkRelationSet *relation_set;
GSList *list;
GailRadioButton *radio_button;
g_return_val_if_fail (GAIL_IS_RADIO_BUTTON (obj), NULL);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
{
/*
* State is defunct
*/
return NULL;
}
radio_button = GAIL_RADIO_BUTTON (obj);
relation_set = ATK_OBJECT_CLASS (gail_radio_button_parent_class)->ref_relation_set (obj);
/*
* If the radio button'group has changed remove the relation
*/
list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
if (radio_button->old_group != list)
{
AtkRelation *relation;
relation = atk_relation_set_get_relation_by_type (relation_set, ATK_RELATION_MEMBER_OF);
atk_relation_set_remove (relation_set, relation);
}
if (!atk_relation_set_contains (relation_set, ATK_RELATION_MEMBER_OF))
{
/*
* Get the members of the button group
*/
radio_button->old_group = list;
if (list)
{
AtkObject **accessible_array;
guint list_length;
AtkRelation* relation;
gint i = 0;
list_length = g_slist_length (list);
accessible_array = (AtkObject**) g_malloc (sizeof (AtkObject *) *
list_length);
while (list != NULL)
{
GtkWidget* list_item = list->data;
accessible_array[i++] = gtk_widget_get_accessible (list_item);
list = list->next;
}
relation = atk_relation_new (accessible_array, list_length,
ATK_RELATION_MEMBER_OF);
g_free (accessible_array);
atk_relation_set_add (relation_set, relation);
/*
* Unref the relation so that it is not leaked.
*/
g_object_unref (relation);
}
}
return relation_set;
}

View File

@ -1,53 +0,0 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems 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 __GAIL_RADIO_BUTTON_H__
#define __GAIL_RADIO_BUTTON_H__
#include "gailtogglebutton.h"
G_BEGIN_DECLS
#define GAIL_TYPE_RADIO_BUTTON (gail_radio_button_get_type ())
#define GAIL_RADIO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_RADIO_BUTTON, GailRadioButton))
#define GAIL_RADIO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_RADIO_BUTTON, GailRadioButtonClass))
#define GAIL_IS_RADIO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_RADIO_BUTTON))
#define GAIL_IS_RADIO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_RADIO_BUTTON))
#define GAIL_RADIO_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_RADIO_BUTTON, GailRadioButtonClass))
typedef struct _GailRadioButton GailRadioButton;
typedef struct _GailRadioButtonClass GailRadioButtonClass;
struct _GailRadioButton
{
GailToggleButton parent;
GSList *old_group;
};
GType gail_radio_button_get_type (void);
struct _GailRadioButtonClass
{
GailToggleButtonClass parent_class;
};
G_END_DECLS
#endif /* __GAIL_RADIO_BUTTON_H__ */

View File

@ -0,0 +1,116 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
*
* 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.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gtkradiobuttonaccessible.h"
G_DEFINE_TYPE (GtkRadioButtonAccessible, gtk_radio_button_accessible, GAIL_TYPE_TOGGLE_BUTTON)
static void
gtk_radio_button_accessible_initialize (AtkObject *accessible,
gpointer data)
{
ATK_OBJECT_CLASS (gtk_radio_button_accessible_parent_class)->initialize (accessible, data);
accessible->role = ATK_ROLE_RADIO_BUTTON;
}
static AtkRelationSet *
gtk_radio_button_accessible_ref_relation_set (AtkObject *obj)
{
GtkWidget *widget;
AtkRelationSet *relation_set;
GSList *list;
GtkRadioButtonAccessible *radio_button;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
radio_button = GTK_RADIO_BUTTON_ACCESSIBLE (obj);
relation_set = ATK_OBJECT_CLASS (gtk_radio_button_accessible_parent_class)->ref_relation_set (obj);
/* If the radio button'group has changed remove the relation */
list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
if (radio_button->old_group != list)
{
AtkRelation *relation;
relation = atk_relation_set_get_relation_by_type (relation_set, ATK_RELATION_MEMBER_OF);
atk_relation_set_remove (relation_set, relation);
}
if (!atk_relation_set_contains (relation_set, ATK_RELATION_MEMBER_OF))
{
/*
* Get the members of the button group
*/
radio_button->old_group = list;
if (list)
{
AtkObject **accessible_array;
guint list_length;
AtkRelation* relation;
gint i = 0;
list_length = g_slist_length (list);
accessible_array = g_new (AtkObject *, list_length);
while (list != NULL)
{
GtkWidget* list_item = list->data;
accessible_array[i++] = gtk_widget_get_accessible (list_item);
list = list->next;
}
relation = atk_relation_new (accessible_array, list_length,
ATK_RELATION_MEMBER_OF);
g_free (accessible_array);
atk_relation_set_add (relation_set, relation);
/*
* Unref the relation so that it is not leaked.
*/
g_object_unref (relation);
}
}
return relation_set;
}
static void
gtk_radio_button_accessible_class_init (GtkRadioButtonAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->initialize = gtk_radio_button_accessible_initialize;
class->ref_relation_set = gtk_radio_button_accessible_ref_relation_set;
}
static void
gtk_radio_button_accessible_init (GtkRadioButtonAccessible *radio_button)
{
radio_button->old_group = NULL;
}

View File

@ -0,0 +1,53 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems 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_RADIO_BUTTON_ACCESSIBLE_H__
#define __GTK_RADIO_BUTTON_ACCESSIBLE_H__
#include "gailtogglebutton.h"
G_BEGIN_DECLS
#define GTK_TYPE_RADIO_BUTTON_ACCESSIBLE (gtk_radio_button_accessible_get_type ())
#define GTK_RADIO_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RADIO_BUTTON_ACCESSIBLE, GtkRadioButtonAccessible))
#define GTK_RADIO_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RADIO_BUTTON_ACCESSIBLE, GtkRadioButtonAccessibleClass))
#define GTK_IS_RADIO_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RADIO_BUTTON_ACCESSIBLE))
#define GTK_IS_RADIO_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RADIO_BUTTON_ACCESSIBLE))
#define GTK_RADIO_BUTTON_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RADIO_BUTTON_ACCESSIBLE, GtkRadioButtonAccessibleClass))
typedef struct _GtkRadioButtonAccessible GtkRadioButtonAccessible;
typedef struct _GtkRadioButtonAccessibleClass GtkRadioButtonAccessibleClass;
struct _GtkRadioButtonAccessible
{
GailToggleButton parent;
GSList *old_group;
};
struct _GtkRadioButtonAccessibleClass
{
GailToggleButtonClass parent_class;
};
GType gtk_radio_button_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_RADIO_BUTTON_ACCESSIBLE_H__ */

View File

@ -33,6 +33,7 @@
#include "gtkmarshalers.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "a11y/gtkradiobuttonaccessible.h"
/**
* SECTION:gtkradiobutton
@ -195,6 +196,8 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
G_TYPE_NONE, 0);
g_type_class_add_private (class, sizeof (GtkRadioButtonPrivate));
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_RADIO_BUTTON_ACCESSIBLE);
}
static void