[gtk/ebassi/a11y/accessible-range: 2/14] Implement GtkAccessibleRange for GtkRange




commit 0304eaec94c96aeffa0ad83ce209fd1b26d4b972
Author: Lukáš Tyrychtr <lukastyrychtr gmail com>
Date:   Wed Sep 14 14:46:19 2022 +0200

    Implement GtkAccessibleRange for GtkRange

 gtk/gtkrange.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 7ebb2d4316..53b852c6f5 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -28,6 +28,7 @@
 #include "gtkrangeprivate.h"
 
 #include "gtkaccessible.h"
+#include "gtkaccessiblerange.h"
 #include "gtkadjustmentprivate.h"
 #include "gtkcolorscaleprivate.h"
 #include "gtkcssboxesprivate.h"
@@ -246,8 +247,12 @@ static gboolean      gtk_range_scroll_controller_scroll (GtkEventControllerScrol
 static void          gtk_range_set_orientation          (GtkRange       *range,
                                                          GtkOrientation  orientation);
 
+static void gtk_range_accessible_range_init (GtkAccessibleRangeInterface *iface);
+
 G_DEFINE_TYPE_WITH_CODE (GtkRange, gtk_range, GTK_TYPE_WIDGET,
                          G_ADD_PRIVATE (GtkRange)
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE_RANGE,
+                                                gtk_range_accessible_range_init)
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE,
                                                 NULL))
 
@@ -435,6 +440,27 @@ gtk_range_class_init (GtkRangeClass *class)
   gtk_widget_class_set_css_name (widget_class, I_("range"));
 }
 
+static double
+gtk_range_accessible_range_get_minimum_increment (GtkAccessibleRange *accessible_range)
+{
+  GtkRange *range = GTK_RANGE (accessible_range);
+  return gtk_adjustment_get_minimum_increment (gtk_range_get_adjustment (range));
+}
+
+static void
+gtk_range_accessible_range_set_current_value (GtkAccessibleRange *accessible_range, double value)
+{
+  GtkRange *range = GTK_RANGE (accessible_range);
+  gtk_range_set_value (range, value);
+}
+
+static void
+gtk_range_accessible_range_init (GtkAccessibleRangeInterface *iface)
+{
+  iface->get_minimum_increment = gtk_range_accessible_range_get_minimum_increment;
+  iface->set_current_value = gtk_range_accessible_range_set_current_value;
+}
+
 static void
 gtk_range_set_property (GObject      *object,
                        guint         prop_id,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]