diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c index e033585338..cf2c374992 100644 --- a/gtk/gtkatcontext.c +++ b/gtk/gtkatcontext.c @@ -1284,43 +1284,32 @@ gtk_at_context_get_text_accumulate (GtkATContext *self, } /* Step 2.E */ - switch ((int) self->accessible_role) + if (self->accessible_role == GTK_ACCESSIBLE_ROLE_TEXT_BOX) { - case GTK_ACCESSIBLE_ROLE_TEXT_BOX: - { - if (GTK_IS_EDITABLE (self->accessible)) - { - const char *text = gtk_editable_get_text (GTK_EDITABLE (self->accessible)); - if (text && not_just_space (text)) - append_with_space (res, text); - } - } + if (GTK_IS_EDITABLE (self->accessible)) + { + const char *text = gtk_editable_get_text (GTK_EDITABLE (self->accessible)); + if (text && not_just_space (text)) + append_with_space (res, text); + } return; - - case GTK_ACCESSIBLE_ROLE_RANGE: - { - int range_attrs[] = { - GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, - GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, - }; - - value = NULL; - for (int i = 0; i < G_N_ELEMENTS (range_attrs); i++) - { - if (gtk_accessible_attribute_set_contains (self->properties, range_attrs[i])) - { - value = gtk_accessible_attribute_set_get_value (self->properties, range_attrs[i]); - break; - } - } - - if (value != NULL) + } + else if (gtk_accessible_role_is_range_subclass (self->accessible_role)) + { + if (gtk_accessible_attribute_set_contains (self->properties, GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT)) + { + value = gtk_accessible_attribute_set_get_value (self->properties, GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT); append_with_space (res, gtk_string_accessible_value_get (value)); - } - return; + } + else if (gtk_accessible_attribute_set_contains (self->properties, GTK_ACCESSIBLE_PROPERTY_VALUE_NOW)) + { + value = gtk_accessible_attribute_set_get_value (self->properties, GTK_ACCESSIBLE_PROPERTY_VALUE_NOW); + if (res->len > 0) + g_string_append (res, " "); + g_string_append_printf (res, "%g", gtk_number_accessible_value_get (value)); + } - default: - break; + return; } /* Step 2.F */ @@ -1379,6 +1368,7 @@ gtk_at_context_get_text (GtkATContext *self, { GtkATContext *parent = NULL; + g_return_val_if_fail (GTK_IS_AT_CONTEXT (self), NULL); g_warn_if_fail (self->realized); /* Step 1 */ @@ -1429,8 +1419,6 @@ gtk_at_context_get_text (GtkATContext *self, char * gtk_at_context_get_name (GtkATContext *self) { - g_return_val_if_fail (GTK_IS_AT_CONTEXT (self), NULL); - return gtk_at_context_get_text (self, GTK_ACCESSIBLE_PROPERTY_LABEL, GTK_ACCESSIBLE_RELATION_LABELLED_BY); } @@ -1447,8 +1435,6 @@ gtk_at_context_get_name (GtkATContext *self) char * gtk_at_context_get_description (GtkATContext *self) { - g_return_val_if_fail (GTK_IS_AT_CONTEXT (self), NULL); - return gtk_at_context_get_text (self, GTK_ACCESSIBLE_PROPERTY_DESCRIPTION, GTK_ACCESSIBLE_RELATION_DESCRIBED_BY); }