mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
add is_selected_page option
This commit is contained in:
parent
2b898d9b47
commit
d074ef17fe
4 changed files with 18 additions and 6 deletions
|
|
@ -86,6 +86,8 @@ impl Tab {
|
|||
self.action_tab_page_navigation_history_forward.clone(),
|
||||
self.action_tab_page_navigation_reload.clone(),
|
||||
self.action_update.clone(),
|
||||
// Options
|
||||
true,
|
||||
);
|
||||
|
||||
// Register dynamically created tab components in the HashMap index
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ impl Item {
|
|||
action_tab_page_navigation_history_forward: Arc<SimpleAction>,
|
||||
action_tab_page_navigation_reload: Arc<SimpleAction>,
|
||||
action_update: Arc<SimpleAction>,
|
||||
// Options
|
||||
is_selected_page: bool,
|
||||
) -> Arc<Self> {
|
||||
// Generate unique ID for new page components
|
||||
let id = uuid_string_random();
|
||||
|
|
@ -48,7 +50,7 @@ impl Item {
|
|||
action_update.clone(),
|
||||
);
|
||||
|
||||
let widget = Widget::new_arc(tab_view, page.gobject(), Some("New page")); // @TODO
|
||||
let widget = Widget::new_arc(tab_view, page.gobject(), Some("New page"), is_selected_page); // @TODO
|
||||
|
||||
// Return struct
|
||||
Arc::new(Self { id, page, widget })
|
||||
|
|
@ -129,11 +131,14 @@ impl Item {
|
|||
// Construct new item object
|
||||
let item = Item::new_arc(
|
||||
tab_view,
|
||||
// Actions
|
||||
action_tab_page_navigation_base.clone(),
|
||||
action_tab_page_navigation_history_back.clone(),
|
||||
action_tab_page_navigation_history_forward.clone(),
|
||||
action_tab_page_navigation_reload.clone(),
|
||||
action_update.clone(),
|
||||
// Options
|
||||
true,
|
||||
);
|
||||
|
||||
// Delegate restore action to the item childs
|
||||
|
|
|
|||
|
|
@ -8,13 +8,22 @@ pub struct Widget {
|
|||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_arc(tab_view: &TabView, page: &Box, title: Option<&str>) -> Arc<Self> {
|
||||
pub fn new_arc(
|
||||
tab_view: &TabView,
|
||||
page: &Box,
|
||||
title: Option<&str>,
|
||||
is_selected_page: bool,
|
||||
) -> Arc<Self> {
|
||||
let gobject = tab_view.append(page);
|
||||
|
||||
if let Some(value) = title {
|
||||
gobject.set_title(value);
|
||||
}
|
||||
|
||||
if is_selected_page {
|
||||
tab_view.set_selected_page(&gobject);
|
||||
}
|
||||
|
||||
Arc::new(Self { gobject })
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,6 @@ impl Widget {
|
|||
}
|
||||
|
||||
// Actions
|
||||
pub fn append(&self, page: &Box) -> TabPage {
|
||||
self.gobject.append(page)
|
||||
}
|
||||
|
||||
pub fn close(&self) {
|
||||
if let Some(selected_page) = self.gobject.selected_page() {
|
||||
self.gobject.close_page(&selected_page);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue