Yoda/src/browser/main/mod.rs

49 lines
785 B
Rust
Raw Normal View History

2024-09-20 18:02:10 +03:00
mod tab;
mod widget;
2024-09-18 20:33:29 +03:00
2024-09-23 01:57:16 +03:00
use std::sync::Arc;
2024-09-22 02:00:54 +03:00
pub struct Main {
2024-09-23 15:56:09 +03:00
// Components
tab: Arc<tab::Tab>,
// Extras
widget: widget::Main,
2024-09-22 02:00:54 +03:00
}
impl Main {
// Construct
2024-09-23 01:57:16 +03:00
pub fn new() -> Arc<Main> {
// Init components
2024-09-22 22:23:44 +03:00
let tab = tab::Tab::new();
2024-09-23 15:56:09 +03:00
// Extras
2024-09-23 15:58:55 +03:00
let widget = widget::Main::new(tab.widget().notebook());
2024-09-23 15:56:09 +03:00
// Init struct
2024-09-23 15:56:09 +03:00
Arc::new(Self { tab, widget })
}
// Actions
2024-09-22 02:00:54 +03:00
pub fn tab_append(&self) {
self.tab.append(true);
}
2024-09-23 16:03:39 +03:00
pub fn tab_close(&self) {
self.tab.close();
}
pub fn tab_close_all(&self) {
self.tab.close();
}
2024-09-23 15:44:33 +03:00
pub fn tab_pin(&self) {
self.tab.pin();
}
// Getters
pub fn widget(&self) -> &widget::Main {
&self.widget
}
2024-09-20 18:02:10 +03:00
}