From 10374b1b0806bc27b97655214337928477b2a09d Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 27 Sep 2024 18:35:52 +0300 Subject: [PATCH] show uri base as title by default --- src/browser/main/tab/page/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/browser/main/tab/page/mod.rs b/src/browser/main/tab/page/mod.rs index bb2a04d7..f3c2998b 100644 --- a/src/browser/main/tab/page/mod.rs +++ b/src/browser/main/tab/page/mod.rs @@ -18,7 +18,7 @@ use gtk::{ }, Box, Orientation, }; -use std::{cell::RefCell, sync::Arc}; +use std::{cell::RefCell, path::Path, sync::Arc}; pub struct Page { // GTK @@ -172,6 +172,16 @@ impl Page { // Format response meta.borrow_mut().progress_fraction = 1.0; meta.borrow_mut().description = host; + meta.borrow_mut().title = uri.path(); + + // Try create short base for title + let path = uri.path(); + let path = Path::new(&path); + if let Some(base) = path.file_name() { + if let Some(base_str) = base.to_str() { + meta.borrow_mut().title = GString::from(base_str); + } + } // Parse response @TODO read bytes let parts = Regex::split_simple(