a11y: Implement ref_state_set using the new APIs

Various tiny semantic changes in here.

The big fix is that we consider every cell as visible and as showing if
the treeview is mapped.
This was also fixed in the tree dump test.
This commit is contained in:
Benjamin Otte 2011-11-24 01:59:18 +01:00
parent 178686ba11
commit 08d86fabc4
5 changed files with 69 additions and 34 deletions

View File

@ -61,9 +61,6 @@ gtk_cell_accessible_object_finalize (GObject *obj)
gpointer target_object;
gint i;
if (cell->state_set)
g_object_unref (cell->state_set);
if (cell->action_list)
g_list_free_full (cell->action_list, destroy_action_info);
@ -107,15 +104,62 @@ gtk_cell_accessible_get_index_in_parent (AtkObject *obj)
}
static AtkStateSet *
gtk_cell_accessible_ref_state_set (AtkObject *obj)
gtk_cell_accessible_ref_state_set (AtkObject *accessible)
{
GtkCellAccessible *cell = GTK_CELL_ACCESSIBLE (obj);
GtkCellAccessible *cell_accessible;
AtkStateSet *state_set;
GtkCellRendererState flags;
gboolean expandable, expanded;
g_object_ref (cell->state_set);
cell_accessible = GTK_CELL_ACCESSIBLE (accessible);
return cell->state_set;
state_set = atk_state_set_new ();
if (cell_accessible->widget == NULL)
{
atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
return state_set;
}
flags = _gtk_cell_accessible_get_state (cell_accessible, &expandable, &expanded);
atk_state_set_add_state (state_set, ATK_STATE_TRANSIENT);
if (!(flags & GTK_CELL_RENDERER_INSENSITIVE))
{
atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE);
atk_state_set_add_state (state_set, ATK_STATE_ENABLED);
}
atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
if (flags & GTK_CELL_RENDERER_SELECTED)
atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
if (gtk_widget_get_mapped (cell_accessible->widget))
atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
/* This is not completely right. We should be tracking the
* focussed cell renderer, but that involves diving into
* cell areas...
*/
atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE);
if (flags & GTK_CELL_RENDERER_FOCUSED)
{
/* XXX: Why do we set ACTIVE here? */
atk_state_set_add_state (state_set, ATK_STATE_ACTIVE);
atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
}
if (expandable)
atk_state_set_add_state (state_set, ATK_STATE_EXPANDABLE);
if (expanded)
atk_state_set_add_state (state_set, ATK_STATE_EXPANDED);
return state_set;
}
static void
_gtk_cell_accessible_class_init (GtkCellAccessibleClass *klass)
{
@ -133,11 +177,6 @@ _gtk_cell_accessible_init (GtkCellAccessible *cell)
{
cell->widget = NULL;
cell->action_list = NULL;
cell->state_set = atk_state_set_new ();
atk_state_set_add_state (cell->state_set, ATK_STATE_TRANSIENT);
atk_state_set_add_state (cell->state_set, ATK_STATE_ENABLED);
atk_state_set_add_state (cell->state_set, ATK_STATE_SENSITIVE);
atk_state_set_add_state (cell->state_set, ATK_STATE_SELECTABLE);
}
static void
@ -164,14 +203,8 @@ _gtk_cell_accessible_add_state (GtkCellAccessible *cell,
AtkStateType state_type,
gboolean emit_signal)
{
gboolean rc;
AtkObject *parent;
if (atk_state_set_contains_state (cell->state_set, state_type))
return FALSE;
rc = atk_state_set_add_state (cell->state_set, state_type);
/* The signal should only be generated if the value changed,
* not when the cell is set up. So states that are set
* initially should pass FALSE as the emit_signal argument.
@ -191,7 +224,7 @@ _gtk_cell_accessible_add_state (GtkCellAccessible *cell,
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
_gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (parent), state_type, emit_signal);
return rc;
return TRUE;
}
gboolean
@ -199,16 +232,10 @@ _gtk_cell_accessible_remove_state (GtkCellAccessible *cell,
AtkStateType state_type,
gboolean emit_signal)
{
gboolean rc;
AtkObject *parent;
if (!atk_state_set_contains_state (cell->state_set, state_type))
return FALSE;
parent = atk_object_get_parent (ATK_OBJECT (cell));
rc = atk_state_set_remove_state (cell->state_set, state_type);
/* The signal should only be generated if the value changed,
* not when the cell is set up. So states that are set
* initially should pass FALSE as the emit_signal argument.
@ -227,7 +254,7 @@ _gtk_cell_accessible_remove_state (GtkCellAccessible *cell,
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (parent))
_gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (parent), state_type, emit_signal);
return rc;
return TRUE;
}
gboolean

View File

@ -39,7 +39,6 @@ struct _GtkCellAccessible
AtkObject parent;
GtkWidget *widget;
AtkStateSet *state_set;
GList *action_list;
};

View File

@ -25,7 +25,6 @@
G_DEFINE_TYPE (GtkRendererCellAccessible, _gtk_renderer_cell_accessible, GTK_TYPE_CELL_ACCESSIBLE)
static void
gtk_renderer_cell_accessible_finalize (GObject *object)
{

View File

@ -125,6 +125,17 @@ static void atk_text_interface_init (AtkTextIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkTextCellAccessible, _gtk_text_cell_accessible, GTK_TYPE_RENDERER_CELL_ACCESSIBLE,
G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init))
static AtkStateSet *
gtk_text_cell_accessible_ref_state_set (AtkObject *accessible)
{
AtkStateSet *state_set;
state_set = ATK_OBJECT_CLASS (_gtk_text_cell_accessible_parent_class)->ref_state_set (accessible);
atk_state_set_add_state (state_set, ATK_STATE_SINGLE_LINE);
return state_set;
}
static void
gtk_text_cell_accessible_finalize (GObject *object)
@ -221,6 +232,7 @@ _gtk_text_cell_accessible_class_init (GtkTextCellAccessibleClass *klass)
renderer_cell_class->property_list = property_list;
atk_object_class->get_name = gtk_text_cell_accessible_get_name;
atk_object_class->ref_state_set = gtk_text_cell_accessible_ref_state_set;
gobject_class->finalize = gtk_text_cell_accessible_finalize;
}
@ -231,8 +243,6 @@ _gtk_text_cell_accessible_init (GtkTextCellAccessible *text_cell)
text_cell->cell_text = NULL;
text_cell->caret_pos = 0;
text_cell->cell_length = 0;
atk_state_set_add_state (GTK_CELL_ACCESSIBLE (text_cell)->state_set,
ATK_STATE_SINGLE_LINE);
}
AtkObject *

View File

@ -66,7 +66,7 @@ window1
parent: tree1
index: 2
name: One
state: enabled focusable focused selectable selected sensitive single-line transient visible
state: enabled focusable selectable selected sensitive showing single-line transient visible
<AtkComponent>
layer: widget
alpha: 1
@ -146,7 +146,7 @@ window1
parent: tree1
index: 4
name: Three
state: enabled focusable selectable sensitive single-line transient visible
state: enabled focusable selectable sensitive showing single-line transient visible
<AtkComponent>
layer: widget
alpha: 1
@ -226,7 +226,7 @@ window1
parent: tree1
index: 6
name: Five
state: enabled focusable selectable sensitive single-line transient visible
state: enabled focusable selectable sensitive showing single-line transient visible
<AtkComponent>
layer: widget
alpha: 1
@ -306,7 +306,7 @@ window1
parent: tree1
index: 8
name: Seven
state: enabled focusable selectable sensitive single-line transient visible
state: enabled focusable selectable sensitive showing single-line transient visible
<AtkComponent>
layer: widget
alpha: 1