Proper a11y for all popovers
This commit is contained in:
@@ -276,9 +276,6 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
||||
def resolve_locations(self, source: Source) -> None:
|
||||
"""Resolve locations and add a warning if location cannot be found"""
|
||||
|
||||
def clear_warning_selection(_widget: Any, label: Gtk.Label) -> None:
|
||||
label.select_region(-1, -1)
|
||||
|
||||
for location_name, location in source.locations._asdict().items():
|
||||
action_row = getattr(
|
||||
self, f"{source.source_id}_{location_name}_action_row", None
|
||||
@@ -290,15 +287,16 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
||||
location.resolve()
|
||||
|
||||
except UnresolvableLocationError:
|
||||
title = _("Installation Not Found")
|
||||
description = _("Select a valid directory.")
|
||||
format_start = '<span rise="12pt"><b><big>'
|
||||
format_end = "</big></b></span>\n"
|
||||
|
||||
popover = Gtk.Popover(
|
||||
focusable=True,
|
||||
child=(
|
||||
label := Gtk.Label(
|
||||
label=(
|
||||
'<span rise="12pt"><b><big>'
|
||||
+ _("Installation Not Found")
|
||||
+ "</big></b></span>\n"
|
||||
+ _("Select a valid directory.")
|
||||
),
|
||||
Gtk.Label(
|
||||
label=format_start + title + format_end + description,
|
||||
use_markup=True,
|
||||
wrap=True,
|
||||
max_width_chars=50,
|
||||
@@ -309,17 +307,24 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
||||
margin_bottom=9,
|
||||
margin_start=12,
|
||||
margin_end=12,
|
||||
selectable=True,
|
||||
)
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
popover.connect("show", clear_warning_selection, label)
|
||||
popover.update_property(
|
||||
(Gtk.AccessibleProperty.LABEL,), (title + description,)
|
||||
)
|
||||
|
||||
def set_a11y_label(widget: Gtk.Popover) -> None:
|
||||
self.set_focus(widget)
|
||||
|
||||
popover.connect("show", set_a11y_label)
|
||||
|
||||
menu_button = Gtk.MenuButton(
|
||||
icon_name="dialog-warning-symbolic",
|
||||
valign=Gtk.Align.CENTER,
|
||||
popover=popover,
|
||||
tooltip_text=_("Warning"),
|
||||
)
|
||||
menu_button.add_css_class("warning")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user