summaryrefslogtreecommitdiff
path: root/gtk/gtkmenubutton.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-10-21 16:27:23 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-10-21 19:47:48 -0400
commit087c0078ca63e1e513f5188a059925f6c23940f6 (patch)
tree2cc32873f346ac2b16efa2678912860b4c49a627 /gtk/gtkmenubutton.c
parentb9ae54c95113b7ebfb01ae26bfe83e9301cb7a22 (diff)
downloadgtk+-087c0078ca63e1e513f5188a059925f6c23940f6.tar.gz
menubutton: initial accessibility setup
Set roles, properties and relations according to the ARIA authoring practices document.
Diffstat (limited to 'gtk/gtkmenubutton.c')
-rw-r--r--gtk/gtkmenubutton.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index 3ed2e7af2e..4807be3994 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -106,6 +106,10 @@
*
* GtkMenuButton has a single CSS node with name button. To differentiate
* it from a plain #GtkButton, it gets the .popup style class.
+ *
+ * # Accessibility
+ *
+ * GtkMenuButton uses the #GTK_ACCESSIBLE_ROLE_BUTTON role.
*/
#include "config.h"
@@ -269,9 +273,18 @@ gtk_menu_button_toggled (GtkMenuButton *self)
if (self->popover)
{
if (active)
- gtk_popover_popup (GTK_POPOVER (self->popover));
+ {
+ gtk_popover_popup (GTK_POPOVER (self->popover));
+ gtk_accessible_update_state (GTK_ACCESSIBLE (self),
+ GTK_ACCESSIBLE_STATE_EXPANDED, TRUE,
+ -1);
+ }
else
- gtk_popover_popdown (GTK_POPOVER (self->popover));
+ {
+ gtk_popover_popdown (GTK_POPOVER (self->popover));
+ gtk_accessible_reset_state (GTK_ACCESSIBLE (self),
+ GTK_ACCESSIBLE_STATE_EXPANDED);
+ }
}
}
@@ -417,6 +430,7 @@ gtk_menu_button_class_init (GtkMenuButtonClass *klass)
g_object_class_install_properties (gobject_class, LAST_PROP, menu_button_props);
gtk_widget_class_set_css_name (widget_class, I_("menubutton"));
+ gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_BUTTON);
}
static void
@@ -495,9 +509,23 @@ gtk_menu_button_new (void)
static void
update_sensitivity (GtkMenuButton *self)
{
- gtk_widget_set_sensitive (self->button,
- self->popover != NULL ||
- self->create_popup_func != NULL);
+ gboolean has_popup;
+
+ has_popup = self->popover != NULL || self->create_popup_func != NULL;
+
+ gtk_widget_set_sensitive (self->button, has_popup);
+
+ gtk_accessible_update_property (GTK_ACCESSIBLE (self),
+ GTK_ACCESSIBLE_PROPERTY_HAS_POPUP, has_popup,
+ -1);
+ if (self->popover != NULL)
+ gtk_accessible_update_relation (GTK_ACCESSIBLE (self),
+ GTK_ACCESSIBLE_RELATION_CONTROLS,
+ g_list_append (NULL, self->popover),
+ -1);
+ else
+ gtk_accessible_reset_relation (GTK_ACCESSIBLE (self),
+ GTK_ACCESSIBLE_RELATION_CONTROLS);
}
static gboolean