diff options
author | Joanmarie Diggs <jdiggs@igalia.com> | 2015-03-25 03:57:45 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2015-03-25 04:06:23 +0100 |
commit | d553c0ae1ed3ef9754e4949d3830dae916750d3b (patch) | |
tree | 18ac8c29bcf009a59f8fcd56eca81447cae3b100 /gtk/a11y | |
parent | 4340e977e4847f3f451a7e397435895afa3107f5 (diff) | |
download | gtk+-d553c0ae1ed3ef9754e4949d3830dae916750d3b.tar.gz |
a11y: Refactor code
Put the equality check in front. This allows better detection of when an
insert or delete needs to be emitted.
Also, only emit text-changed:delete if the deleted text is not the empty
string. Only emit text-changed:insert if the inserted text is not the
empty string.
https://bugzilla.gnome.org/show_bug.cgi?id=746706
Diffstat (limited to 'gtk/a11y')
-rw-r--r-- | gtk/a11y/gtktextcellaccessible.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/gtk/a11y/gtktextcellaccessible.c b/gtk/a11y/gtktextcellaccessible.c index 1b68c9440a..8ea2d277cf 100644 --- a/gtk/a11y/gtktextcellaccessible.c +++ b/gtk/a11y/gtktextcellaccessible.c @@ -136,7 +136,6 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell) { GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (cell); AtkObject *obj = ATK_OBJECT (cell); - gboolean rv = FALSE; gint temp_length, text_length; gchar *text; GtkCellRenderer *renderer; @@ -153,9 +152,9 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell) text = g_strdup (""); text_length = g_utf8_strlen (text, -1); - if (text_cell->priv->cell_text) + if (g_strcmp0 (text_cell->priv->cell_text, text) != 0) { - if (text == NULL || g_strcmp0 (text_cell->priv->cell_text, text) != 0) + if (text_cell->priv->cell_length) { g_free (text_cell->priv->cell_text); temp_length = text_cell->priv->cell_length; @@ -164,29 +163,22 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell) 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; } - } - else - rv = TRUE; - if (rv) - { text_cell->priv->cell_text = g_strdup (text); text_cell->priv->cell_length = text_length; - } - g_free (text); - - if (rv) - { - g_signal_emit_by_name (cell, "text-changed::insert", - 0, text_cell->priv->cell_length); + if (text_length) + { + g_signal_emit_by_name (cell, "text-changed::insert", + 0, text_cell->priv->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"); + } } + + g_free (text); } static void |