From fc7e7495a6a4f3bb7335f48cd64a7648a21ffea7 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 2 May 2014 20:47:00 -0400 Subject: [PATCH] GtkScaleButton: Implement new AtkValue interface The AtkValue interface has been replaced in ATK 2.12. Implement the new one in addition to the old one. --- gtk/a11y/gtkscalebuttonaccessible.c | 67 +++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/gtk/a11y/gtkscalebuttonaccessible.c b/gtk/a11y/gtkscalebuttonaccessible.c index fa87e70939..1db9db7ba8 100644 --- a/gtk/a11y/gtkscalebuttonaccessible.c +++ b/gtk/a11y/gtkscalebuttonaccessible.c @@ -270,6 +270,68 @@ gtk_scale_button_accessible_set_current_value (AtkValue *obj, return TRUE; } +static void +gtk_scale_button_accessible_get_value_and_text (AtkValue *obj, + gdouble *value, + gchar **text) +{ + GtkWidget *widget; + GtkAdjustment *adjustment; + + widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); + adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget)); + if (adjustment == NULL) + return; + + *value = gtk_adjustment_get_value (adjustment); + *text = NULL; +} + +static AtkRange * +gtk_scale_button_accessible_get_range (AtkValue *obj) +{ + GtkWidget *widget; + GtkAdjustment *adjustment; + + widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); + adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget)); + if (adjustment == NULL) + return NULL; + + return atk_range_new (gtk_adjustment_get_lower (adjustment), + gtk_adjustment_get_upper (adjustment), + NULL); +} + +static void +gtk_scale_button_accessible_set_value (AtkValue *obj, + const gdouble value) +{ + GtkWidget *widget; + GtkAdjustment *adjustment; + + widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); + adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget)); + if (adjustment == NULL) + return; + + gtk_adjustment_set_value (adjustment, value); +} + +static gdouble +gtk_scale_button_accessible_get_increment (AtkValue *obj) +{ + GtkWidget *widget; + GtkAdjustment *adjustment; + + widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); + adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget)); + if (adjustment == NULL) + return 0; + + return gtk_adjustment_get_minimum_increment (adjustment); +} + static void atk_value_interface_init (AtkValueIface *iface) { @@ -278,4 +340,9 @@ atk_value_interface_init (AtkValueIface *iface) iface->get_minimum_value = gtk_scale_button_accessible_get_minimum_value; iface->get_minimum_increment = gtk_scale_button_accessible_get_minimum_increment; iface->set_current_value = gtk_scale_button_accessible_set_current_value; + + iface->get_value_and_text = gtk_scale_button_accessible_get_value_and_text; + iface->get_range = gtk_scale_button_accessible_get_range; + iface->set_value = gtk_scale_button_accessible_set_value; + iface->get_increment = gtk_scale_button_accessible_get_increment; }