This introduces GtkAccessibleRange, an interface which allows the accessibility backend to work with a control which can adjust a value.
#include <gtk/gtkaboutdialog.h>
#include <gtk/gtkaccelgroup.h>
#include <gtk/gtkaccessible.h>
+#include <gtk/gtkaccessiblerange.h>
#include <gtk/gtkactionable.h>
#include <gtk/gtkactionbar.h>
#include <gtk/gtkadjustment.h>
return role_names[role];
}
+/*< private >
+ * gtk_accessible_role_is_range_subclass:
+ * @role: a `GtkAccessibleRole`
+ *
+ * Checks if @role is considered to be a subclass of %GTK_ACCESSIBLE_ROLE_RANGE
+ * according to the WAI-ARIA specification.
+ *
+ * Returns: whether the @role is range-like
+ */
+gboolean
+gtk_accessible_role_is_range_subclass (GtkAccessibleRole role)
+{
+ /* Same trick as in gtkatcontext.c */
+ switch ((int) role)
+ {
+ case GTK_ACCESSIBLE_ROLE_METER:
+ case GTK_ACCESSIBLE_ROLE_PROGRESS_BAR:
+ case GTK_ACCESSIBLE_ROLE_SCROLLBAR:
+ case GTK_ACCESSIBLE_ROLE_SLIDER:
+ case GTK_ACCESSIBLE_ROLE_SPIN_BUTTON:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
/*<private>
* gtk_accessible_platform_changed:
* @self: a `GtkAccessible`
const char * gtk_accessible_role_to_name (GtkAccessibleRole role,
const char *domain);
+gboolean gtk_accessible_role_is_range_subclass (GtkAccessibleRole role);
+
gboolean gtk_accessible_should_present (GtkAccessible *self);
void gtk_accessible_platform_changed (GtkAccessible *self,
--- /dev/null
+/* gtkaccessiblerange.c: Accessible range interface\r
+ *\r
+ * Copyright © 2022 Red Hat Inc.\r
+ * \r
+ * SPDX-License-Identifier: LGPL-2.1-or-later\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Lesser General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2.1 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Lesser General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+\r
+/**\r
+ * GtkAccessibleRange:\r
+ * \r
+ * This interface describes range controls, e. g. controls which have a single\r
+ * value which can optionally be changed by the user.\r
+ * \r
+ * This interface is expected to be implemented by controls of the\r
+ * %GTK_ACCESSIBLE_ROLE_METER, %GTK_ACCESSIBLE_ROLE_PROGRESS_BAR,\r
+ * %GTK_ACCESSIBLE_ROLE_SCROLLBAR, %GTK_ACCESSIBLE_ROLE_SLIDER and %GTK_ACCESSIBLE_ROLE_SPIN_BUTTON\r
+ * role. If that is not the case, a warning will be issued at runtime.\r
+ * \r
+ * In addition to this interface, its implementors are expected to provide the\r
+ * correct values for the following properties: %GTK_ACCESSIBLE_PROPERTY_VALUE_MAX,\r
+ * %GTK_ACCESSIBLE_PROPERTY_VALUE_MIN and %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW.\r
+ */\r
+\r
+#include "config.h"\r
+\r
+#include "gtkaccessiblerange.h"\r
+\r
+G_DEFINE_INTERFACE (GtkAccessibleRange, gtk_accessible_range, GTK_TYPE_ACCESSIBLE)\r
+\r
+static void\r
+gtk_accessible_range_default_init (GtkAccessibleRangeInterface *iface)\r
+{\r
+}\r
+\r
+ /*\r
+ * gtk_accessible_range_get_minimum_increment:\r
+ * @self: a `GtkAccessibleRange`\r
+ *\r
+ * Returns the minimum increment which this `GtkAccessibleRange` supports.\r
+ *\r
+ * Returns: the minimum increment\r
+ */\r
+double\r
+gtk_accessible_range_get_minimum_increment (GtkAccessibleRange *self)\r
+{\r
+ g_return_val_if_fail (GTK_IS_ACCESSIBLE_RANGE (self), .0);\r
+\r
+ return GTK_ACCESSIBLE_RANGE_GET_IFACE (self)->get_minimum_increment (self);\r
+}\r
+\r
+ /*\r
+ * gtk_accessible_range_set_current_value:\r
+ * @self: a `GtkAccessibleRange`\r
+ *\r
+ * Sets the current value of this `GtkAccessibleRange`.\r
+ */\r
+void\r
+gtk_accessible_range_set_current_value (GtkAccessibleRange *self, double value)\r
+{\r
+ g_return_if_fail (GTK_IS_ACCESSIBLE_RANGE (self));\r
+\r
+ return GTK_ACCESSIBLE_RANGE_GET_IFACE (self)->set_current_value (self, value);\r
+}
\ No newline at end of file
--- /dev/null
+/* gtkaccessiblerange.h: Accessible range interface\r
+ *\r
+ * Copyright © 2022 Red Hat Inc.\r
+ * \r
+ * SPDX-License-Identifier: LGPL-2.1-or-later\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Lesser General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2.1 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Lesser General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+\r
+#pragma once\r
+\r
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)\r
+#error "Only <gtk/gtk.h> can be included directly."\r
+#endif\r
+\r
+#include <glib-object.h>\r
+#include <gtk/gtkaccessible.h>\r
+\r
+G_BEGIN_DECLS\r
+#define GTK_TYPE_ACCESSIBLE_RANGE (gtk_accessible_range_get_type())\r
+\r
+GDK_AVAILABLE_IN_ALL\r
+G_DECLARE_INTERFACE (GtkAccessibleRange, gtk_accessible_range, GTK, ACCESSIBLE_RANGE, GtkAccessible)\r
+\r
+struct _GtkAccessibleRangeInterface\r
+{\r
+ GTypeInterface g_iface;\r
+\r
+ double (* get_minimum_increment) (GtkAccessibleRange *self);\r
+ void (* set_current_value) (GtkAccessibleRange *self, double value);\r
+};\r
+\r
+GDK_AVAILABLE_IN_ALL\r
+double gtk_accessible_range_get_minimum_increment (GtkAccessibleRange *self);\r
+\r
+GDK_AVAILABLE_IN_ALL\r
+void gtk_accessible_range_set_current_value (GtkAccessibleRange *self, double value);\r
+\r
+G_END_DECLS
\ No newline at end of file
'gtkaboutdialog.c',
'gtkaccelgroup.c',
'gtkaccessible.c',
+ 'gtkaccessiblerange.c',
'gtkactionable.c',
'gtkactionbar.c',
'gtkadjustment.c',
'gtkaboutdialog.h',
'gtkaccelgroup.h',
'gtkaccessible.h',
+ 'gtkaccessiblerange.h',
'gtkactionable.h',
'gtkactionbar.h',
'gtkadjustment.h',