forked from AuroraMiddleware/gtk
a11y: Only emit signals when cells change; not upon creation
This is a workaround for atspi-atk behaviour. atspi-atk uses signal emission hooks. So it to already catches signal emissions on creation of objects, before anyone could even think of g_signal_connect()ing. https://bugzilla.gnome.org/show_bug.cgi?id=746706
This commit is contained in:
parent
f87b08ddd3
commit
8f644101b9
@ -113,7 +113,8 @@ gtk_boolean_cell_accessible_ref_state_set (AtkObject *accessible)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_boolean_cell_accessible_update_cache (GtkCellAccessible *cell)
|
||||
gtk_boolean_cell_accessible_update_cache (GtkCellAccessible *cell,
|
||||
gboolean emit_signal)
|
||||
{
|
||||
GtkBooleanCellAccessible *boolean_cell = GTK_BOOLEAN_CELL_ACCESSIBLE (cell);
|
||||
gboolean active;
|
||||
@ -131,14 +132,16 @@ gtk_boolean_cell_accessible_update_cache (GtkCellAccessible *cell)
|
||||
{
|
||||
boolean_cell->priv->cell_value = !boolean_cell->priv->cell_value;
|
||||
|
||||
atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_CHECKED, active);
|
||||
if (emit_signal)
|
||||
atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_CHECKED, active);
|
||||
}
|
||||
|
||||
if (boolean_cell->priv->cell_sensitive != sensitive)
|
||||
{
|
||||
boolean_cell->priv->cell_sensitive = !boolean_cell->priv->cell_sensitive;
|
||||
|
||||
atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_SENSITIVE, sensitive);
|
||||
if (emit_signal)
|
||||
atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_SENSITIVE, sensitive);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,19 +419,23 @@ _gtk_cell_accessible_state_changed (GtkCellAccessible *cell,
|
||||
/*
|
||||
* gtk_cell_accessible_update_cache:
|
||||
* @cell: the cell that is changed
|
||||
* @emit_signal: whether or not to notify the ATK bridge
|
||||
*
|
||||
* Notifies the cell that the values in the data in the row that
|
||||
* is used to feed the cell renderer with has changed. The
|
||||
* cell_changed function of @cell is called to send update
|
||||
* notifications for the properties it takes from its cell
|
||||
* renderer.
|
||||
* renderer. If @emit_signal is TRUE, also notify the ATK bridge
|
||||
* of the change. The bridge should be notified when an existing
|
||||
* cell changes; not when a newly-created cell is being set up.
|
||||
*
|
||||
* Note that there is no higher granularity available about which
|
||||
* properties changed, so you will need to make do with this
|
||||
* function.
|
||||
**/
|
||||
void
|
||||
_gtk_cell_accessible_update_cache (GtkCellAccessible *cell)
|
||||
_gtk_cell_accessible_update_cache (GtkCellAccessible *cell,
|
||||
gboolean emit_signal)
|
||||
{
|
||||
GtkCellAccessibleClass *klass;
|
||||
|
||||
@ -440,5 +444,5 @@ _gtk_cell_accessible_update_cache (GtkCellAccessible *cell)
|
||||
klass = GTK_CELL_ACCESSIBLE_GET_CLASS (cell);
|
||||
|
||||
if (klass->update_cache)
|
||||
klass->update_cache (cell);
|
||||
klass->update_cache (cell, emit_signal);
|
||||
}
|
||||
|
@ -48,7 +48,8 @@ struct _GtkCellAccessible
|
||||
struct _GtkCellAccessibleClass
|
||||
{
|
||||
GtkAccessibleClass parent_class;
|
||||
void (*update_cache) (GtkCellAccessible *cell);
|
||||
void (*update_cache) (GtkCellAccessible *cell,
|
||||
gboolean emit_signal);
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -25,7 +25,8 @@ G_BEGIN_DECLS
|
||||
void _gtk_cell_accessible_state_changed (GtkCellAccessible *cell,
|
||||
GtkCellRendererState added,
|
||||
GtkCellRendererState removed);
|
||||
void _gtk_cell_accessible_update_cache (GtkCellAccessible *cell);
|
||||
void _gtk_cell_accessible_update_cache (GtkCellAccessible *cell,
|
||||
gboolean emit_signal);
|
||||
void _gtk_cell_accessible_initialize (GtkCellAccessible *cell,
|
||||
GtkWidget *widget,
|
||||
AtkObject *parent);
|
||||
|
@ -64,13 +64,14 @@ gtk_container_cell_accessible_ref_child (AtkObject *obj,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_container_cell_accessible_update_cache (GtkCellAccessible *cell)
|
||||
gtk_container_cell_accessible_update_cache (GtkCellAccessible *cell,
|
||||
gboolean emit_signal)
|
||||
{
|
||||
GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (cell);
|
||||
GList *l;
|
||||
|
||||
for (l = container->priv->children; l; l = l->next)
|
||||
_gtk_cell_accessible_update_cache (l->data);
|
||||
_gtk_cell_accessible_update_cache (l->data, emit_signal);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -87,7 +87,8 @@ static void add_attr (PangoAttrList *attr_li
|
||||
|
||||
/* Misc */
|
||||
|
||||
static void gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell);
|
||||
static void gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell,
|
||||
gboolean emit_signal);
|
||||
|
||||
static void atk_text_interface_init (AtkTextIface *iface);
|
||||
|
||||
@ -132,7 +133,8 @@ gtk_text_cell_accessible_get_name (AtkObject *atk_obj)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
|
||||
gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell,
|
||||
gboolean emit_signal)
|
||||
{
|
||||
GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (cell);
|
||||
AtkObject *obj = ATK_OBJECT (cell);
|
||||
@ -154,7 +156,7 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
|
||||
|
||||
if (g_strcmp0 (text_cell->priv->cell_text, text) != 0)
|
||||
{
|
||||
if (text_cell->priv->cell_length)
|
||||
if (text_cell->priv->cell_length && emit_signal)
|
||||
{
|
||||
g_signal_emit_by_name (cell, "text-changed::delete",
|
||||
0, text_cell->priv->cell_length);
|
||||
@ -164,13 +166,13 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
|
||||
text_cell->priv->cell_text = g_strdup (text);
|
||||
text_cell->priv->cell_length = text_length;
|
||||
|
||||
if (text_length)
|
||||
if (text_length && emit_signal)
|
||||
{
|
||||
g_signal_emit_by_name (cell, "text-changed::insert",
|
||||
0, text_cell->priv->cell_length);
|
||||
}
|
||||
|
||||
if (obj->name == NULL)
|
||||
if (obj->name == NULL && emit_signal)
|
||||
g_object_notify (G_OBJECT (obj), "accessible-name");
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ create_cell (GtkTreeView *treeview,
|
||||
cell_info_new (accessible, tree, node, column, cell);
|
||||
|
||||
set_cell_data (treeview, accessible, cell);
|
||||
_gtk_cell_accessible_update_cache (cell);
|
||||
_gtk_cell_accessible_update_cache (cell, FALSE);
|
||||
|
||||
return cell;
|
||||
}
|
||||
@ -1705,7 +1705,7 @@ _gtk_tree_view_accessible_changed (GtkTreeView *treeview,
|
||||
continue;
|
||||
|
||||
set_cell_data (treeview, accessible, cell);
|
||||
_gtk_cell_accessible_update_cache (cell);
|
||||
_gtk_cell_accessible_update_cache (cell, TRUE);
|
||||
}
|
||||
|
||||
g_signal_emit_by_name (accessible, "visible-data-changed");
|
||||
|
Loading…
Reference in New Issue
Block a user