[gtk/ebassi/a11y/accessible-range: 3/14] Implement GtkAccessibleRange for GtkSpinButton




commit 485ffcde38f91fbf9c9c8586f9000dd86d036898
Author: Lukáš Tyrychtr <lukastyrychtr gmail com>
Date:   Wed Sep 14 16:49:32 2022 +0200

    Implement GtkAccessibleRange for GtkSpinButton

 gtk/gtkspinbutton.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index 8506f7aa26..f9eb4a2f45 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -32,6 +32,7 @@
 #include "gtkspinbuttonprivate.h"
 
 #include "gtkaccessibleprivate.h"
+#include "gtkaccessiblerange.h"
 #include "gtkadjustment.h"
 #include "gtkbox.h"
 #include "gtkbutton.h"
@@ -308,6 +309,8 @@ static void gtk_spin_button_update_width_chars (GtkSpinButton *spin_button);
 
 static void gtk_spin_button_accessible_init (GtkAccessibleInterface *iface);
 
+static void gtk_spin_button_accessible_range_init (GtkAccessibleRangeInterface *iface);
+
 static guint spinbutton_signals[LAST_SIGNAL] = {0};
 static GParamSpec *spinbutton_props[NUM_SPINBUTTON_PROPS] = {NULL, };
 
@@ -315,6 +318,8 @@ G_DEFINE_TYPE_WITH_CODE (GtkSpinButton, gtk_spin_button, GTK_TYPE_WIDGET,
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE,
                                                 gtk_spin_button_accessible_init)
+                                                G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE_RANGE,
+                                                                       gtk_spin_button_accessible_range_init)
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
                                                 gtk_spin_button_editable_init)
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE,
@@ -632,6 +637,27 @@ gtk_spin_button_accessible_init (GtkAccessibleInterface *iface)
   iface->get_platform_state = gtk_spin_button_accessible_get_platform_state;
 }
 
+static double
+gtk_spin_button_accessible_range_get_minimum_increment (GtkAccessibleRange *accessible_range)
+{
+  GtkSpinButton *button = GTK_SPIN_BUTTON (accessible_range);
+  return gtk_adjustment_get_minimum_increment (gtk_spin_button_get_adjustment (button));
+}
+
+static void
+gtk_spin_button_accessible_range_set_current_value (GtkAccessibleRange *accessible_range, double value)
+{
+  GtkSpinButton *button = GTK_SPIN_BUTTON (accessible_range);
+  gtk_spin_button_set_value (button, value);
+}
+
+static void
+gtk_spin_button_accessible_range_init (GtkAccessibleRangeInterface *iface)
+{
+  iface->get_minimum_increment = gtk_spin_button_accessible_range_get_minimum_increment;
+  iface->set_current_value = gtk_spin_button_accessible_range_set_current_value;
+}
+
 static void
 gtk_cell_editable_spin_button_activated (GtkText *text, GtkSpinButton *spin)
 {


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