mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-08-26 06:21:58 +00:00
fix redirection info reset
This commit is contained in:
parent
0d202a866a
commit
01ea693c03
@ -272,13 +272,14 @@ impl Tab {
|
||||
/// Reload page at `i32` position or selected page on `None` given
|
||||
pub fn reload(&self, page_position: Option<i32>) {
|
||||
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<i32>, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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<GString>, bool) + 'static) {
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<GString>, 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,
|
||||
)
|
||||
});
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -26,6 +26,7 @@ impl Directory {
|
||||
file.path().unwrap().to_str().unwrap()
|
||||
)),
|
||||
is_snap_history,
|
||||
false,
|
||||
)
|
||||
}
|
||||
},
|
||||
|
@ -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<Feature>,
|
||||
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) => {
|
||||
|
@ -26,7 +26,7 @@ pub fn build(mime: &str, download: Option<(&Rc<ItemAction>, &Uri)>) -> StatusPag
|
||||
move |_| {
|
||||
action
|
||||
.load
|
||||
.activate(Some(&format!("download:{}", request)), true)
|
||||
.activate(Some(&format!("download:{}", request)), true, false)
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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(
|
||||
|
@ -85,6 +85,7 @@ impl Response for Box {
|
||||
Uri::escape_string(&text_view.text(), None, false),
|
||||
)),
|
||||
false,
|
||||
false,
|
||||
)
|
||||
}
|
||||
});
|
||||
|
@ -66,6 +66,7 @@ impl Sensitive for Box {
|
||||
Uri::escape_string(&form.password_entry_row.text(), None, false),
|
||||
)),
|
||||
false,
|
||||
false,
|
||||
)
|
||||
}
|
||||
});
|
||||
|
@ -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<Redirect>) -> &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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user