54 lines
938 B
Rust
Raw Normal View History

2024-09-20 18:02:10 +03:00
mod label;
mod page;
2024-09-18 22:38:18 +03:00
2024-09-23 18:51:48 +03:00
use gtk::Notebook;
use label::Label;
use page::Page;
2024-09-23 15:56:09 +03:00
2024-09-22 02:00:54 +03:00
pub struct Tab {
2024-09-23 18:51:48 +03:00
widget: Notebook,
2024-09-18 22:38:18 +03:00
}
2024-09-22 02:00:54 +03:00
impl Tab {
2024-09-22 22:23:44 +03:00
// Construct
2024-09-23 18:51:48 +03:00
pub fn new() -> Tab {
Self {
widget: Notebook::builder().scrollable(true).build(),
}
2024-09-18 22:47:53 +03:00
}
2024-09-22 02:00:54 +03:00
2024-09-22 22:23:44 +03:00
// Actions
2024-09-23 15:44:33 +03:00
pub fn append(&self, is_active: bool) -> u32 {
2024-09-23 18:51:48 +03:00
let label = Label::new(false);
let page = Page::new();
let page_number = self.widget.append_page(page.widget(), Some(label.widget()));
self.widget.set_tab_reorderable(page.widget(), true);
if is_active {
self.widget.set_current_page(Some(page_number));
}
page_number
2024-09-22 22:23:44 +03:00
}
2024-09-18 22:47:53 +03:00
2024-09-23 16:03:39 +03:00
pub fn close(&self) {
todo!()
}
2024-09-23 18:51:48 +03:00
/* @TODO
2024-09-23 16:03:39 +03:00
pub fn close_all(&self) {
todo!()
2024-09-23 18:51:48 +03:00
}*/
2024-09-23 16:03:39 +03:00
2024-09-23 15:44:33 +03:00
pub fn pin(&self) -> bool {
2024-09-23 16:03:39 +03:00
todo!()
2024-09-23 15:44:33 +03:00
}
2024-09-22 22:23:44 +03:00
// Getters
2024-09-23 18:51:48 +03:00
pub fn widget(&self) -> &Notebook {
2024-09-22 22:23:44 +03:00
&self.widget
}
2024-09-20 18:02:10 +03:00
}