From 0c2658825e8b999fc137449cc5d1358a898b13fa Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 11 Oct 2024 05:21:04 +0300 Subject: [PATCH] implement tab title update --- src/app/browser/window/tab.rs | 9 +++++++++ src/app/browser/window/tab/item.rs | 4 ++++ src/app/browser/window/tab/item/page.rs | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index ac6052d9..ef3e98bc 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -155,7 +155,16 @@ impl Tab { pub fn update(&self) { if let Some(id) = self.widget.current_page_keyword() { if let Some(item) = self.index.borrow().get(&id) { + // Update item components item.update(); + + // Update tab title + let title = match item.page_meta_title() { + Some(value) => value, + None => GString::new(), + }; + + item.gobject().set_title(title.as_str()); } } } diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index 26ba59d4..41950b13 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -187,6 +187,10 @@ impl Item { self.id.clone() } + pub fn page_meta_title(&self) -> Option { + self.page.meta_title() + } + pub fn gobject(&self) -> &TabPage { &self.widget.gobject() } diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index a003357a..442645a9 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -463,6 +463,10 @@ impl Page { } // Getters + pub fn meta_title(&self) -> Option { + self.meta.borrow().title.clone() + } + pub fn gobject(&self) -> &Box { &self.widget.gobject() }