mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
implement is_history record argument for load action
This commit is contained in:
parent
60d4a94ff3
commit
47b2be986b
@ -81,7 +81,7 @@ impl Item {
|
||||
|
||||
action.load().connect_activate({
|
||||
let page = page.clone();
|
||||
move |request| {
|
||||
move |request, is_history| {
|
||||
if let Some(text) = request {
|
||||
page.navigation()
|
||||
.request()
|
||||
@ -89,7 +89,7 @@ impl Item {
|
||||
.gobject()
|
||||
.set_text(&text);
|
||||
}
|
||||
page.load(true);
|
||||
page.load(is_history);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -15,7 +15,10 @@ impl Load {
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type())),
|
||||
gobject: SimpleAction::new(
|
||||
&uuid_string_random(),
|
||||
Some(&<(String, bool)>::static_variant_type()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,12 +26,15 @@ 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>) {
|
||||
pub fn activate(&self, request: Option<&str>, is_history: bool) {
|
||||
self.gobject.activate(Some(
|
||||
&match request {
|
||||
&(
|
||||
match request {
|
||||
Some(value) => String::from(value),
|
||||
None => String::new(),
|
||||
}
|
||||
},
|
||||
is_history,
|
||||
)
|
||||
.to_variant(),
|
||||
));
|
||||
}
|
||||
@ -37,17 +43,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>) + 'static) {
|
||||
self.gobject.connect_activate(move |_, variant| {
|
||||
let request = variant
|
||||
.expect("Parameter value required")
|
||||
.get::<String>()
|
||||
.expect("Parameter type does not match `String`");
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<GString>, bool) + 'static) {
|
||||
self.gobject.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");
|
||||
|
||||
callback(match request.is_empty() {
|
||||
callback(
|
||||
match request.is_empty() {
|
||||
true => None,
|
||||
false => Some(request.into()),
|
||||
})
|
||||
},
|
||||
is_history,
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ impl Page {
|
||||
pub fn home(&self) {
|
||||
if let Some(url) = self.navigation.home().url() {
|
||||
// Update with history record
|
||||
self.tab_action.load().activate(Some(&url));
|
||||
self.tab_action.load().activate(Some(&url), true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -748,8 +748,8 @@ impl Page {
|
||||
.set_status(Status::Redirect) // @TODO is this status really wanted?
|
||||
.set_title("Redirect");
|
||||
|
||||
// Reload page to apply redirection
|
||||
tab_action.load().activate(None);
|
||||
// Reload page to apply redirection (without history record request)
|
||||
tab_action.load().activate(None, false);
|
||||
}
|
||||
},
|
||||
Err(reason) => {
|
||||
|
@ -247,7 +247,7 @@ impl Reader {
|
||||
return match uri.scheme().as_str() {
|
||||
"gemini" => {
|
||||
// Open new page in browser
|
||||
actions.1.load().activate(Some(&uri.to_str()));
|
||||
actions.1.load().activate(Some(&uri.to_str()), true);
|
||||
}
|
||||
// Scheme not supported, delegate
|
||||
_ => UriLauncher::new(&uri.to_str()).launch(
|
||||
|
@ -63,11 +63,14 @@ impl Response {
|
||||
action_send.connect_activate({
|
||||
let form = form.clone();
|
||||
move |_, _| {
|
||||
tab_action.load().activate(Some(&format!(
|
||||
tab_action.load().activate(
|
||||
Some(&format!(
|
||||
"{}?{}",
|
||||
base.to_string_partial(UriHideFlags::QUERY),
|
||||
Uri::escape_string(form.text().as_str(), None, false),
|
||||
)));
|
||||
)),
|
||||
true,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -44,11 +44,14 @@ impl Sensitive {
|
||||
action_send.connect_activate({
|
||||
let form = form.clone();
|
||||
move |_, _| {
|
||||
tab_action.load().activate(Some(&format!(
|
||||
tab_action.load().activate(
|
||||
Some(&format!(
|
||||
"{}?{}",
|
||||
base.to_string_partial(UriHideFlags::QUERY),
|
||||
Uri::escape_string(form.text().as_str(), None, false),
|
||||
)));
|
||||
)),
|
||||
true,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -48,7 +48,7 @@ impl Widget {
|
||||
});
|
||||
|
||||
gobject.connect_activate(move |this| {
|
||||
tab_action.load().activate(Some(&this.text()));
|
||||
tab_action.load().activate(Some(&this.text()), true);
|
||||
});
|
||||
|
||||
gobject.connect_state_flags_changed({
|
||||
|
Loading…
x
Reference in New Issue
Block a user