From 47e44028e1fc190176a308c6089b2696b2bf8114 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 19 Mar 2012 00:17:05 +0100 Subject: [PATCH] a11y: Add back the 'toggle' actions This is a hack. But as long as Orca cannot figure out if a cell is heckable, the best we can do is support the old way of providing a "toggle" action. https://bugzilla.gnome.org/show_bug.cgi?id=672367 https://bugzilla.gnome.org/show_bug.cgi?id=672368 https://bugzilla.gnome.org/show_bug.cgi?id=672369 --- gtk/a11y/gtkbooleancellaccessible.c | 52 ++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/gtk/a11y/gtkbooleancellaccessible.c b/gtk/a11y/gtkbooleancellaccessible.c index ddffe8ee8c..e8e9c622fb 100644 --- a/gtk/a11y/gtkbooleancellaccessible.c +++ b/gtk/a11y/gtkbooleancellaccessible.c @@ -20,8 +20,58 @@ #include #include "gtkbooleancellaccessible.h" +static AtkActionIface *parent_action_iface; -G_DEFINE_TYPE (GtkBooleanCellAccessible, _gtk_boolean_cell_accessible, GTK_TYPE_RENDERER_CELL_ACCESSIBLE) +static gint +gtk_boolean_cell_accessible_get_n_actions (AtkAction *action) +{ + return parent_action_iface->get_n_actions (action) + 1; +} + +static const gchar * +gtk_boolean_cell_accessible_get_description (AtkAction *action, + gint i) +{ + if (i == 0) + return "toggles the cell"; + + return parent_action_iface->get_description (action, i - 1); +} + +static const gchar * +gtk_boolean_cell_accessible_action_get_name (AtkAction *action, + gint i) +{ + if (i == 0) + return "toggle"; + + return parent_action_iface->get_description (action, i - 1); +} + +static gboolean +gtk_boolean_cell_accessible_do_action (AtkAction *action, + gint i) +{ + if (i == 0) + return parent_action_iface->do_action (action, 2); + else + return parent_action_iface->do_action (action, i - 1); +} + +static void +gtk_boolean_cell_accessible_action_interface_init (AtkActionIface *iface) +{ + parent_action_iface = g_type_interface_peek_parent (iface); + + iface->do_action = gtk_boolean_cell_accessible_do_action; + iface->get_n_actions = gtk_boolean_cell_accessible_get_n_actions; + iface->get_description = gtk_boolean_cell_accessible_get_description; + iface->get_name = gtk_boolean_cell_accessible_action_get_name; +} + + +G_DEFINE_TYPE_EXTENDED (GtkBooleanCellAccessible, _gtk_boolean_cell_accessible, GTK_TYPE_RENDERER_CELL_ACCESSIBLE, 0, + G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, gtk_boolean_cell_accessible_action_interface_init)) static AtkStateSet *