add comments, rename address getter to url

This commit is contained in:
yggverse 2024-09-30 16:40:36 +03:00
parent 68898d8da0
commit 4e7565297a
3 changed files with 10 additions and 6 deletions

View File

@ -114,8 +114,8 @@ impl Page {
}
pub fn navigation_base(&self) {
if let Some(address) = self.navigation.base_address() {
self.action_page_open.activate(Some(&address.to_variant()));
if let Some(url) = self.navigation.base_url() {
self.action_page_open.activate(Some(&url.to_variant()));
}
}

View File

@ -103,8 +103,8 @@ impl Navigation {
&self.widget
}
pub fn base_address(&self) -> Option<GString> {
self.base.address()
pub fn base_url(&self) -> Option<GString> {
self.base.url()
}
pub fn request_text(&self) -> GString {

View File

@ -7,8 +7,11 @@ use gtk::{
use std::{cell::RefCell, sync::Arc};
pub struct Base {
// Actions
action_tab_page_navigation_base: Arc<SimpleAction>,
// Mutable URI cache (parsed on update)
uri: RefCell<Option<Uri>>,
// GTK
widget: Button,
}
@ -58,7 +61,8 @@ impl Base {
&self.widget
}
pub fn address(&self) -> Option<GString> {
pub fn url(&self) -> Option<GString> {
// Build URL from parsed URI cache
if let Some(uri) = self.uri.take() {
let scheme = uri.scheme();
let port = uri.port();
@ -67,7 +71,7 @@ impl Base {
return Some(gformat!("{scheme}://{host}:{port}/"));
} else {
return Some(gformat!("{scheme}://{host}/"));
}
} // @TODO auth params
}
}
None