Yoda/src/browser/main/mod.rs
2024-09-26 01:14:33 +03:00

69 lines
1.2 KiB
Rust

mod tab;
use std::sync::Arc;
use tab::Tab;
use gtk::{glib::GString, prelude::BoxExt, Box, Orientation};
pub struct Main {
tab: Arc<Tab>,
widget: Box,
}
impl Main {
// Construct
pub fn new() -> Self {
// Init components
let tab = Arc::new(Tab::new());
tab.activate(tab.clone());
// Extras
let widget = Box::builder().orientation(Orientation::Vertical).build();
widget.append(tab.widget());
// Init struct
Self { tab, widget }
}
// Actions
pub fn tab_append(&self) {
self.tab.append(true);
}
pub fn tab_page_reload(&self) {
self.tab.page_reload();
}
pub fn tab_close(&self) {
self.tab.close();
}
pub fn tab_close_all(&self) {
self.tab.close_all();
}
pub fn tab_pin(&self) {
self.tab.pin();
}
pub fn update(&self) {
self.tab.update();
}
// Getters
pub fn tab_page_title(&self) -> GString {
self.tab.page_title()
}
pub fn tab_page_description(&self) -> GString {
self.tab.page_description()
}
pub fn widget(&self) -> &Box {
&self.widget
}
}