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:
|
def resolve_locations(self, source: Source) -> None:
|
||||||
"""Resolve locations and add a warning if location cannot be found"""
|
"""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():
|
for location_name, location in source.locations._asdict().items():
|
||||||
action_row = getattr(
|
action_row = getattr(
|
||||||
self, f"{source.source_id}_{location_name}_action_row", None
|
self, f"{source.source_id}_{location_name}_action_row", None
|
||||||
@@ -290,15 +287,16 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
|||||||
location.resolve()
|
location.resolve()
|
||||||
|
|
||||||
except UnresolvableLocationError:
|
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(
|
popover = Gtk.Popover(
|
||||||
|
focusable=True,
|
||||||
child=(
|
child=(
|
||||||
label := Gtk.Label(
|
Gtk.Label(
|
||||||
label=(
|
label=format_start + title + format_end + description,
|
||||||
'<span rise="12pt"><b><big>'
|
|
||||||
+ _("Installation Not Found")
|
|
||||||
+ "</big></b></span>\n"
|
|
||||||
+ _("Select a valid directory.")
|
|
||||||
),
|
|
||||||
use_markup=True,
|
use_markup=True,
|
||||||
wrap=True,
|
wrap=True,
|
||||||
max_width_chars=50,
|
max_width_chars=50,
|
||||||
@@ -309,17 +307,24 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
|||||||
margin_bottom=9,
|
margin_bottom=9,
|
||||||
margin_start=12,
|
margin_start=12,
|
||||||
margin_end=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(
|
menu_button = Gtk.MenuButton(
|
||||||
icon_name="dialog-warning-symbolic",
|
icon_name="dialog-warning-symbolic",
|
||||||
valign=Gtk.Align.CENTER,
|
valign=Gtk.Align.CENTER,
|
||||||
popover=popover,
|
popover=popover,
|
||||||
|
tooltip_text=_("Warning"),
|
||||||
)
|
)
|
||||||
menu_button.add_css_class("warning")
|
menu_button.add_css_class("warning")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user