Yoda/src/app/browser/window/tab/item/action.rs

54 lines
1.1 KiB
Rust

mod history;
mod home;
mod ident;
mod load;
mod reload;
use gtk::gio::SimpleAction;
use history::History;
use home::Home;
use ident::Ident;
use load::Load;
use reload::Reload;
use std::rc::Rc;
/// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions
pub struct Action {
pub history: Rc<History>,
pub home: SimpleAction,
pub ident: Rc<Ident>,
pub load: Rc<Load>,
pub reload: SimpleAction,
}
impl Default for Action {
fn default() -> Self {
Self::new()
}
}
impl Action {
// Constructors
/// Create new `Self`
pub fn new() -> Self {
let ident = Rc::new(Ident::new());
let load = Rc::new(Load::new());
let home = SimpleAction::home();
let reload = SimpleAction::reload();
let history = Rc::new(History::build({
let load = load.clone();
move |request| load.activate(Some(&request), false)
}));
Self {
history,
reload,
home,
ident,
load,
}
}
}