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
|
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);
|
GtkBooleanCellAccessible *boolean_cell = GTK_BOOLEAN_CELL_ACCESSIBLE (cell);
|
||||||
gboolean active;
|
gboolean active;
|
||||||
@ -131,6 +132,7 @@ gtk_boolean_cell_accessible_update_cache (GtkCellAccessible *cell)
|
|||||||
{
|
{
|
||||||
boolean_cell->priv->cell_value = !boolean_cell->priv->cell_value;
|
boolean_cell->priv->cell_value = !boolean_cell->priv->cell_value;
|
||||||
|
|
||||||
|
if (emit_signal)
|
||||||
atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_CHECKED, active);
|
atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_CHECKED, active);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +140,7 @@ gtk_boolean_cell_accessible_update_cache (GtkCellAccessible *cell)
|
|||||||
{
|
{
|
||||||
boolean_cell->priv->cell_sensitive = !boolean_cell->priv->cell_sensitive;
|
boolean_cell->priv->cell_sensitive = !boolean_cell->priv->cell_sensitive;
|
||||||
|
|
||||||
|
if (emit_signal)
|
||||||
atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_SENSITIVE, sensitive);
|
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:
|
* gtk_cell_accessible_update_cache:
|
||||||
* @cell: the cell that is changed
|
* @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
|
* Notifies the cell that the values in the data in the row that
|
||||||
* is used to feed the cell renderer with has changed. The
|
* is used to feed the cell renderer with has changed. The
|
||||||
* cell_changed function of @cell is called to send update
|
* cell_changed function of @cell is called to send update
|
||||||
* notifications for the properties it takes from its cell
|
* 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
|
* Note that there is no higher granularity available about which
|
||||||
* properties changed, so you will need to make do with this
|
* properties changed, so you will need to make do with this
|
||||||
* function.
|
* function.
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
_gtk_cell_accessible_update_cache (GtkCellAccessible *cell)
|
_gtk_cell_accessible_update_cache (GtkCellAccessible *cell,
|
||||||
|
gboolean emit_signal)
|
||||||
{
|
{
|
||||||
GtkCellAccessibleClass *klass;
|
GtkCellAccessibleClass *klass;
|
||||||
|
|
||||||
@ -440,5 +444,5 @@ _gtk_cell_accessible_update_cache (GtkCellAccessible *cell)
|
|||||||
klass = GTK_CELL_ACCESSIBLE_GET_CLASS (cell);
|
klass = GTK_CELL_ACCESSIBLE_GET_CLASS (cell);
|
||||||
|
|
||||||
if (klass->update_cache)
|
if (klass->update_cache)
|
||||||
klass->update_cache (cell);
|
klass->update_cache (cell, emit_signal);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,8 @@ struct _GtkCellAccessible
|
|||||||
struct _GtkCellAccessibleClass
|
struct _GtkCellAccessibleClass
|
||||||
{
|
{
|
||||||
GtkAccessibleClass parent_class;
|
GtkAccessibleClass parent_class;
|
||||||
void (*update_cache) (GtkCellAccessible *cell);
|
void (*update_cache) (GtkCellAccessible *cell,
|
||||||
|
gboolean emit_signal);
|
||||||
};
|
};
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
@ -25,7 +25,8 @@ G_BEGIN_DECLS
|
|||||||
void _gtk_cell_accessible_state_changed (GtkCellAccessible *cell,
|
void _gtk_cell_accessible_state_changed (GtkCellAccessible *cell,
|
||||||
GtkCellRendererState added,
|
GtkCellRendererState added,
|
||||||
GtkCellRendererState removed);
|
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,
|
void _gtk_cell_accessible_initialize (GtkCellAccessible *cell,
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
AtkObject *parent);
|
AtkObject *parent);
|
||||||
|
@ -64,13 +64,14 @@ gtk_container_cell_accessible_ref_child (AtkObject *obj,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (cell);
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
for (l = container->priv->children; l; l = l->next)
|
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
|
static void
|
||||||
|
@ -87,7 +87,8 @@ static void add_attr (PangoAttrList *attr_li
|
|||||||
|
|
||||||
/* Misc */
|
/* 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);
|
static void atk_text_interface_init (AtkTextIface *iface);
|
||||||
|
|
||||||
@ -132,7 +133,8 @@ gtk_text_cell_accessible_get_name (AtkObject *atk_obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (cell);
|
||||||
AtkObject *obj = ATK_OBJECT (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 (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",
|
g_signal_emit_by_name (cell, "text-changed::delete",
|
||||||
0, text_cell->priv->cell_length);
|
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_text = g_strdup (text);
|
||||||
text_cell->priv->cell_length = text_length;
|
text_cell->priv->cell_length = text_length;
|
||||||
|
|
||||||
if (text_length)
|
if (text_length && emit_signal)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (cell, "text-changed::insert",
|
g_signal_emit_by_name (cell, "text-changed::insert",
|
||||||
0, text_cell->priv->cell_length);
|
0, text_cell->priv->cell_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj->name == NULL)
|
if (obj->name == NULL && emit_signal)
|
||||||
g_object_notify (G_OBJECT (obj), "accessible-name");
|
g_object_notify (G_OBJECT (obj), "accessible-name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ create_cell (GtkTreeView *treeview,
|
|||||||
cell_info_new (accessible, tree, node, column, cell);
|
cell_info_new (accessible, tree, node, column, cell);
|
||||||
|
|
||||||
set_cell_data (treeview, accessible, cell);
|
set_cell_data (treeview, accessible, cell);
|
||||||
_gtk_cell_accessible_update_cache (cell);
|
_gtk_cell_accessible_update_cache (cell, FALSE);
|
||||||
|
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
@ -1705,7 +1705,7 @@ _gtk_tree_view_accessible_changed (GtkTreeView *treeview,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
set_cell_data (treeview, accessible, cell);
|
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");
|
g_signal_emit_by_name (accessible, "visible-data-changed");
|
||||||
|
Loading…
Reference in New Issue
Block a user