diff --git a/src/preferences.py b/src/preferences.py
index 9adf84b..e801fcd 100644
--- a/src/preferences.py
+++ b/src/preferences.py
@@ -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 = ''
+ format_end = "\n"
+
popover = Gtk.Popover(
+ focusable=True,
child=(
- label := Gtk.Label(
- label=(
- ''
- + _("Installation Not Found")
- + "\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")