Convert GailToggleButton to GtkToggleButtonAccessible

This commit is contained in:
Matthias Clasen 2011-06-28 00:53:22 -04:00
parent f54cc70238
commit a8b67d2064
8 changed files with 121 additions and 137 deletions

View File

@ -45,7 +45,7 @@ gail_c_sources = \
gailtextcell.c \
gailtextutil.c \
gtktextviewaccessible.c \
gailtogglebutton.c \
gtktogglebuttonaccessible.c \
gailtoplevel.c \
gailtreeview.c \
gailutil.c \
@ -96,7 +96,7 @@ gail_private_h_sources = \
gailtextcell.h \
gailtextutil.h \
gtktextviewaccessible.h \
gailtogglebutton.h \
gtktogglebuttonaccessible.h \
gailtoplevel.h \
gailtreeview.h \
gailutil.h \

View File

@ -42,7 +42,6 @@
#include "gailscrolledwindow.h"
#include "gailstatusbar.h"
#include "gailtextcell.h"
#include "gailtogglebutton.h"
#include "gailtoplevel.h"
#include "gailtreeview.h"
#include "gailutil.h"
@ -99,7 +98,6 @@ GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_WIDGET, GailWidget, gail_widget, GTK_TYPE_WIDG
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_CONTAINER, GailContainer, gail_container, GTK_TYPE_CONTAINER)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_BUTTON, GailButton, gail_button, GTK_TYPE_BUTTON)
GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_MENU_ITEM, GailMenuItem, gail_menu_item, gail_menu_item_new)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_TOGGLE_BUTTON, GailToggleButton, gail_toggle_button, GTK_TYPE_TOGGLE_BUTTON)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_COMBO_BOX, GailComboBox, gail_combo_box, GTK_TYPE_COMBO_BOX)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_MENU_SHELL, GailMenuShell, gail_menu_shell, GTK_TYPE_MENU_SHELL)
GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_MENU, GailMenu, gail_menu, GTK_TYPE_MENU)
@ -860,7 +858,6 @@ gail_accessibility_module_init (void)
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CONTAINER, gail_container);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_BUTTON, gail_button);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU_ITEM, gail_menu_item);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_TOGGLE_BUTTON, gail_toggle_button);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_COMBO_BOX, gail_combo_box);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU_BAR, gail_menu_shell);
GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU, gail_menu);

View File

@ -1,51 +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_TOGGLE_BUTTON_H__
#define __GAIL_TOGGLE_BUTTON_H__
#include "gailbutton.h"
G_BEGIN_DECLS
#define GAIL_TYPE_TOGGLE_BUTTON (gail_toggle_button_get_type ())
#define GAIL_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_TOGGLE_BUTTON, GailToggleButton))
#define GAIL_TOGGLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_TOGGLE_BUTTON, GailToggleButtonClass))
#define GAIL_IS_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_TOGGLE_BUTTON))
#define GAIL_IS_TOGGLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_TOGGLE_BUTTON))
#define GAIL_TOGGLE_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_TOGGLE_BUTTON, GailToggleButtonClass))
typedef struct _GailToggleButton GailToggleButton;
typedef struct _GailToggleButtonClass GailToggleButtonClass;
struct _GailToggleButton
{
GailButton parent;
};
GType gail_toggle_button_get_type (void);
struct _GailToggleButtonClass
{
GailButtonClass parent_class;
};
G_END_DECLS
#endif /* __GAIL_TOGGLE_BUTTON_H__ */

View File

