feat: ClosableTabImplNotebook::append_closable_tab()
parent
2ec23a35d5
commit
2b2e63d809
|
@ -10,6 +10,15 @@ pub trait ClosableTabImplementedNotebook {
|
|||
child: &T,
|
||||
tab_label: Option<&U>,
|
||||
) -> u32;
|
||||
fn append_closable_page<
|
||||
T: IsA<Widget>,
|
||||
U: IsA<Widget>
|
||||
>(
|
||||
&self,
|
||||
child: &T,
|
||||
tab_label: Option<&U>,
|
||||
) -> u32;
|
||||
|
||||
fn create_closable_tab<
|
||||
U: IsA<Widget>,
|
||||
|
||||
|
@ -52,4 +61,23 @@ impl ClosableTabImplementedNotebook for gtk::Notebook {
|
|||
page
|
||||
|
||||
}
|
||||
|
||||
fn append_closable_page<
|
||||
T: IsA<Widget>,
|
||||
U: IsA<Widget>
|
||||
>(
|
||||
&self,
|
||||
child: &T,
|
||||
tab_label: Option<&U>,
|
||||
) -> u32 {
|
||||
let (tab, button) = &Self::create_closable_tab(tab_label);
|
||||
let page = self.append_page(child, Some(tab));
|
||||
|
||||
button.connect_clicked(glib::clone!(@weak self as notebook =>
|
||||
move |_| {
|
||||
notebook.remove_page(Some(page));
|
||||
}));
|
||||
|
||||
page
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue