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>
28 lines
798 B
Rust
28 lines
798 B
Rust
//! 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)),
|
|
}
|
|
}
|
|
}
|