summaryrefslogtreecommitdiff
path: root/gtk/gtkaccessiblerange.c
diff options
context:
space:
mode:
authorLukáš Tyrychtr <lukastyrychtr@gmail.com>2022-09-14 16:53:04 +0200
committerLukáš Tyrychtr <lukastyrychtr@gmail.com>2022-09-29 09:36:08 +0200
commit86864d7bc063ad69474d845e21f50c1705ddf04a (patch)
treea2467756200c6ca42b811bd9c1d29b4bf308da48 /gtk/gtkaccessiblerange.c
parent485ffcde38f91fbf9c9c8586f9000dd86d036898 (diff)
downloadgtk+-86864d7bc063ad69474d845e21f50c1705ddf04a.tar.gz
Account for GtkAccessibleRange implementations which do not have a
minimum step and it makes no sense for them to set the current value
Diffstat (limited to 'gtk/gtkaccessiblerange.c')
-rw-r--r--gtk/gtkaccessiblerange.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/gtk/gtkaccessiblerange.c b/gtk/gtkaccessiblerange.c
index 555e1eb921..363e954515 100644
--- a/gtk/gtkaccessiblerange.c
+++ b/gtk/gtkaccessiblerange.c
@@ -40,9 +40,23 @@
G_DEFINE_INTERFACE (GtkAccessibleRange, gtk_accessible_range, GTK_TYPE_ACCESSIBLE)
+static double
+gtk_accessible_range_default_get_minimum_increment (GtkAccessibleRange *accessible_range)
+{
+ return 0.0;
+}
+
+static void
+gtk_accessible_range_default_set_current_value (GtkAccessibleRange *accessible_range, double value)
+{
+ /* By default, we do nothing */
+}
+
static void
gtk_accessible_range_default_init (GtkAccessibleRangeInterface *iface)
{
+ iface->get_minimum_increment = gtk_accessible_range_default_get_minimum_increment;
+ iface->set_current_value = gtk_accessible_range_default_set_current_value;
}
/*
@@ -51,7 +65,7 @@ gtk_accessible_range_default_init (GtkAccessibleRangeInterface *iface)
*
* Returns the minimum increment which this `GtkAccessibleRange` supports.
*
- * Returns: the minimum increment
+ * Returns: the minimum increment, or 0.0 if not overridden
*/
double
gtk_accessible_range_get_minimum_increment (GtkAccessibleRange *self)
@@ -66,11 +80,15 @@ gtk_accessible_range_get_minimum_increment (GtkAccessibleRange *self)
* @self: a `GtkAccessibleRange`
*
* Sets the current value of this `GtkAccessibleRange`.
+ * Note that for some widgets implementing this interface, setting a value
+ * through the accessibility API makes no sense, so calling this function may
+ * in some cases do nothing.
*/
void
gtk_accessible_range_set_current_value (GtkAccessibleRange *self, double value)
{
g_return_if_fail (GTK_IS_ACCESSIBLE_RANGE (self));
- return GTK_ACCESSIBLE_RANGE_GET_IFACE (self)->set_current_value (self, value);
+ GtkAccessibleRangeInterface *iface = GTK_ACCESSIBLE_RANGE_GET_IFACE (self);
+ iface->set_current_value (self, value);
} \ No newline at end of file