@ -23,7 +23,7 @@
#include "gtkradiobuttonaccessible.h"
G_DEFINE_TYPE (GtkRadioButtonAccessible, gtk_radio_button_accessible, GAIL_TYPE_TOGGLE_BUTTON)
G_DEFINE_TYPE (GtkRadioButtonAccessible, gtk_radio_button_accessible, GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE)
static void
gtk_radio_button_accessible_initialize (AtkObject *accessible,

View File

@ -20,7 +20,7 @@
#ifndef __GTK_RADIO_BUTTON_ACCESSIBLE_H__
#define __GTK_RADIO_BUTTON_ACCESSIBLE_H__
#include "gailtogglebutton.h"
#include "gtktogglebuttonaccessible.h"
G_BEGIN_DECLS
@ -36,14 +36,14 @@ typedef struct _GtkRadioButtonAccessibleClass GtkRadioButtonAccessibleClass;
struct _GtkRadioButtonAccessible
{
GailToggleButton parent;
GtkToggleButtonAccessible parent;
GSList *old_group;
};
struct _GtkRadioButtonAccessibleClass
{
GailToggleButtonClass parent_class;
GtkToggleButtonAccessibleClass parent_class;
};
GType gtk_radio_button_accessible_get_type (void);

View File

@ -21,52 +21,32 @@
#include <string.h>
#include <gtk/gtk.h>
#include "gailtogglebutton.h"
#include "gtktogglebuttonaccessible.h"
static void gail_toggle_button_class_init (GailToggleButtonClass *klass);
static void gail_toggle_button_init (GailToggleButton *button);
static void gail_toggle_button_toggled_gtk (GtkWidget *widget);
static void gail_toggle_button_real_notify_gtk (GObject *obj,
GParamSpec *pspec);
static void gail_toggle_button_real_initialize (AtkObject *obj,
gpointer data);
static AtkStateSet* gail_toggle_button_ref_state_set (AtkObject *accessible);
G_DEFINE_TYPE (GailToggleButton, gail_toggle_button, GAIL_TYPE_BUTTON)
G_DEFINE_TYPE (GtkToggleButtonAccessible, gtk_toggle_button_accessible, GAIL_TYPE_BUTTON)
static void
gail_toggle_button_class_init (GailToggleButtonClass *klass)
gtk_toggle_button_accessible_toggled (GtkWidget *widget)
{
GailWidgetClass *widget_class;
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
AtkObject *accessible;
GtkToggleButton *toggle_button;
widget_class = (GailWidgetClass*)klass;
widget_class->notify_gtk = gail_toggle_button_real_notify_gtk;
toggle_button = GTK_TOGGLE_BUTTON (widget);
class->ref_state_set = gail_toggle_button_ref_state_set;
class->initialize = gail_toggle_button_real_initialize;
accessible = gtk_widget_get_accessible (widget);
atk_object_notify_state_change (accessible, ATK_STATE_CHECKED,
gtk_toggle_button_get_active (toggle_button));
}
static void
gail_toggle_button_init (GailToggleButton *button)
gtk_toggle_button_accessible_initialize (AtkObject *obj,
gpointer data)
{
}
ATK_OBJECT_CLASS (gtk_toggle_button_accessible_parent_class)->initialize (obj, data);
static void
gail_toggle_button_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (gail_toggle_button_parent_class)->initialize (obj, data);
g_signal_connect (data,
"toggled",
G_CALLBACK (gail_toggle_button_toggled_gtk),
NULL);
g_signal_connect (data, "toggled",
G_CALLBACK (gtk_toggle_button_accessible_toggled), NULL);
if (GTK_IS_CHECK_BUTTON (data))
obj->role = ATK_ROLE_CHECK_BOX;
@ -75,48 +55,8 @@ gail_toggle_button_real_initialize (AtkObject *obj,
}
static void
gail_toggle_button_toggled_gtk (GtkWidget *widget)
{
AtkObject *accessible;
GtkToggleButton *toggle_button;
toggle_button = GTK_TOGGLE_BUTTON (widget);
accessible = gtk_widget_get_accessible (widget);
atk_object_notify_state_change (accessible, ATK_STATE_CHECKED,
gtk_toggle_button_get_active (toggle_button));
}
static AtkStateSet*
gail_toggle_button_ref_state_set (AtkObject *accessible)
{
AtkStateSet *state_set;
GtkToggleButton *toggle_button;
GtkWidget *widget;
state_set = ATK_OBJECT_CLASS (gail_toggle_button_parent_class)->ref_state_set (accessible);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget == NULL)
return state_set;
toggle_button = GTK_TOGGLE_BUTTON (widget);
if (gtk_toggle_button_get_active (toggle_button))
atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
if (gtk_toggle_button_get_inconsistent (toggle_button))
{
atk_state_set_remove_state (state_set, ATK_STATE_ENABLED);
atk_state_set_add_state (state_set, ATK_STATE_INDETERMINATE);
}
return state_set;
}
static void
gail_toggle_button_real_notify_gtk (GObject *obj,
GParamSpec *pspec)
gtk_toggle_button_accessible_notify_gtk (GObject *obj,
GParamSpec *pspec)
{
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (obj);
AtkObject *atk_obj;
@ -139,5 +79,49 @@ gail_toggle_button_real_notify_gtk (GObject *obj,
atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
}
else
GAIL_WIDGET_CLASS (gail_toggle_button_parent_class)->notify_gtk (obj, pspec);
GAIL_WIDGET_CLASS (gtk_toggle_button_accessible_parent_class)->notify_gtk (obj, pspec);
}
static AtkStateSet*
gtk_toggle_button_accessible_ref_state_set (AtkObject *accessible)
{
AtkStateSet *state_set;
GtkToggleButton *toggle_button;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget == NULL)
return NULL;
state_set = ATK_OBJECT_CLASS (gtk_toggle_button_accessible_parent_class)->ref_state_set (accessible);
toggle_button = GTK_TOGGLE_BUTTON (widget);
if (gtk_toggle_button_get_active (toggle_button))
atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
if (gtk_toggle_button_get_inconsistent (toggle_button))
{
atk_state_set_remove_state (state_set, ATK_STATE_ENABLED);
atk_state_set_add_state (state_set, ATK_STATE_INDETERMINATE);
}
return state_set;
}
static void
gtk_toggle_button_accessible_class_init (GtkToggleButtonAccessibleClass *klass)
{
GailWidgetClass *widget_class;
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
widget_class = (GailWidgetClass*)klass;
widget_class->notify_gtk = gtk_toggle_button_accessible_notify_gtk;
class->ref_state_set = gtk_toggle_button_accessible_ref_state_set;
class->initialize = gtk_toggle_button_accessible_initialize;
}
static void
gtk_toggle_button_accessible_init (GtkToggleButtonAccessible *button)
{
}

