summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--gtk/a11y/Makefile.am2
-rw-r--r--gtk/a11y/gtklevelbaraccessible.c140
-rw-r--r--gtk/a11y/gtklevelbaraccessible.h53
-rw-r--r--gtk/gtklevelbar.c4
-rw-r--r--tests/a11y/Makefile.am2
-rw-r--r--tests/a11y/value.c127
7 files changed, 329 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 6b9e4aca75..d8052f3b8a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,7 +44,7 @@ m4_define([gtk_binary_version], [3.0.0])
# required versions of other packages
m4_define([glib_required_version], [2.35.3])
m4_define([pango_required_version], [1.32.4])
-m4_define([atk_required_version], [2.5.3])
+m4_define([atk_required_version], [2.7.4])
m4_define([cairo_required_version], [1.10.0])
m4_define([gdk_pixbuf_required_version], [2.27.1])
m4_define([introspection_required_version], [1.32.0])
diff --git a/gtk/a11y/Makefile.am b/gtk/a11y/Makefile.am
index 91136c6fcc..a451e8c1ea 100644
--- a/gtk/a11y/Makefile.am
+++ b/gtk/a11y/Makefile.am
@@ -23,6 +23,7 @@ gtka11y_c_sources = \
gtkimageaccessible.c \
gtkimagecellaccessible.c \
gtklabelaccessible.c \
+ gtklevelbaraccessible.c \
gtklinkbuttonaccessible.c \
gtklockbuttonaccessible.c \
gtkmenuaccessible.c \
@@ -69,6 +70,7 @@ gtka11yinclude_HEADERS = \
gtkimageaccessible.h \
gtkimagecellaccessible.h \
gtklabelaccessible.h \
+ gtklevelbaraccessible.h \
gtklinkbuttonaccessible.h \
gtklockbuttonaccessible.h \
gtkmenuaccessible.h \
diff --git a/gtk/a11y/gtklevelbaraccessible.c b/gtk/a11y/gtklevelbaraccessible.c
new file mode 100644
index 0000000000..be90df690b
--- /dev/null
+++ b/gtk/a11y/gtklevelbaraccessible.c
@@ -0,0 +1,140 @@
+/* GAIL - The GNOME Accessibility Implementation Library
+ * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
+ * Copyright 2013 SUSE LLC.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include "gtklevelbaraccessible.h"
+
+
+static void atk_value_interface_init (AtkValueIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkLevelBarAccessible, gtk_level_bar_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
+
+static void
+gtk_level_bar_accessible_initialize (AtkObject *obj,
+ gpointer data)
+{
+ ATK_OBJECT_CLASS (gtk_level_bar_accessible_parent_class)->initialize (obj, data);
+
+ obj->role = ATK_ROLE_LEVEL_BAR;
+}
+
+static void
+gtk_level_bar_accessible_notify_gtk (GObject *obj,
+ GParamSpec *pspec)
+{
+ GtkWidget *widget = GTK_WIDGET (obj);
+ GtkLevelBarAccessible *level_bar = GTK_LEVEL_BAR_ACCESSIBLE (gtk_widget_get_accessible (widget));
+
+ if (strcmp (pspec->name, "value") == 0)
+ {
+ g_object_notify (G_OBJECT (level_bar), "accessible-value");
+ }
+ else
+ GTK_WIDGET_ACCESSIBLE_CLASS (gtk_level_bar_accessible_parent_class)->notify_gtk (obj, pspec);
+}
+
+
+
+static void
+gtk_level_bar_accessible_class_init (GtkLevelBarAccessibleClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+ GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
+
+ widget_class->notify_gtk = gtk_level_bar_accessible_notify_gtk;
+
+ class->initialize = gtk_level_bar_accessible_initialize;
+}
+
+static void
+gtk_level_bar_accessible_init (GtkLevelBarAccessible *button)
+{
+}
+
+static void
+gtk_level_bar_accessible_get_current_value (AtkValue *obj,
+ GValue *value)
+{
+ GtkWidget *widget;
+ GtkLevelBar *level_bar;
+
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+ level_bar = GTK_LEVEL_BAR (widget);
+
+ memset (value, 0, sizeof (GValue));
+ g_value_init (value, G_TYPE_DOUBLE);
+ g_value_set_double (value, gtk_level_bar_get_value (level_bar));
+}
+
+static void
+gtk_level_bar_accessible_get_maximum_value (AtkValue *obj,
+ GValue *value)
+{
+ GtkWidget *widget;
+ GtkLevelBar *level_bar;
+
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+ level_bar = GTK_LEVEL_BAR (widget);
+
+ memset (value, 0, sizeof (GValue));
+ g_value_init (value, G_TYPE_DOUBLE);
+ g_value_set_double (value, gtk_level_bar_get_max_value (level_bar));
+}
+
+static void
+gtk_level_bar_accessible_get_minimum_value (AtkValue *obj,
+ GValue *value)
+{
+ GtkWidget *widget;
+ GtkLevelBar *level_bar;
+
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+ level_bar = GTK_LEVEL_BAR (widget);
+
+ memset (value, 0, sizeof (GValue));
+ g_value_init (value, G_TYPE_DOUBLE);
+ g_value_set_double (value, gtk_level_bar_get_min_value (level_bar));
+}
+
+static gboolean
+gtk_level_bar_accessible_set_current_value (AtkValue *obj,
+ const GValue *value)
+{
+ GtkWidget *widget;
+ GtkLevelBar *level_bar;
+
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+ level_bar = GTK_LEVEL_BAR (widget);
+
+ gtk_level_bar_set_value (level_bar, g_value_get_double (value));
+
+ return TRUE;
+}
+
+static void
+atk_value_interface_init (AtkValueIface *iface)
+{
+ iface->get_current_value = gtk_level_bar_accessible_get_current_value;
+ iface->get_maximum_value = gtk_level_bar_accessible_get_maximum_value;
+ iface->get_minimum_value = gtk_level_bar_accessible_get_minimum_value;
+ iface->set_current_value = gtk_level_bar_accessible_set_current_value;
+}
diff --git a/gtk/a11y/gtklevelbaraccessible.h b/gtk/a11y/gtklevelbaraccessible.h
new file mode 100644
index 0000000000..6659346b0e
--- /dev/null
+++ b/gtk/a11y/gtklevelbaraccessible.h
@@ -0,0 +1,53 @@
+/* GAIL - The GNOME Accessibility Implementation Library
+ * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2013 SUSE LLC.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_LEVEL_BAR_ACCESSIBLE_H__
+#define __GTK_LEVEL_BAR_ACCESSIBLE_H__
+
+#include "gtkentryaccessible.h"
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_LEVEL_BAR_ACCESSIBLE (gtk_level_bar_accessible_get_type ())
+#define GTK_LEVEL_BAR_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LEVEL_BAR_ACCESSIBLE, GtkLevelBarAccessible))
+#define GTK_LEVEL_BAR_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LEVEL_BAR_ACCESSIBLE, GtkLevelBarAccessibleClass))
+#define GTK_IS_LEVEL_BAR_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LEVEL_BAR_ACCESSIBLE))
+#define GTK_IS_LEVEL_BAR_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LEVEL_BAR_ACCESSIBLE))
+#define GTK_LEVEL_BAR_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LEVEL_BAR_ACCESSIBLE, GtkLevelBarAccessibleClass))
+
+typedef struct _GtkLevelBarAccessible GtkLevelBarAccessible;
+typedef struct _GtkLevelBarAccessibleClass GtkLevelBarAccessibleClass;
+typedef struct _GtkLevelBarAccessiblePrivate GtkLevelBarAccessiblePrivate;
+
+struct _GtkLevelBarAccessible
+{
+ GtkWidgetAccessible parent;
+
+ GtkLevelBarAccessiblePrivate *priv;
+};
+
+struct _GtkLevelBarAccessibleClass
+{
+ GtkWidgetAccessibleClass parent_class;
+};
+
+GType gtk_level_bar_accessible_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GTK_LEVEL_BAR_ACCESSIBLE_H__ */
diff --git a/gtk/gtklevelbar.c b/gtk/gtklevelbar.c
index 25a8161e14..fff48919e8 100644
--- a/gtk/gtklevelbar.c
+++ b/gtk/gtklevelbar.c
@@ -97,6 +97,8 @@
#include <math.h>
#include <stdlib.h>
+#include "a11y/gtklevelbaraccessible.h"
+
#include "fallback-c89.c"
#define DEFAULT_BLOCK_SIZE 3
@@ -1024,6 +1026,8 @@ gtk_level_bar_class_init (GtkLevelBarClass *klass)
g_type_class_add_private (klass, sizeof (GtkLevelBarPrivate));
g_object_class_install_properties (oclass, LAST_PROPERTY, properties);
+
+ gtk_widget_class_set_accessible_type (wclass, GTK_TYPE_LEVEL_BAR_ACCESSIBLE);
}
static void
diff --git a/tests/a11y/Makefile.am b/tests/a11y/Makefile.am
index b84a1ff573..d7a54becfc 100644
--- a/tests/a11y/Makefile.am
+++ b/tests/a11y/Makefile.am
@@ -31,6 +31,8 @@ TEST_PROGS += children
TEST_PROGS += derive
+TEST_PROGS += value
+
# the focus test has no chance of working until
# all the idle handlers in gail are gone
#
diff --git a/tests/a11y/value.c b/tests/a11y/value.c
new file mode 100644
index 0000000000..af50a3688e
--- /dev/null
+++ b/tests/a11y/value.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2011 Red Hat Inc.
+ * Copyright (C) 2012 SUSE LLC.
+ *
+ * Author:
+ * Mike Gorse <mgorse@suse.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+#include <string.h>
+
+static void
+set_value (GtkWidget *widget,
+ gint value)
+{
+ if (GTK_IS_LEVEL_BAR (widget))
+ gtk_level_bar_set_value (GTK_LEVEL_BAR (widget), value);
+ else if (GTK_IS_RANGE (widget))
+ {
+ GtkAdjustment *adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
+ gtk_adjustment_set_value (adjustment, value);
+ }
+ else if (GTK_IS_SPIN_BUTTON (widget))
+ {
+ GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
+ gtk_adjustment_set_value (adjustment, value);
+ }
+}
+
+typedef struct
+{
+ gint count;
+ gchar *last_name;
+} NotifyData;
+
+static void
+notify_cb (GObject *obj,
+ GParamSpec *pspec, NotifyData *data)
+{
+ data->count++;
+ if (data->last_name)
+ g_free (data->last_name);
+ data->last_name = g_strdup (pspec->name);
+}
+
+static void
+test_basic (GtkWidget *widget)
+{
+ NotifyData notify_data;
+ AtkObject *atk_object;
+ AtkValue *atk_value;
+ gdouble value = 50;
+ GValue ret;
+
+ atk_object = gtk_widget_get_accessible (widget);
+ atk_value = ATK_VALUE (atk_object);
+
+ memset (&notify_data, 0, sizeof (notify_data));
+ g_signal_connect (atk_object, "notify", G_CALLBACK (notify_cb), &notify_data);
+ set_value (widget, value);
+ g_assert_cmpint (notify_data.count, ==, 1);
+ g_assert_cmpstr (notify_data.last_name, ==, "accessible-value");
+
+ memset (&ret, 0, sizeof (ret));
+ atk_value_get_current_value (atk_value, &ret);
+ g_assert_cmpfloat (g_value_get_double (&ret), ==, value);
+
+ g_free (notify_data.last_name);
+ g_signal_handlers_disconnect_by_func (atk_object, G_CALLBACK (notify_cb), &notify_data);
+}
+
+static void
+setup_test (GtkWidget *widget)
+{
+ set_value (widget, 0);
+}
+
+static void
+add_value_test (const gchar *prefix,
+ GTestFixtureFunc test_func,
+ GtkWidget *widget)
+{
+ gchar *path;
+
+ path = g_strdup_printf ("%s/%s", prefix, G_OBJECT_TYPE_NAME (widget));
+ g_test_add_vtable (path,
+ 0,
+ g_object_ref (widget),
+ (GTestFixtureFunc) setup_test,
+ (GTestFixtureFunc) test_func,
+ (GTestFixtureFunc) g_object_unref);
+ g_free (path);
+}
+
+static void
+add_value_tests (GtkWidget *widget)
+{
+ g_object_ref_sink (widget);
+ add_value_test ("/value/basic", (GTestFixtureFunc) test_basic, widget);
+ g_object_unref (widget);
+}
+
+int
+main (int argc, char *argv[])
+{
+ gtk_test_init (&argc, &argv, NULL);
+
+ g_test_bug_base ("http://bugzilla.gnome.org/");
+
+ add_value_tests (gtk_spin_button_new_with_range (0, 100, 1));
+ add_value_tests (gtk_level_bar_new_for_interval (0, 100));
+
+ return g_test_run ();
+}