Browse Source

add is_selected_page option

master
yggverse 2 months ago
parent
commit
d074ef17fe
  1. 2
      src/app/browser/window/tab.rs
  2. 7
      src/app/browser/window/tab/item.rs
  3. 11
      src/app/browser/window/tab/item/widget.rs
  4. 4
      src/app/browser/window/tab/widget.rs

2
src/app/browser/window/tab.rs

@ -86,6 +86,8 @@ impl Tab {
self.action_tab_page_navigation_history_forward.clone(), self.action_tab_page_navigation_history_forward.clone(),
self.action_tab_page_navigation_reload.clone(), self.action_tab_page_navigation_reload.clone(),
self.action_update.clone(), self.action_update.clone(),
// Options
true,
); );
// Register dynamically created tab components in the HashMap index // Register dynamically created tab components in the HashMap index

7
src/app/browser/window/tab/item.rs

@ -34,6 +34,8 @@ impl Item {
action_tab_page_navigation_history_forward: Arc<SimpleAction>, action_tab_page_navigation_history_forward: Arc<SimpleAction>,
action_tab_page_navigation_reload: Arc<SimpleAction>, action_tab_page_navigation_reload: Arc<SimpleAction>,
action_update: Arc<SimpleAction>, action_update: Arc<SimpleAction>,
// Options
is_selected_page: bool,
) -> Arc<Self> { ) -> Arc<Self> {
// Generate unique ID for new page components // Generate unique ID for new page components
let id = uuid_string_random(); let id = uuid_string_random();
@ -48,7 +50,7 @@ impl Item {
action_update.clone(), 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 // Return struct
Arc::new(Self { id, page, widget }) Arc::new(Self { id, page, widget })
@ -129,11 +131,14 @@ impl Item {
// Construct new item object // Construct new item object
let item = Item::new_arc( let item = Item::new_arc(
tab_view, tab_view,
// Actions
action_tab_page_navigation_base.clone(), action_tab_page_navigation_base.clone(),
action_tab_page_navigation_history_back.clone(), action_tab_page_navigation_history_back.clone(),
action_tab_page_navigation_history_forward.clone(), action_tab_page_navigation_history_forward.clone(),
action_tab_page_navigation_reload.clone(), action_tab_page_navigation_reload.clone(),
action_update.clone(), action_update.clone(),
// Options
true,
); );
// Delegate restore action to the item childs // Delegate restore action to the item childs

11
src/app/browser/window/tab/item/widget.rs

@ -8,13 +8,22 @@ pub struct Widget {
impl Widget { impl Widget {
// Construct // 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); let gobject = tab_view.append(page);
if let Some(value) = title { if let Some(value) = title {
gobject.set_title(value); gobject.set_title(value);
} }
if is_selected_page {
tab_view.set_selected_page(&gobject);
}
Arc::new(Self { gobject }) Arc::new(Self { gobject })
} }

4
src/app/browser/window/tab/widget.rs

@ -14,10 +14,6 @@ impl Widget {
} }
// Actions // Actions
pub fn append(&self, page: &Box) -> TabPage {
self.gobject.append(page)
}
pub fn close(&self) { pub fn close(&self) {
if let Some(selected_page) = self.gobject.selected_page() { if let Some(selected_page) = self.gobject.selected_page() {
self.gobject.close_page(&selected_page); self.gobject.close_page(&selected_page);

Loading…
Cancel
Save