mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
use shared current widget id getter
This commit is contained in:
parent
572d5af387
commit
77e3c8aec3
2 changed files with 57 additions and 85 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use gtk::Notebook;
|
||||
use gtk::{glib::GString, prelude::WidgetExt, Notebook};
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Notebook,
|
||||
|
|
@ -12,7 +12,31 @@ impl Widget {
|
|||
Self { gobject }
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn close(&self) {
|
||||
self.gobject.remove_page(self.gobject().current_page());
|
||||
}
|
||||
|
||||
pub fn close_all(&self) {
|
||||
// @TODO skip pinned or make confirmation alert (GTK>=4.10)
|
||||
while let Some(page_number) = self.gobject.current_page() {
|
||||
self.gobject.remove_page(Some(page_number));
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn current_name(&self) -> Option<GString> {
|
||||
let page_number = self.gobject.current_page()?;
|
||||
let nth_page = self.gobject.nth_page(Some(page_number))?;
|
||||
|
||||
let widget_name = nth_page.widget_name();
|
||||
if !widget_name.is_empty() {
|
||||
Some(widget_name)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gobject(&self) -> &Notebook {
|
||||
&self.gobject
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue