dropdown: Avoid accessibility warnings

The image here is just presentational.
This commit is contained in:
Matthias Clasen 2023-06-18 13:04:02 -04:00
parent 28e1f288c3
commit 05ea3470e5
2 changed files with 16 additions and 1 deletions

View File

@ -171,6 +171,10 @@ button_toggled (GtkWidget *widget,
gtk_popover_popup (GTK_POPOVER (self->popup));
else
gtk_popover_popdown (GTK_POPOVER (self->popup));
gtk_accessible_update_state (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_STATE_EXPANDED, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)),
-1);
}
static void
@ -695,7 +699,10 @@ setup_item (GtkSignalListItemFactory *factory,
label = gtk_label_new (NULL);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_box_append (GTK_BOX (box), label);
icon = gtk_image_new_from_icon_name ("object-select-symbolic");
icon = g_object_new (GTK_TYPE_IMAGE,
"icon-name", "object-select-symbolic",
"accessible-role", GTK_ACCESSIBLE_ROLE_NONE,
NULL);
gtk_box_append (GTK_BOX (box), icon);
gtk_list_item_set_child (list_item, box);
}

View File

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk40">
<template class="GtkDropDown" parent="GtkWidget">
<accessibility>
<property name="has-popup">1</property>
<relation name="labelled-by">button_item</relation>
<state name="expanded">0</state>
</accessibility>
<child>
<object class="GtkToggleButton" id="button">
<signal name="toggled" handler="button_toggled"/>
@ -9,6 +14,7 @@
<property name="can-focus">0</property>
<child>
<object class="GtkStack" id="button_stack">
<property name="accessible-role">generic</property>
<property name="hexpand">1</property>
<property name="hhomogeneous">0</property>
<child>
@ -34,6 +40,7 @@
</child>
<child>
<object class="GtkBuiltinIcon" id="arrow">
<property name="accessible-role">none</property>
<property name="css-name">arrow</property>
</object>
</child>
@ -43,6 +50,7 @@
</child>
<child>
<object class="GtkPopover" id="popup">
<property name="accessible-role">list-box</property>
<signal name="closed" handler="popover_closed"/>
<property name="halign">1</property>
<property name="has-arrow">0</property>