Add WCAG tooltips for technical terms on dashboard

This commit is contained in:
lashman
2026-02-27 10:03:16 +02:00
parent 7852e7ab4b
commit 66fc582cce

View File

@@ -1,11 +1,11 @@
use adw::prelude::*; use adw::prelude::*;
use gtk::gio;
use std::rc::Rc; use std::rc::Rc;
use crate::core::database::Database; use crate::core::database::Database;
use crate::core::duplicates; use crate::core::duplicates;
use crate::core::fuse; use crate::core::fuse;
use crate::core::wayland; use crate::core::wayland;
use crate::i18n::ni18n;
use super::widgets; use super::widgets;
/// Build the dashboard page showing system health and statistics. /// Build the dashboard page showing system health and statistics.
@@ -25,19 +25,22 @@ pub fn build_dashboard_page(db: &Rc<Database>) -> adw::NavigationPage {
.build(); .build();
// Section 1: System Status // Section 1: System Status
content.append(&build_system_status_section()); content.append(&build_system_status_group());
// Section 2: Library Statistics // Section 2: Library Statistics
content.append(&build_library_stats_section(db)); content.append(&build_library_stats_group(db));
// Section 3: Updates Summary // Section 3: Updates Summary (actionable)
content.append(&build_updates_summary_section(db)); content.append(&build_updates_summary_group(db));
// Section 4: Duplicates Summary // Section 4: Duplicates Summary (actionable)
content.append(&build_duplicates_summary_section(db)); content.append(&build_duplicates_summary_group(db));
// Section 5: Disk Usage // Section 5: Disk Usage (actionable)
content.append(&build_disk_usage_section(db)); content.append(&build_disk_usage_group(db));
// Section 6: Quick Actions
content.append(&build_quick_actions_group());
clamp.set_child(Some(&content)); clamp.set_child(Some(&content));
let scrolled = gtk::ScrolledWindow::builder() let scrolled = gtk::ScrolledWindow::builder()
@@ -57,23 +60,12 @@ pub fn build_dashboard_page(db: &Rc<Database>) -> adw::NavigationPage {
.build() .build()
} }
fn build_system_status_section() -> gtk::Box { fn build_system_status_group() -> adw::PreferencesGroup {
let section = gtk::Box::builder() let group = adw::PreferencesGroup::builder()
.orientation(gtk::Orientation::Vertical) .title("System Status")
.spacing(8) .description("Display server, FUSE, and compatibility information")
.build(); .build();
let heading = gtk::Label::builder()
.label("System Status")
.css_classes(["heading"])
.halign(gtk::Align::Start)
.build();
section.append(&heading);
let list_box = gtk::ListBox::new();
list_box.add_css_class("boxed-list");
list_box.set_selection_mode(gtk::SelectionMode::None);
// Session type // Session type
let session = wayland::detect_session_type(); let session = wayland::detect_session_type();
let session_row = adw::ActionRow::builder() let session_row = adw::ActionRow::builder()
@@ -90,7 +82,7 @@ fn build_system_status_section() -> gtk::Box {
); );
session_badge.set_valign(gtk::Align::Center); session_badge.set_valign(gtk::Align::Center);
session_row.add_suffix(&session_badge); session_row.add_suffix(&session_badge);
list_box.append(&session_row); group.add(&session_row);
// Desktop environment // Desktop environment
let de = wayland::detect_desktop_environment(); let de = wayland::detect_desktop_environment();
@@ -98,13 +90,14 @@ fn build_system_status_section() -> gtk::Box {
.title("Desktop environment") .title("Desktop environment")
.subtitle(&de) .subtitle(&de)
.build(); .build();
list_box.append(&de_row); group.add(&de_row);
// FUSE status // FUSE status
let fuse_info = fuse::detect_system_fuse(); let fuse_info = fuse::detect_system_fuse();
let fuse_row = adw::ActionRow::builder() let fuse_row = adw::ActionRow::builder()
.title("FUSE") .title("FUSE")
.subtitle(fuse_description(&fuse_info)) .subtitle(&fuse_description(&fuse_info))
.tooltip_text("Filesystem in Userspace - required for mounting AppImages")
.build(); .build();
let fuse_badge = widgets::status_badge( let fuse_badge = widgets::status_badge(
fuse_info.status.label(), fuse_info.status.label(),
@@ -112,7 +105,7 @@ fn build_system_status_section() -> gtk::Box {
); );
fuse_badge.set_valign(gtk::Align::Center); fuse_badge.set_valign(gtk::Align::Center);
fuse_row.add_suffix(&fuse_badge); fuse_row.add_suffix(&fuse_badge);
list_box.append(&fuse_row); group.add(&fuse_row);
// Install hint if FUSE not functional // Install hint if FUSE not functional
if let Some(ref hint) = fuse_info.install_hint { if let Some(ref hint) = fuse_info.install_hint {
@@ -120,9 +113,9 @@ fn build_system_status_section() -> gtk::Box {
.title("Fix FUSE") .title("Fix FUSE")
.subtitle(hint) .subtitle(hint)
.subtitle_selectable(true) .subtitle_selectable(true)
.css_classes(["monospace"])
.build(); .build();
list_box.append(&hint_row); hint_row.add_css_class("monospace");
group.add(&hint_row);
} }
// XWayland // XWayland
@@ -130,6 +123,7 @@ fn build_system_status_section() -> gtk::Box {
let xwayland_row = adw::ActionRow::builder() let xwayland_row = adw::ActionRow::builder()
.title("XWayland") .title("XWayland")
.subtitle(if has_xwayland { "Running" } else { "Not detected" }) .subtitle(if has_xwayland { "Running" } else { "Not detected" })
.tooltip_text("X11 compatibility layer for Wayland desktops")
.build(); .build();
let xwayland_badge = widgets::status_badge( let xwayland_badge = widgets::status_badge(
if has_xwayland { "Available" } else { "Unavailable" }, if has_xwayland { "Available" } else { "Unavailable" },
@@ -137,7 +131,7 @@ fn build_system_status_section() -> gtk::Box {
); );
xwayland_badge.set_valign(gtk::Align::Center); xwayland_badge.set_valign(gtk::Align::Center);
xwayland_row.add_suffix(&xwayland_badge); xwayland_row.add_suffix(&xwayland_badge);
list_box.append(&xwayland_row); group.add(&xwayland_row);
// AppImageLauncher conflict check // AppImageLauncher conflict check
if let Some(version) = fuse::detect_appimagelauncher() { if let Some(version) = fuse::detect_appimagelauncher() {
@@ -151,11 +145,10 @@ fn build_system_status_section() -> gtk::Box {
let ail_badge = widgets::status_badge("Conflict", "warning"); let ail_badge = widgets::status_badge("Conflict", "warning");
ail_badge.set_valign(gtk::Align::Center); ail_badge.set_valign(gtk::Align::Center);
ail_row.add_suffix(&ail_badge); ail_row.add_suffix(&ail_badge);
list_box.append(&ail_row); group.add(&ail_row);
} }
section.append(&list_box); group
section
} }
fn fuse_description(info: &fuse::FuseSystemInfo) -> String { fn fuse_description(info: &fuse::FuseSystemInfo) -> String {
@@ -179,23 +172,12 @@ fn fuse_description(info: &fuse::FuseSystemInfo) -> String {
} }
} }
fn build_library_stats_section(db: &Rc<Database>) -> gtk::Box { fn build_library_stats_group(db: &Rc<Database>) -> adw::PreferencesGroup {
let section = gtk::Box::builder() let group = adw::PreferencesGroup::builder()
.orientation(gtk::Orientation::Vertical) .title("Library")
.spacing(8) .description("Overview of your AppImage collection")
.build(); .build();
let heading = gtk::Label::builder()
.label("Library")
.css_classes(["heading"])
.halign(gtk::Align::Start)
.build();
section.append(&heading);
let list_box = gtk::ListBox::new();
list_box.add_css_class("boxed-list");
list_box.set_selection_mode(gtk::SelectionMode::None);
let records = db.get_all_appimages().unwrap_or_default(); let records = db.get_all_appimages().unwrap_or_default();
let total = records.len(); let total = records.len();
@@ -203,16 +185,21 @@ fn build_library_stats_section(db: &Rc<Database>) -> gtk::Box {
let executable = records.iter().filter(|r| r.is_executable).count(); let executable = records.iter().filter(|r| r.is_executable).count();
let total_row = adw::ActionRow::builder() let total_row = adw::ActionRow::builder()
.title("Total AppImages") .title(&ni18n("AppImage", "AppImages", total as u32))
.subtitle(&total.to_string()) .subtitle(&total.to_string())
.activatable(true)
.build(); .build();
list_box.append(&total_row); let total_arrow = gtk::Image::from_icon_name("go-next-symbolic");
total_arrow.set_valign(gtk::Align::Center);
total_row.add_suffix(&total_arrow);
total_row.set_action_name(Some("navigation.pop"));
group.add(&total_row);
let integrated_row = adw::ActionRow::builder() let integrated_row = adw::ActionRow::builder()
.title("Integrated") .title("Integrated")
.subtitle(&format!("{} of {}", integrated, total)) .subtitle(&format!("{} of {}", integrated, total))
.build(); .build();
list_box.append(&integrated_row); group.add(&integrated_row);
let exec_row = adw::ActionRow::builder() let exec_row = adw::ActionRow::builder()
.title("Executable") .title("Executable")
@@ -226,29 +213,17 @@ fn build_library_stats_section(db: &Rc<Database>) -> gtk::Box {
badge.set_valign(gtk::Align::Center); badge.set_valign(gtk::Align::Center);
exec_row.add_suffix(&badge); exec_row.add_suffix(&badge);
} }
list_box.append(&exec_row); group.add(&exec_row);
section.append(&list_box); group
section
} }
fn build_updates_summary_section(db: &Rc<Database>) -> gtk::Box { fn build_updates_summary_group(db: &Rc<Database>) -> adw::PreferencesGroup {
let section = gtk::Box::builder() let group = adw::PreferencesGroup::builder()
.orientation(gtk::Orientation::Vertical) .title("Updates")
.spacing(8) .description("AppImage update availability")
.build(); .build();
let heading = gtk::Label::builder()
.label("Updates")
.css_classes(["heading"])
.halign(gtk::Align::Start)
.build();
section.append(&heading);
let list_box = gtk::ListBox::new();
list_box.add_css_class("boxed-list");
list_box.set_selection_mode(gtk::SelectionMode::None);
let records = db.get_all_appimages().unwrap_or_default(); let records = db.get_all_appimages().unwrap_or_default();
let with_update_info = records let with_update_info = records
@@ -270,40 +245,34 @@ fn build_updates_summary_section(db: &Rc<Database>) -> gtk::Box {
.title("With update info") .title("With update info")
.subtitle(&format!("{} of {}", with_update_info, records.len())) .subtitle(&format!("{} of {}", with_update_info, records.len()))
.build(); .build();
list_box.append(&info_row); group.add(&info_row);
// Actionable updates row -> triggers check-updates
let updates_row = adw::ActionRow::builder() let updates_row = adw::ActionRow::builder()
.title("Updates available") .title("Updates available")
.subtitle(&with_updates.to_string()) .subtitle(&with_updates.to_string())
.activatable(true)
.build(); .build();
updates_row.set_action_name(Some("win.check-updates"));
if with_updates > 0 { if with_updates > 0 {
let badge = widgets::status_badge(&format!("{} updates", with_updates), "info"); let badge = widgets::status_badge(&format!("{} updates", with_updates), "info");
badge.set_valign(gtk::Align::Center); badge.set_valign(gtk::Align::Center);
updates_row.add_suffix(&badge); updates_row.add_suffix(&badge);
} }
list_box.append(&updates_row); let updates_arrow = gtk::Image::from_icon_name("go-next-symbolic");
updates_arrow.set_valign(gtk::Align::Center);
updates_row.add_suffix(&updates_arrow);
group.add(&updates_row);
section.append(&list_box); group
section
} }
fn build_duplicates_summary_section(db: &Rc<Database>) -> gtk::Box { fn build_duplicates_summary_group(db: &Rc<Database>) -> adw::PreferencesGroup {
let section = gtk::Box::builder() let group = adw::PreferencesGroup::builder()
.orientation(gtk::Orientation::Vertical) .title("Duplicates")
.spacing(8) .description("Duplicate and multi-version detection")
.build(); .build();
let heading = gtk::Label::builder()
.label("Duplicates")
.css_classes(["heading"])
.halign(gtk::Align::Start)
.build();
section.append(&heading);
let list_box = gtk::ListBox::new();
list_box.add_css_class("boxed-list");
list_box.set_selection_mode(gtk::SelectionMode::None);
let groups = duplicates::detect_duplicates(db); let groups = duplicates::detect_duplicates(db);
let summary = duplicates::summarize_duplicates(&groups); let summary = duplicates::summarize_duplicates(&groups);
@@ -315,13 +284,19 @@ fn build_duplicates_summary_section(db: &Rc<Database>) -> gtk::Box {
let badge = widgets::status_badge("Clean", "success"); let badge = widgets::status_badge("Clean", "success");
badge.set_valign(gtk::Align::Center); badge.set_valign(gtk::Align::Center);
row.add_suffix(&badge); row.add_suffix(&badge);
list_box.append(&row); group.add(&row);
} else { } else {
// Actionable row -> opens duplicate dialog
let groups_row = adw::ActionRow::builder() let groups_row = adw::ActionRow::builder()
.title("Duplicate groups") .title("Duplicate groups")
.subtitle(&summary.total_groups.to_string()) .subtitle(&summary.total_groups.to_string())
.activatable(true)
.build(); .build();
list_box.append(&groups_row); groups_row.set_action_name(Some("win.find-duplicates"));
let dupes_arrow = gtk::Image::from_icon_name("go-next-symbolic");
dupes_arrow.set_valign(gtk::Align::Center);
groups_row.add_suffix(&dupes_arrow);
group.add(&groups_row);
if summary.total_potential_savings > 0 { if summary.total_potential_savings > 0 {
let savings_row = adw::ActionRow::builder() let savings_row = adw::ActionRow::builder()
@@ -331,39 +306,33 @@ fn build_duplicates_summary_section(db: &Rc<Database>) -> gtk::Box {
let badge = widgets::status_badge("Reclaimable", "warning"); let badge = widgets::status_badge("Reclaimable", "warning");
badge.set_valign(gtk::Align::Center); badge.set_valign(gtk::Align::Center);
savings_row.add_suffix(&badge); savings_row.add_suffix(&badge);
list_box.append(&savings_row); group.add(&savings_row);
} }
} }
section.append(&list_box); group
section
} }
fn build_disk_usage_section(db: &Rc<Database>) -> gtk::Box { fn build_disk_usage_group(db: &Rc<Database>) -> adw::PreferencesGroup {
let section = gtk::Box::builder() let group = adw::PreferencesGroup::builder()
.orientation(gtk::Orientation::Vertical) .title("Disk Usage")
.spacing(8) .description("Storage used by your AppImages")
.build(); .build();
let heading = gtk::Label::builder()
.label("Disk Usage")
.css_classes(["heading"])
.halign(gtk::Align::Start)
.build();
section.append(&heading);
let list_box = gtk::ListBox::new();
list_box.add_css_class("boxed-list");
list_box.set_selection_mode(gtk::SelectionMode::None);
let records = db.get_all_appimages().unwrap_or_default(); let records = db.get_all_appimages().unwrap_or_default();
let total_bytes: i64 = records.iter().map(|r| r.size_bytes).sum(); let total_bytes: i64 = records.iter().map(|r| r.size_bytes).sum();
// Actionable total row -> opens cleanup wizard
let total_row = adw::ActionRow::builder() let total_row = adw::ActionRow::builder()
.title("Total disk usage") .title("Total disk usage")
.subtitle(&widgets::format_size(total_bytes)) .subtitle(&widgets::format_size(total_bytes))
.activatable(true)
.build(); .build();
list_box.append(&total_row); total_row.set_action_name(Some("win.cleanup"));
let disk_arrow = gtk::Image::from_icon_name("go-next-symbolic");
disk_arrow.set_valign(gtk::Align::Center);
total_row.add_suffix(&disk_arrow);
group.add(&total_row);
// Largest AppImages // Largest AppImages
let mut sorted = records.clone(); let mut sorted = records.clone();
@@ -375,9 +344,64 @@ fn build_disk_usage_section(db: &Rc<Database>) -> gtk::Box {
.title(name) .title(name)
.subtitle(&widgets::format_size(record.size_bytes)) .subtitle(&widgets::format_size(record.size_bytes))
.build(); .build();
list_box.append(&row); group.add(&row);
} }
section.append(&list_box); group
section }
fn build_quick_actions_group() -> adw::PreferencesGroup {
let group = adw::PreferencesGroup::builder()
.title("Quick Actions")
.build();
let button_box = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal)
.spacing(12)
.halign(gtk::Align::Center)
.margin_top(6)
.margin_bottom(6)
.build();
let scan_btn = gtk::Button::builder()
.label("Scan")
.tooltip_text("Scan for AppImages")
.build();
scan_btn.add_css_class("pill");
scan_btn.add_css_class("suggested-action");
scan_btn.set_action_name(Some("win.scan"));
scan_btn.update_property(&[
gtk::accessible::Property::Label("Scan for AppImages"),
]);
let updates_btn = gtk::Button::builder()
.label("Check Updates")
.tooltip_text("Check all AppImages for updates")
.build();
updates_btn.add_css_class("pill");
updates_btn.set_action_name(Some("win.check-updates"));
updates_btn.update_property(&[
gtk::accessible::Property::Label("Check for updates"),
]);
let clean_btn = gtk::Button::builder()
.label("Clean Orphans")
.tooltip_text("Remove orphaned desktop entries")
.build();
clean_btn.add_css_class("pill");
clean_btn.set_action_name(Some("win.clean-orphans"));
clean_btn.update_property(&[
gtk::accessible::Property::Label("Clean orphaned desktop entries"),
]);
button_box.append(&scan_btn);
button_box.append(&updates_btn);
button_box.append(&clean_btn);
// Use an ActionRow to contain the buttons for proper group styling
let row = adw::ActionRow::new();
row.set_child(Some(&button_box));
group.add(&row);
group
} }