a11y: Redo cell update function

1) always emit signals
   Previously, newly constructed cells would be told to not emit events.
   However, we can ensure that nothing is connected to the signals, so
   they will not actually emit anything.
2) don't return anything
   The return value is unused anyway.
This commit is contained in:
Benjamin Otte 2011-12-15 23:51:57 +01:00
parent 5cca6b2dc2
commit 2e7fcc24ac
5 changed files with 31 additions and 47 deletions

View File

@ -26,12 +26,10 @@
G_DEFINE_TYPE (GtkBooleanCellAccessible, _gtk_boolean_cell_accessible, GTK_TYPE_RENDERER_CELL_ACCESSIBLE)
static gboolean
gtk_boolean_cell_accessible_update_cache (GtkRendererCellAccessible *cell,
gboolean emit_change_signal)
static void
gtk_boolean_cell_accessible_update_cache (GtkRendererCellAccessible *cell)
{
GtkBooleanCellAccessible *boolean_cell = GTK_BOOLEAN_CELL_ACCESSIBLE (cell);
gboolean rv = FALSE;
gboolean active;
gboolean sensitive;
@ -42,27 +40,23 @@ gtk_boolean_cell_accessible_update_cache (GtkRendererCellAccessible *cell,
if (boolean_cell->cell_value != active)
{
rv = TRUE;
boolean_cell->cell_value = !boolean_cell->cell_value;
if (active)
_gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_CHECKED, emit_change_signal);
_gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_CHECKED, TRUE);
else
_gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_CHECKED, emit_change_signal);
_gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_CHECKED, TRUE);
}
if (boolean_cell->cell_sensitive != sensitive)
{
rv = TRUE;
boolean_cell->cell_sensitive = !boolean_cell->cell_sensitive;
if (sensitive)
_gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_SENSITIVE, emit_change_signal);
_gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_SENSITIVE, TRUE);
else
_gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_SENSITIVE, emit_change_signal);
_gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (cell), ATK_STATE_SENSITIVE, TRUE);
}
return rv;
}
static void

View File

@ -103,16 +103,17 @@ _gtk_renderer_cell_accessible_init (GtkRendererCellAccessible *renderer_cell)
{
}
gboolean
_gtk_renderer_cell_accessible_update_cache (GtkRendererCellAccessible *cell,
gboolean emit_change_signal)
void
_gtk_renderer_cell_accessible_update_cache (GtkRendererCellAccessible *cell)
{
GtkRendererCellAccessibleClass *class = GTK_RENDERER_CELL_ACCESSIBLE_GET_CLASS (cell);
GtkRendererCellAccessibleClass *klass;
g_return_if_fail (GTK_IS_RENDERER_CELL_ACCESSIBLE (cell));
if (class->update_cache)
return (class->update_cache) (cell, emit_change_signal);
klass = GTK_RENDERER_CELL_ACCESSIBLE_GET_CLASS (cell);
return FALSE;
if (klass->update_cache)
klass->update_cache (cell);
}
AtkObject *

View File

@ -44,16 +44,14 @@ struct _GtkRendererCellAccessible
struct _GtkRendererCellAccessibleClass
{
GtkCellAccessibleClass parent_class;
gboolean (*update_cache) (GtkRendererCellAccessible *cell,
gboolean emit_change_signal);
void (*update_cache) (GtkRendererCellAccessible *cell);
};
GType _gtk_renderer_cell_accessible_get_type (void);
AtkObject *_gtk_renderer_cell_accessible_new (GtkCellRenderer * renderer);
gboolean _gtk_renderer_cell_accessible_update_cache (GtkRendererCellAccessible *cell,
gboolean emit_change_signal);
void _gtk_renderer_cell_accessible_update_cache (GtkRendererCellAccessible *cell);
G_END_DECLS

View File

