shortcutswindow: Fix up roles and labels again

This commit is contained in:
Matthias Clasen 2023-06-21 13:18:58 -04:00
parent 533a2cf9ec
commit 01274dfbb9
4 changed files with 19 additions and 4 deletions

View File

@ -420,7 +420,7 @@ gtk_shortcut_label_rebuild (GtkShortcutLabel *self)
child = gtk_widget_get_prev_sibling (child)) child = gtk_widget_get_prev_sibling (child))
{ {
parts = g_list_prepend (parts, child); parts = g_list_prepend (parts, child);
} }
gtk_accessible_relation_init_value (relation, &value); gtk_accessible_relation_init_value (relation, &value);
g_value_set_pointer (&value, parts); g_value_set_pointer (&value, parts);
gtk_accessible_update_relation_value (GTK_ACCESSIBLE (self), gtk_accessible_update_relation_value (GTK_ACCESSIBLE (self),
@ -524,6 +524,7 @@ gtk_shortcut_label_class_init (GtkShortcutLabelClass *klass)
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT); gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
gtk_widget_class_set_css_name (widget_class, I_("shortcut")); gtk_widget_class_set_css_name (widget_class, I_("shortcut"));
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GROUP);
} }
static void static void

View File

@ -27,6 +27,7 @@
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtkshortcutsshortcut.h" #include "gtkshortcutsshortcut.h"
#include "gtksizegroup.h" #include "gtksizegroup.h"
#include "gtkaccessible.h"
/** /**
* GtkShortcutsGroup: * GtkShortcutsGroup:
@ -333,6 +334,7 @@ gtk_shortcuts_group_class_init (GtkShortcutsGroupClass *klass)
g_object_class_install_properties (object_class, LAST_PROP, properties); g_object_class_install_properties (object_class, LAST_PROP, properties);
gtk_widget_class_set_css_name (widget_class, I_("shortcuts-group")); gtk_widget_class_set_css_name (widget_class, I_("shortcuts-group"));
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GROUP);
} }
static void static void
@ -346,6 +348,7 @@ gtk_shortcuts_group_init (GtkShortcutsGroup *self)
attrs = pango_attr_list_new (); attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD)); pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
self->title = g_object_new (GTK_TYPE_LABEL, self->title = g_object_new (GTK_TYPE_LABEL,
"accessible-role", GTK_ACCESSIBLE_ROLE_CAPTION,
"attributes", attrs, "attributes", attrs,
"visible", TRUE, "visible", TRUE,
"xalign", 0.0f, "xalign", 0.0f,
@ -353,4 +356,8 @@ gtk_shortcuts_group_init (GtkShortcutsGroup *self)
pango_attr_list_unref (attrs); pango_attr_list_unref (attrs);
gtk_box_append (GTK_BOX (self), GTK_WIDGET (self->title)); gtk_box_append (GTK_BOX (self), GTK_WIDGET (self->title));
gtk_accessible_update_relation (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_RELATION_LABELLED_BY, self->title, NULL,
-1);
} }

View File

@ -709,7 +709,7 @@ gtk_shortcuts_shortcut_class_init (GtkShortcutsShortcutClass *klass)
/* It is semantically a label, but the label role has such specific meaning in Orca /* It is semantically a label, but the label role has such specific meaning in Orca
* as to be unusable in this context. * as to be unusable in this context.
*/ */
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GENERIC); gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_LABEL);
} }
static void static void
@ -761,8 +761,13 @@ gtk_shortcuts_shortcut_init (GtkShortcutsShortcut *self)
gtk_widget_add_css_class (GTK_WIDGET (self->subtitle), "dim-label"); gtk_widget_add_css_class (GTK_WIDGET (self->subtitle), "dim-label");
gtk_box_append (GTK_BOX (self->title_box), GTK_WIDGET (self->subtitle)); gtk_box_append (GTK_BOX (self->title_box), GTK_WIDGET (self->subtitle));
#if 0
gtk_accessible_update_relation (GTK_ACCESSIBLE (self), gtk_accessible_update_relation (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_RELATION_LABELLED_BY, self->title, NULL, GTK_ACCESSIBLE_RELATION_LABELLED_BY, self->accelerator, self->title, NULL,
GTK_ACCESSIBLE_RELATION_DESCRIBED_BY, self->accelerator, NULL, -1);
#endif
gtk_accessible_update_property (GTK_ACCESSIBLE (self),
GTK_ACCESSIBLE_PROPERTY_DESCRIPTION, "",
-1); -1);
} }

View File

@ -821,6 +821,8 @@ gtk_shortcuts_window_class_init (GtkShortcutsWindowClass *klass)
g_type_ensure (GTK_TYPE_SHORTCUTS_GROUP); g_type_ensure (GTK_TYPE_SHORTCUTS_GROUP);
g_type_ensure (GTK_TYPE_SHORTCUTS_SHORTCUT); g_type_ensure (GTK_TYPE_SHORTCUTS_SHORTCUT);
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GENERIC);
} }
static void static void