diff --git a/src/ui/library_view.rs b/src/ui/library_view.rs index 51b84f3..70095f0 100644 --- a/src/ui/library_view.rs +++ b/src/ui/library_view.rs @@ -45,6 +45,7 @@ pub struct LibraryView { list_button: gtk::ToggleButton, records: Rc>>, search_empty_page: adw::StatusPage, + update_banner: adw::Banner, // Batch selection selection_mode: Rc>, selected_ids: Rc>>, @@ -338,10 +339,19 @@ impl LibraryView { delete_btn.set_action_name(Some("win.batch-delete")); 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 --- let content_box = gtk::Box::builder() .orientation(gtk::Orientation::Vertical) .build(); + content_box.append(&update_banner); content_box.append(&search_bar); content_box.append(&stack); content_box.append(&action_bar); @@ -514,6 +524,7 @@ impl LibraryView { list_button, records, search_empty_page, + update_banner, selection_mode, selected_ids, _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. pub fn set_view_mode(&self, mode: ViewMode) { match mode { diff --git a/src/window.rs b/src/window.rs index 6cd6713..558e30d 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1374,6 +1374,10 @@ impl DriftwoodWindow { 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) {