Show updates-available banner in Installed view

This commit is contained in:
lashman
2026-02-28 01:48:50 +02:00
parent 68918af00a
commit 6a546396ed
2 changed files with 29 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ pub struct LibraryView {
list_button: gtk::ToggleButton, list_button: gtk::ToggleButton,
records: Rc<RefCell<Vec<AppImageRecord>>>, records: Rc<RefCell<Vec<AppImageRecord>>>,
search_empty_page: adw::StatusPage, search_empty_page: adw::StatusPage,
update_banner: adw::Banner,
// Batch selection // Batch selection
selection_mode: Rc<Cell<bool>>, selection_mode: Rc<Cell<bool>>,
selected_ids: Rc<RefCell<HashSet<i64>>>, selected_ids: Rc<RefCell<HashSet<i64>>>,
@@ -338,10 +339,19 @@ impl LibraryView {
delete_btn.set_action_name(Some("win.batch-delete")); delete_btn.set_action_name(Some("win.batch-delete"));
action_bar.pack_end(&delete_btn); action_bar.pack_end(&delete_btn);
// --- Updates-available banner ---
let update_banner = adw::Banner::builder()
.title(&i18n("Updates available"))
.button_label(&i18n("View Updates"))
.revealed(false)
.build();
update_banner.set_action_name(Some("win.show-updates"));
// --- Assemble toolbar view --- // --- Assemble toolbar view ---
let content_box = gtk::Box::builder() let content_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical) .orientation(gtk::Orientation::Vertical)
.build(); .build();
content_box.append(&update_banner);
content_box.append(&search_bar); content_box.append(&search_bar);
content_box.append(&stack); content_box.append(&stack);
content_box.append(&action_bar); content_box.append(&action_bar);
@@ -514,6 +524,7 @@ impl LibraryView {
list_button, list_button,
records, records,
search_empty_page, search_empty_page,
update_banner,
selection_mode, selection_mode,
selected_ids, selected_ids,
_action_bar: action_bar, _action_bar: action_bar,
@@ -751,6 +762,20 @@ impl LibraryView {
} }
} }
/// Update the "updates available" banner.
pub fn set_update_count(&self, count: i64) {
self.update_banner.set_revealed(count > 0);
if count > 0 {
let text = ni18n_f(
"{} update available",
"{} updates available",
count as u32,
&[("{}", &count.to_string())],
);
self.update_banner.set_title(&text);
}
}
/// Programmatically set the view mode by toggling the linked buttons. /// Programmatically set the view mode by toggling the linked buttons.
pub fn set_view_mode(&self, mode: ViewMode) { pub fn set_view_mode(&self, mode: ViewMode) {
match mode { match mode {

View File

@@ -1374,6 +1374,10 @@ impl DriftwoodWindow {
page.set_needs_attention(count > 0); page.set_needs_attention(count > 0);
} }
} }
// Also update the banner in the Installed view
if let Some(library_view) = self.imp().library_view.get() {
library_view.set_update_count(count);
}
} }
fn start_file_watcher(&self) { fn start_file_watcher(&self) {