2024-09-20 18:02:10 +03:00
|
|
|
mod label;
|
|
|
|
mod page;
|
2024-09-18 22:38:18 +03:00
|
|
|
|
2024-09-22 02:00:54 +03:00
|
|
|
use std::sync::Arc;
|
2024-09-19 00:46:58 +03:00
|
|
|
|
2024-09-22 02:00:54 +03:00
|
|
|
use gtk::Notebook;
|
|
|
|
pub struct Tab {
|
|
|
|
pub widget: Arc<gtk::Notebook>,
|
2024-09-18 22:38:18 +03:00
|
|
|
}
|
|
|
|
|
2024-09-22 02:00:54 +03:00
|
|
|
impl Tab {
|
|
|
|
pub fn append(&self, current: bool) -> u32 {
|
|
|
|
let page = page::new();
|
2024-09-18 22:47:53 +03:00
|
|
|
|
2024-09-22 02:00:54 +03:00
|
|
|
let page_number = self.widget.append_page(&page, Some(&label::new()));
|
2024-09-20 18:02:10 +03:00
|
|
|
|
2024-09-22 02:00:54 +03:00
|
|
|
self.widget.set_tab_reorderable(&page, true);
|
2024-09-20 18:02:10 +03:00
|
|
|
|
2024-09-22 02:00:54 +03:00
|
|
|
if current {
|
|
|
|
self.widget.set_current_page(Some(page_number));
|
|
|
|
}
|
|
|
|
|
|
|
|
page_number
|
2024-09-18 22:47:53 +03:00
|
|
|
}
|
2024-09-22 02:00:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new() -> Tab {
|
|
|
|
let widget = Arc::new(Notebook::builder().scrollable(true).build());
|
2024-09-18 22:47:53 +03:00
|
|
|
|
2024-09-22 02:00:54 +03:00
|
|
|
Tab { widget }
|
2024-09-20 18:02:10 +03:00
|
|
|
}
|