diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index 424ed504..40c91b0f 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -272,13 +272,14 @@ impl Tab { /// Reload page at `i32` position or selected page on `None` given pub fn reload(&self, page_position: Option) { if let Some(item) = self.item(page_position) { - item.client.handle(&item.page.navigation.request(), true); + item.client + .handle(&item.page.navigation.request(), true, false); } } pub fn open(&self, page_position: Option, request: &str) { if let Some(item) = self.item(page_position) { - item.action.load.activate(Some(request), true); + item.action.load.activate(Some(request), true, false); } } diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index 196194ca..bafd0ff2 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -86,7 +86,7 @@ impl Item { if let Some(uri) = page.navigation.home() { let request = uri.to_string(); page.navigation.set_request(&request); - client.handle(&request, true); + client.handle(&request, true, false); } } }); @@ -94,10 +94,10 @@ impl Item { action.load.connect_activate({ let page = page.clone(); let client = client.clone(); - move |request, is_snap_history| { + move |request, is_snap_history, is_redirect| { if let Some(request) = request { page.navigation.set_request(&request); - client.handle(&request, is_snap_history); + client.handle(&request, is_snap_history, is_redirect); } } }); @@ -110,7 +110,7 @@ impl Item { action.reload.connect_activate({ let page = page.clone(); let client = client.clone(); - move |_, _| client.handle(&page.navigation.request(), true) + move |_, _| client.handle(&page.navigation.request(), true, false) }); action.reload.connect_enabled_notify({ @@ -147,7 +147,7 @@ impl Item { if let Some(request) = request { page.navigation.set_request(request); if is_load { - client.handle(request, true) + client.handle(request, true, false) } } diff --git a/src/app/browser/window/tab/item/action.rs b/src/app/browser/window/tab/item/action.rs index 24bea278..f15c7640 100644 --- a/src/app/browser/window/tab/item/action.rs +++ b/src/app/browser/window/tab/item/action.rs @@ -40,7 +40,7 @@ impl Action { let history = Rc::new(History::build({ let load = load.clone(); - move |request| load.activate(Some(&request), false) + move |request| load.activate(Some(&request), false, false) })); Self { diff --git a/src/app/browser/window/tab/item/action/load.rs b/src/app/browser/window/tab/item/action/load.rs index bb39158d..d955d2f9 100644 --- a/src/app/browser/window/tab/item/action/load.rs +++ b/src/app/browser/window/tab/item/action/load.rs @@ -23,7 +23,7 @@ impl Load { Self { simple_action: SimpleAction::new( &uuid_string_random(), - Some(&<(String, bool)>::static_variant_type()), + Some(&<(String, bool, bool)>::static_variant_type()), ), } } @@ -32,9 +32,9 @@ impl Load { /// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal /// with formatted for this action [Variant](https://docs.gtk.org/glib/struct.Variant.html) value - pub fn activate(&self, request: Option<&str>, is_history: bool) { + pub fn activate(&self, request: Option<&str>, is_snap_history: bool, is_redirect: bool) { self.simple_action.activate(Some( - &(request.unwrap_or_default(), is_history).to_variant(), + &(request.unwrap_or_default(), is_snap_history, is_redirect).to_variant(), )); } @@ -42,19 +42,20 @@ impl Load { /// Define callback function for /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal - pub fn connect_activate(&self, callback: impl Fn(Option, bool) + 'static) { + pub fn connect_activate(&self, callback: impl Fn(Option, bool, bool) + 'static) { self.simple_action.connect_activate(move |_, this| { - let (request, is_history) = this - .expect("Expected (`request`,`is_history`) variant") - .get::<(String, bool)>() - .expect("Parameter type does not match (`String`,`bool`) tuple"); + let (request, is_snap_history, is_redirect) = this + .expect("Expected (`request`,`is_snap_history`) variant") + .get::<(String, bool, bool)>() + .expect("Parameter type does not match (`String`,`bool`,`bool`) tuple"); callback( match request.is_empty() { true => None, false => Some(request.into()), }, - is_history, + is_snap_history, + is_redirect, ) }); } diff --git a/src/app/browser/window/tab/item/client.rs b/src/app/browser/window/tab/item/client.rs index 64f59186..0a9f3374 100644 --- a/src/app/browser/window/tab/item/client.rs +++ b/src/app/browser/window/tab/item/client.rs @@ -36,7 +36,7 @@ impl Client { /// Route tab item `request` to protocol driver /// * or `navigation` entry if the value not provided - pub fn handle(&self, request: &str, is_snap_history: bool) { + pub fn handle(&self, request: &str, is_snap_history: bool, is_redirect: bool) { self.page.escape(); // Initially disable find action @@ -63,11 +63,13 @@ impl Client { "file" => driver .file .handle(uri, feature, cancellable, is_snap_history), - "gemini" | "titan" => { - driver - .gemini - .handle(uri, feature, cancellable, is_snap_history) - } + "gemini" | "titan" => driver.gemini.handle( + uri, + feature, + cancellable, + is_snap_history, + is_redirect, + ), scheme => { // no scheme match driver, complete with failure message let status = page.content.to_status_failure(); @@ -79,10 +81,11 @@ impl Client { } }, // begin redirection to new address suggested - Err(query) => page - .item_action - .load - .activate(Some(&query), is_snap_history), + Err(query) => { + page.item_action + .load + .activate(Some(&query), is_snap_history, true) + } } } }) diff --git a/src/app/browser/window/tab/item/client/driver/file/directory.rs b/src/app/browser/window/tab/item/client/driver/file/directory.rs index 47052a8f..90e14177 100644 --- a/src/app/browser/window/tab/item/client/driver/file/directory.rs +++ b/src/app/browser/window/tab/item/client/driver/file/directory.rs @@ -26,6 +26,7 @@ impl Directory { file.path().unwrap().to_str().unwrap() )), is_snap_history, + false, ) } }, diff --git a/src/app/browser/window/tab/item/client/driver/gemini.rs b/src/app/browser/window/tab/item/client/driver/gemini.rs index 16876780..c47fa78f 100644 --- a/src/app/browser/window/tab/item/client/driver/gemini.rs +++ b/src/app/browser/window/tab/item/client/driver/gemini.rs @@ -39,7 +39,7 @@ impl Gemini { p.set_progress(match event { // 0.1 reserved for handle begin SocketClientEvent::Resolving => { - i.reset().add_event("Resolving".to_string()); + i.add_event("Resolving".to_string()); 0.2 } SocketClientEvent::Resolved => { @@ -94,8 +94,15 @@ impl Gemini { feature: Rc, cancellable: Cancellable, is_snap_history: bool, + is_redirect: bool, ) { use ggemini::client::connection::request::{Mode, Request}; + self.page + .navigation + .request + .info + .borrow_mut() + .reset(!is_redirect); match uri.scheme().as_str() { "gemini" => handle( self, @@ -109,6 +116,8 @@ impl Gemini { is_snap_history, ), "titan" => { + self.page.set_title("Titan input"); + self.page.set_progress(0.0); self.page.input.set_new_titan({ let this = Self { client: self.client.clone(), @@ -131,9 +140,7 @@ impl Gemini { is_snap_history, ) } - }); - self.page.set_title("Titan input"); - self.page.set_progress(0.0); + }) } _ => panic!(), // unexpected } @@ -520,7 +527,7 @@ fn handle( .build(); b.connect_clicked({ let p = page.clone(); - move |_| p.item_action.load.activate(Some(&u), false) + move |_| p.item_action.load.activate(Some(&u), false, true) }); b })); @@ -544,7 +551,7 @@ fn handle( Redirect::Temporary { .. } => i.into_temporary_redirect(), }); } - page.item_action.load.activate(Some(&t), false); + page.item_action.load.activate(Some(&t), false, true); } } Err(e) => { diff --git a/src/app/browser/window/tab/item/page/content/status/mime.rs b/src/app/browser/window/tab/item/page/content/status/mime.rs index 434331db..65087ffc 100644 --- a/src/app/browser/window/tab/item/page/content/status/mime.rs +++ b/src/app/browser/window/tab/item/page/content/status/mime.rs @@ -26,7 +26,7 @@ pub fn build(mime: &str, download: Option<(&Rc, &Uri)>) -> StatusPag move |_| { action .load - .activate(Some(&format!("download:{}", request)), true) + .activate(Some(&format!("download:{}", request)), true, false) } }); diff --git a/src/app/browser/window/tab/item/page/content/text/gemini.rs b/src/app/browser/window/tab/item/page/content/text/gemini.rs index dcc40a39..52fc00af 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini.rs @@ -316,7 +316,7 @@ impl Gemini { // Select link handler by scheme return match uri.scheme().as_str() { "gemini" | "titan" => { - item_action.load.activate(Some(&uri.to_str()), true) + item_action.load.activate(Some(&uri.to_str()), true, false) } // Scheme not supported, delegate _ => UriLauncher::new(&uri.to_str()).launch( diff --git a/src/app/browser/window/tab/item/page/input/response.rs b/src/app/browser/window/tab/item/page/input/response.rs index 95903e0c..e56c25dc 100644 --- a/src/app/browser/window/tab/item/page/input/response.rs +++ b/src/app/browser/window/tab/item/page/input/response.rs @@ -85,6 +85,7 @@ impl Response for Box { Uri::escape_string(&text_view.text(), None, false), )), false, + false, ) } }); diff --git a/src/app/browser/window/tab/item/page/input/sensitive.rs b/src/app/browser/window/tab/item/page/input/sensitive.rs index 1a8ab3ff..57df9174 100644 --- a/src/app/browser/window/tab/item/page/input/sensitive.rs +++ b/src/app/browser/window/tab/item/page/input/sensitive.rs @@ -66,6 +66,7 @@ impl Sensitive for Box { Uri::escape_string(&form.password_entry_row.text(), None, false), )), false, + false, ) } }); diff --git a/src/app/browser/window/tab/item/page/navigation/request/info.rs b/src/app/browser/window/tab/item/page/navigation/request/info.rs index e166c71c..d7773e42 100644 --- a/src/app/browser/window/tab/item/page/navigation/request/info.rs +++ b/src/app/browser/window/tab/item/page/navigation/request/info.rs @@ -73,7 +73,10 @@ impl Info { /// Reset `Self` to the clean state /// * this method keeps `Redirect` value! - pub fn reset(&mut self) -> &mut Self { + pub fn reset(&mut self, is_unset_redirect: bool) -> &mut Self { + if is_unset_redirect { + self.set_redirect(None); + } self.clear_events() .set_header(None) .set_mime(None) @@ -102,6 +105,11 @@ impl Info { self } + pub fn set_redirect(&mut self, redirect: Option) -> &mut Self { + self.redirect = redirect; + self + } + pub fn set_socket(&mut self, address: Option<(SocketAddress, SocketAddress)>) -> &mut Self { self.socket = address.map(|(local_address, remote_address)| Socket { local_address,