Commit a8b67d20 authored by Matthias Clasen's avatar Matthias Clasen

Convert GailToggleButton to GtkToggleButtonAccessible

parent f54cc702
......@@ -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 \
......
......@@ -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);
......
......@@ -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,
......
......@@ -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);
......
......@@ -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);
widget_class = (GailWidgetClass*)klass;
widget_class->notify_gtk = gail_toggle_button_real_notify_gtk;
AtkObject *accessible;
GtkToggleButton *toggle_button;
class->ref_state_set = gail_toggle_button_ref_state_set;
class->initialize = gail_toggle_button_real_initialize;
}
toggle_button = GTK_TOGGLE_BUTTON (widget);
static void
gail_toggle_button_init (GailToggleButton *button)
{
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_real_initialize (AtkObject *obj,
gpointer data)
gtk_toggle_button_accessible_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (gail_toggle_button_parent_class)->initialize (obj, data);
ATK_OBJECT_CLASS (gtk_toggle_button_accessible_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,31 +55,45 @@ gail_toggle_button_real_initialize (AtkObject *obj,
}
static void
gail_toggle_button_toggled_gtk (GtkWidget *widget)
gtk_toggle_button_accessible_notify_gtk (GObject *obj,
GParamSpec *pspec)
{
AtkObject *accessible;
GtkToggleButton *toggle_button;
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (obj);
AtkObject *atk_obj;
gboolean sensitive;
gboolean inconsistent;
toggle_button = GTK_TOGGLE_BUTTON (widget);
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (toggle_button));
sensitive = gtk_widget_get_sensitive (GTK_WIDGET (toggle_button));
inconsistent = gtk_toggle_button_get_inconsistent (toggle_button);
accessible = gtk_widget_get_accessible (widget);
atk_object_notify_state_change (accessible, ATK_STATE_CHECKED,
gtk_toggle_button_get_active (toggle_button));
}
if (strcmp (pspec->name, "inconsistent") == 0)
{
atk_object_notify_state_change (atk_obj, ATK_STATE_INDETERMINATE, inconsistent);
atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
}
else if (strcmp (pspec->name, "sensitive") == 0)
{
/* Need to override gailwidget behavior of notifying for ENABLED */
atk_object_notify_state_change (atk_obj, ATK_STATE_SENSITIVE, sensitive);
atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
}
else
GAIL_WIDGET_CLASS (gtk_toggle_button_accessible_parent_class)->notify_gtk (obj, pspec);
}
static AtkStateSet*
gail_toggle_button_ref_state_set (AtkObject *accessible)
gtk_toggle_button_accessible_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;
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))
......@@ -110,34 +104,24 @@ gail_toggle_button_ref_state_set (AtkObject *accessible)
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_class_init (GtkToggleButtonAccessibleClass *klass)
{
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (obj);
AtkObject *atk_obj;
gboolean sensitive;
gboolean inconsistent;
GailWidgetClass *widget_class;
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (toggle_button));
sensitive = gtk_widget_get_sensitive (GTK_WIDGET (toggle_button));
inconsistent = gtk_toggle_button_get_inconsistent (toggle_button);
widget_class = (GailWidgetClass*)klass;
widget_class->notify_gtk = gtk_toggle_button_accessible_notify_gtk;
if (strcmp (pspec->name, "inconsistent") == 0)
{
atk_object_notify_state_change (atk_obj, ATK_STATE_INDETERMINATE, inconsistent);
atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
}
else if (strcmp (pspec->name, "sensitive") == 0)
{
/* Need to override gailwidget behavior of notifying for ENABLED */
atk_object_notify_state_change (atk_obj, ATK_STATE_SENSITIVE, sensitive);
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);
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)
{
}
......@@ -17,35 +17,35 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __GAIL_TOGGLE_BUTTON_H__
#define __GAIL_TOGGLE_BUTTON_H__
#ifndef __GTK_TOGGLE_BUTTON_ACCESSIBLE_H__
#define __GTK_TOGGLE_BUTTON_ACCESSIBLE_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))
#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 _GailToggleButton GailToggleButton;
typedef struct _GailToggleButtonClass GailToggleButtonClass;
typedef struct _GtkToggleButtonAccessible GtkToggleButtonAccessible;
typedef struct _GtkToggleButtonAccessibleClass GtkToggleButtonAccessibleClass;
struct _GailToggleButton
struct _GtkToggleButtonAccessible
{
GailButton parent;
};
GType gail_toggle_button_get_type (void);
struct _GailToggleButtonClass
struct _GtkToggleButtonAccessibleClass
{
GailButtonClass parent_class;
};
GType gtk_toggle_button_accessible_get_type (void);
G_END_DECLS
#endif /* __GAIL_TOGGLE_BUTTON_H__ */
#endif /* __GTK_TOGGLE_BUTTON_ACCESSIBLE_H__ */
......@@ -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
......
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