View File

@ -0,0 +1,51 @@
/* 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_TOGGLE_BUTTON_ACCESSIBLE_H__
#define __GTK_TOGGLE_BUTTON_ACCESSIBLE_H__
#include "gailbutton.h"
G_BEGIN_DECLS
#define GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE (gtk_toggle_button_accessible_get_type ())
#define GTK_TOGGLE_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE, GtkToggleButtonAccessible))
#define GTK_TOGGLE_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE, GtkToggleButtonAccessibleClass))
#define GTK_IS_TOGGLE_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE))
#define GTK_IS_TOGGLE_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE))
#define GTK_TOGGLE_BUTTON_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE, GtkToggleButtonAccessibleClass))
typedef struct _GtkToggleButtonAccessible GtkToggleButtonAccessible;
typedef struct _GtkToggleButtonAccessibleClass GtkToggleButtonAccessibleClass;
struct _GtkToggleButtonAccessible
{
GailButton parent;
};
struct _GtkToggleButtonAccessibleClass
{
GailButtonClass parent_class;
};
GType gtk_toggle_button_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_TOGGLE_BUTTON_ACCESSIBLE_H__ */

View File

@ -36,6 +36,7 @@
#include "gtkactivatable.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "a11y/gtktogglebuttonaccessible.h"
/**
@ -212,6 +213,8 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class)
G_TYPE_NONE, 0);
g_type_class_add_private (class, sizeof (GtkToggleButtonPrivate));
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE);
}
static void