collection-details: Add a11y labels for icons
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
# SPDX-FileCopyrightText: Copyright 2025 Jamie Gravendeel
|
# SPDX-FileCopyrightText: Copyright 2025 Jamie Gravendeel
|
||||||
|
|
||||||
from itertools import product
|
from itertools import product
|
||||||
from typing import Any, TypeVar, cast
|
from typing import Any, NamedTuple, TypeVar, cast
|
||||||
|
|
||||||
from gi.repository import Adw, Gio, GObject, Gtk
|
from gi.repository import Adw, Gio, GObject, Gtk
|
||||||
|
|
||||||
@@ -10,28 +10,34 @@ from cartridges import collections
|
|||||||
from cartridges.collections import Collection
|
from cartridges.collections import Collection
|
||||||
from cartridges.config import PREFIX
|
from cartridges.config import PREFIX
|
||||||
|
|
||||||
ICONS = (
|
|
||||||
"collection",
|
class _Icon(NamedTuple):
|
||||||
"star",
|
name: str
|
||||||
"heart",
|
a11y_label: str
|
||||||
"music",
|
|
||||||
"people",
|
|
||||||
"skull",
|
_ICONS = (
|
||||||
"private",
|
_Icon("collection", "📚"),
|
||||||
"globe",
|
_Icon("star", "⭐"),
|
||||||
"map",
|
_Icon("heart", "❤️"),
|
||||||
"city",
|
_Icon("music", "🎵"),
|
||||||
"car",
|
_Icon("people", "🧑"),
|
||||||
"horse",
|
_Icon("skull", "💀"),
|
||||||
"sprout",
|
_Icon("private", "🕵️"),
|
||||||
"step-over",
|
_Icon("globe", "🌐"),
|
||||||
"gamepad",
|
_Icon("map", "🗺"),
|
||||||
"ball",
|
_Icon("city", "🏙️"),
|
||||||
"puzzle",
|
_Icon("car", "🚗"),
|
||||||
"flashlight",
|
_Icon("horse", "🐎"),
|
||||||
"knife",
|
_Icon("sprout", "🌱"),
|
||||||
"gun",
|
_Icon("step-over", "🪜"),
|
||||||
"fist",
|
_Icon("gamepad", "🎮"),
|
||||||
|
_Icon("ball", "⚽"),
|
||||||
|
_Icon("puzzle", "🧩"),
|
||||||
|
_Icon("flashlight", "🔦"),
|
||||||
|
_Icon("knife", "🔪"),
|
||||||
|
_Icon("gun", "🔫"),
|
||||||
|
_Icon("fist", "✊"),
|
||||||
)
|
)
|
||||||
|
|
||||||
_T = TypeVar("_T")
|
_T = TypeVar("_T")
|
||||||
@@ -79,13 +85,17 @@ class CollectionDetails(Adw.Dialog):
|
|||||||
|
|
||||||
group_button = None
|
group_button = None
|
||||||
for index, (row, col) in enumerate(product(range(3), range(7))):
|
for index, (row, col) in enumerate(product(range(3), range(7))):
|
||||||
icon = ICONS[index]
|
icon = _ICONS[index].name
|
||||||
|
|
||||||
button = Gtk.ToggleButton(
|
button = Gtk.ToggleButton(
|
||||||
icon_name=f"{icon}-symbolic",
|
icon_name=f"{icon}-symbolic",
|
||||||
hexpand=True,
|
hexpand=True,
|
||||||
halign=Gtk.Align.CENTER,
|
halign=Gtk.Align.CENTER,
|
||||||
)
|
)
|
||||||
|
button.update_property(
|
||||||
|
(Gtk.AccessibleProperty.LABEL,), (_ICONS[index].a11y_label,)
|
||||||
|
)
|
||||||
|
|
||||||
button.add_css_class("circular")
|
button.add_css_class("circular")
|
||||||
button.add_css_class("flat")
|
button.add_css_class("flat")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user