refactor(gui): extract AppContext for shared page handles

KeysPage::new now takes a single AppContext that owns parent_window,
toast_overlay, and the shared daemon Rc<RefCell<Option<Daemon>>>. Phases
9, 10, 11, and 12 GUI tab will all consume this struct.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
michael
2026-04-27 10:42:11 -07:00
parent d20643cde5
commit a927d96630
3 changed files with 40 additions and 15 deletions

27
gui/src/app_context.rs Normal file
View File

@@ -0,0 +1,27 @@
//! Shared per-window handles passed to every page constructor.
//!
//! `daemon` is a `RefCell<Option<...>>` because the connect-on-startup attempt
//! may fail (pages render their disconnected banner); a successful Retry
//! repopulates this same cell, and every page sees the new value via the Rc
//! clone chain.
use crate::bus::Daemon;
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Clone)]
pub(crate) struct AppContext {
pub parent_window: gtk::Window,
pub toast_overlay: adw::ToastOverlay,
pub daemon: Rc<RefCell<Option<Daemon>>>,
}
impl AppContext {
pub fn new(parent_window: gtk::Window, toast_overlay: adw::ToastOverlay) -> Self {
Self {
parent_window,
toast_overlay,
daemon: Rc::new(RefCell::new(None)),
}
}
}