mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
implement tab restore feature
This commit is contained in:
parent
d074ef17fe
commit
09c08b2b6f
7 changed files with 58 additions and 72 deletions
|
|
@ -2,6 +2,8 @@ use adw::{TabPage, TabView};
|
|||
use gtk::Box;
|
||||
use std::sync::Arc;
|
||||
|
||||
const DEFAULT_TITLE: &str = "New page";
|
||||
|
||||
pub struct Widget {
|
||||
gobject: TabPage,
|
||||
}
|
||||
|
|
@ -12,15 +14,16 @@ impl Widget {
|
|||
tab_view: &TabView,
|
||||
page: &Box,
|
||||
title: Option<&str>,
|
||||
is_selected_page: bool,
|
||||
is_selected: bool,
|
||||
) -> Arc<Self> {
|
||||
let gobject = tab_view.append(page);
|
||||
|
||||
if let Some(value) = title {
|
||||
gobject.set_title(value);
|
||||
}
|
||||
gobject.set_title(match title {
|
||||
Some(value) => value,
|
||||
None => DEFAULT_TITLE,
|
||||
});
|
||||
|
||||
if is_selected_page {
|
||||
if is_selected {
|
||||
tab_view.set_selected_page(&gobject);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue