Commit e2847d96 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Convert GailRadioButton to GtkRadioButtonAccessible

parent 369b4a60
......@@ -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 \
......
......@@ -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);
......
......@@ -20,68 +20,39 @@
#include "config.h"
#include <gtk/gtk.h>
#include "gailradiobutton.h"
#include "gtkradiobuttonaccessible.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;
}
G_DEFINE_TYPE (GtkRadioButtonAccessible, gtk_radio_button_accessible, GAIL_TYPE_TOGGLE_BUTTON)
static void
gail_radio_button_initialize (AtkObject *accessible,
gpointer data)
gtk_radio_button_accessible_initialize (AtkObject *accessible,
gpointer data)
{
ATK_OBJECT_CLASS (gail_radio_button_parent_class)->initialize (accessible, data);
ATK_OBJECT_CLASS (gtk_radio_button_accessible_parent_class)->initialize (accessible, data);
accessible->role = ATK_ROLE_RADIO_BUTTON;
}
AtkRelationSet*
gail_radio_button_ref_relation_set (AtkObject *obj)
static AtkRelationSet *
gtk_radio_button_accessible_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);
GtkRadioButtonAccessible *radio_button;
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);
radio_button = GTK_RADIO_BUTTON_ACCESSIBLE (obj);
/*
* If the radio button'group has changed remove the relation
*/
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;
......@@ -95,36 +66,51 @@ gail_radio_button_ref_relation_set (AtkObject *obj)
/*
* 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;
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);
}
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;
}
......@@ -17,37 +17,37 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_RADIO_BUTTON_H__
#define __GAIL_RADIO_BUTTON_H__
#ifndef __GTK_RADIO_BUTTON_ACCESSIBLE_H__
#define __GTK_RADIO_BUTTON_ACCESSIBLE_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))
#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 _GailRadioButton GailRadioButton;
typedef struct _GailRadioButtonClass GailRadioButtonClass;
typedef struct _GtkRadioButtonAccessible GtkRadioButtonAccessible;
typedef struct _GtkRadioButtonAccessibleClass GtkRadioButtonAccessibleClass;
struct _GailRadioButton
struct _GtkRadioButtonAccessible
{
GailToggleButton parent;
GSList *old_group;
};
GType gail_radio_button_get_type (void);
struct _GailRadioButtonClass
struct _GtkRadioButtonAccessibleClass
{
GailToggleButtonClass parent_class;
};
GType gtk_radio_button_accessible_get_type (void);
G_END_DECLS
#endif /* __GAIL_RADIO_BUTTON_H__ */
#endif /* __GTK_RADIO_BUTTON_ACCESSIBLE_H__ */
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment