diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2022-09-30 18:31:55 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2022-09-30 18:36:02 +0100 |
commit | 31fea11255adf54b1ed450c86ad07be70c504aab (patch) | |
tree | fb778d01542e173f706dadc66d874cedaa8539c5 /gtk/a11y | |
parent | 5dd7e248061051acd692f78519c1094c090c7c50 (diff) | |
download | gtk+-31fea11255adf54b1ed450c86ad07be70c504aab.tar.gz |
a11y: Drop GtkAccessibleRange.get_minimum_increment()ebassi/a11y/accessible-range
MinimumIncrement is an AT-SPI-ism that has no counterpart in the ARIA
specification, so it should not live inside public API. Additionally,
it's not really a useful method because it collapses two values on the
adjustment API.
The only method in the GtkAccessibleRange interface should be the
set_current_value(), which allows ATs to control the current position in
a ranged widget.
The AT-SPI implementation can now use all the accessible properties,
including the VALUE_TEXT one, mapped to the Text property on the
AtSpi.Value interface.
Diffstat (limited to 'gtk/a11y')
-rw-r--r-- | gtk/a11y/atspi/Value.xml | 18 | ||||
-rw-r--r-- | gtk/a11y/gtkatspivalue.c | 51 |
2 files changed, 42 insertions, 27 deletions
diff --git a/gtk/a11y/atspi/Value.xml b/gtk/a11y/atspi/Value.xml index ccd6c7aa59..cdf13f96ad 100644 --- a/gtk/a11y/atspi/Value.xml +++ b/gtk/a11y/atspi/Value.xml @@ -1,14 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <node name="/node"> -<interface name="org.a11y.atspi.Value"> - - <property name="MinimumValue" type="d" access="read"/> - - <property name="MaximumValue" type="d" access="read"/> - - <property name="MinimumIncrement" type="d" access="read"/> - - <property name="CurrentValue" type="d" access="readwrite"/> - -</interface> + <interface name="org.a11y.atspi.Value"> + <property name="MinimumValue" type="d" access="read"/> + <property name="MaximumValue" type="d" access="read"/> + <property name="MinimumIncrement" type="d" access="read"/> + <property name="CurrentValue" type="d" access="readwrite"/> + <property name="Text" type="s" access="read"/> + </interface> </node> diff --git a/gtk/a11y/gtkatspivalue.c b/gtk/a11y/gtkatspivalue.c index 404121065a..5dab4e24c0 100644 --- a/gtk/a11y/gtkatspivalue.c +++ b/gtk/a11y/gtkatspivalue.c @@ -24,7 +24,7 @@ #include "a11y/atspi/atspi-value.h" -#include "gtkaccessiblerange.h" +#include "gtkaccessiblerangeprivate.h" #include "gtkatcontextprivate.h" #include "gtkdebug.h" @@ -40,35 +40,57 @@ handle_value_get_property (GDBusConnection *connection, gpointer user_data) { GtkATContext *ctx = GTK_AT_CONTEXT (user_data); + + /* Numeric attributes */ struct { const char *name; GtkAccessibleProperty property; - } properties[] = { + } num_properties[] = { { "MinimumValue", GTK_ACCESSIBLE_PROPERTY_VALUE_MIN }, { "MaximumValue", GTK_ACCESSIBLE_PROPERTY_VALUE_MAX }, { "CurrentValue", GTK_ACCESSIBLE_PROPERTY_VALUE_NOW }, }; - int i; - for (i = 0; i < G_N_ELEMENTS (properties); i++) + /* String attributes */ + struct { + const char *name; + GtkAccessibleProperty property; + } str_properties[] = { + { "Text", GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT }, + }; + + for (int i = 0; i < G_N_ELEMENTS (num_properties); i++) { - if (g_strcmp0 (property_name, properties[i].name) == 0) + if (g_strcmp0 (property_name, num_properties[i].name) == 0) { - if (gtk_at_context_has_accessible_property (ctx, properties[i].property)) + if (gtk_at_context_has_accessible_property (ctx, num_properties[i].property)) { - GtkAccessibleValue *value; + GtkAccessibleValue *value = + gtk_at_context_get_accessible_property (ctx, num_properties[i].property); - value = gtk_at_context_get_accessible_property (ctx, properties[i].property); return g_variant_new_double (gtk_number_accessible_value_get (value)); } } } - if (g_strcmp0 (property_name, "MinimumIncrement") == 0) + for (int i = 0; i < G_N_ELEMENTS (str_properties); i++) { - GtkAccessibleRange *range = GTK_ACCESSIBLE_RANGE (gtk_at_context_get_accessible (ctx)); - return g_variant_new_double(gtk_accessible_range_get_minimum_increment (range)); - } + if (g_strcmp0 (property_name, str_properties[i].name) == 0) + { + if (gtk_at_context_has_accessible_property (ctx, str_properties[i].property)) + { + GtkAccessibleValue *value = + gtk_at_context_get_accessible_property (ctx, str_properties[i].property); + + return g_variant_new_string (gtk_string_accessible_value_get (value)); + } + } + } + + /* Special-case MinimumIncrement as it does not have an ARIA counterpart */ + if (g_strcmp0 (property_name, "MinimumIncrement") == 0) + return g_variant_new_double (0.0); + /* fall back for widgets that should have the * properties but don't */ @@ -89,9 +111,7 @@ handle_value_set_property (GDBusConnection *connection, GtkAccessibleRange *range = GTK_ACCESSIBLE_RANGE (gtk_at_context_get_accessible (self)); if (g_strcmp0 (property_name, "CurrentValue") == 0) - { - return gtk_accessible_range_set_current_value (range, g_variant_get_double (value)); - } + return gtk_accessible_range_set_current_value (range, g_variant_get_double (value)); return FALSE; } @@ -110,4 +130,3 @@ gtk_atspi_get_value_vtable (GtkAccessible *accessible) return NULL; } - |