@ -80,8 +80,7 @@ static void add_attr (PangoAttrList *attr_li
/* Misc */
static gboolean gtk_text_cell_accessible_update_cache (GtkRendererCellAccessible *cell,
gboolean emit_change_signal);
static void gtk_text_cell_accessible_update_cache (GtkRendererCellAccessible *cell);
static void atk_text_interface_init (AtkTextIface *iface);
@ -121,9 +120,8 @@ gtk_text_cell_accessible_get_name (AtkObject *atk_obj)
return text_cell->cell_text;
}
static gboolean
gtk_text_cell_accessible_update_cache (GtkRendererCellAccessible *cell,
gboolean emit_change_signal)
static void
gtk_text_cell_accessible_update_cache (GtkRendererCellAccessible *cell)
{
GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (cell);
AtkObject *obj = ATK_OBJECT (cell);
@ -141,12 +139,9 @@ gtk_text_cell_accessible_update_cache (GtkRendererCellAccessible *cell,
temp_length = text_cell->cell_length;
text_cell->cell_text = NULL;
text_cell->cell_length = 0;
if (emit_change_signal)
{
g_signal_emit_by_name (cell, "text-changed::delete", 0, temp_length);
if (obj->name == NULL)
g_object_notify (G_OBJECT (obj), "accessible-name");
}
g_signal_emit_by_name (cell, "text-changed::delete", 0, temp_length);
if (obj->name == NULL)
g_object_notify (G_OBJECT (obj), "accessible-name");
if (text)
rv = TRUE;
}
@ -172,16 +167,12 @@ gtk_text_cell_accessible_update_cache (GtkRendererCellAccessible *cell,
if (rv)
{
if (emit_change_signal)
{
g_signal_emit_by_name (cell, "text-changed::insert",
0, text_cell->cell_length);
g_signal_emit_by_name (cell, "text-changed::insert",
0, text_cell->cell_length);
if (obj->name == NULL)
g_object_notify (G_OBJECT (obj), "accessible-name");
}
if (obj->name == NULL)
g_object_notify (G_OBJECT (obj), "accessible-name");
}
return rv;
}
static void

View File

@ -56,7 +56,7 @@ static gboolean focus_out (GtkWidget *widget);
static int cell_info_get_index (GtkTreeView *tree_view,
GtkTreeViewAccessibleCellInfo *info);
static gboolean update_cell_value (GtkRendererCellAccessible *renderer_cell,
static void update_cell_value (GtkRendererCellAccessible *renderer_cell,
GtkTreeViewAccessible *accessible,
gboolean emit_change_signal);
static gboolean is_cell_showing (GtkTreeView *tree_view,
@ -1605,7 +1605,7 @@ is_cell_showing (GtkTreeView *tree_view,
* set to FALSE and in model_row_changed() on receipt of "row-changed"
* signal when emit_change_signal is set to TRUE
*/
static gboolean
static void
update_cell_value (GtkRendererCellAccessible *renderer_cell,
GtkTreeViewAccessible *accessible,
gboolean emit_change_signal)
@ -1621,7 +1621,7 @@ update_cell_value (GtkRendererCellAccessible *renderer_cell,
cell = GTK_CELL_ACCESSIBLE (renderer_cell);
cell_info = find_cell_info (accessible, cell);
if (!cell_info)
return FALSE;
return;
if (emit_change_signal)
{
@ -1629,7 +1629,7 @@ update_cell_value (GtkRendererCellAccessible *renderer_cell,
tree_model = gtk_tree_view_get_model (tree_view);
path = cell_info_get_path (cell_info);
if (path == NULL)
return FALSE;
return;
gtk_tree_model_get_iter (tree_model, &iter, path);
is_expander = FALSE;
@ -1651,7 +1651,7 @@ update_cell_value (GtkRendererCellAccessible *renderer_cell,
is_expander, is_expanded);
}
return _gtk_renderer_cell_accessible_update_cache (renderer_cell, emit_change_signal);
_gtk_renderer_cell_accessible_update_cache (renderer_cell);
}
/* Misc Private */