mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
fix identity request implementation
This commit is contained in:
parent
2dc6154d54
commit
f581f1d2f3
4 changed files with 36 additions and 26 deletions
|
|
@ -91,6 +91,11 @@ impl Item {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
action.identity.connect_activate({
|
||||||
|
let page = page.clone();
|
||||||
|
move |_, _| page.navigation.identity()
|
||||||
|
});
|
||||||
|
|
||||||
action.reload.connect_activate({
|
action.reload.connect_activate({
|
||||||
let page = page.clone();
|
let page = page.clone();
|
||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ pub trait Identity {
|
||||||
|
|
||||||
impl Identity for SimpleAction {
|
impl Identity for SimpleAction {
|
||||||
fn identity() -> Self {
|
fn identity() -> Self {
|
||||||
let identity = SimpleAction::new(&uuid_string_random(), None);
|
SimpleAction::new(&uuid_string_random(), None)
|
||||||
identity.set_enabled(false);
|
|
||||||
identity
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,10 @@ impl Navigation {
|
||||||
self.request.grab_focus()
|
self.request.grab_focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn identity(&self) {
|
||||||
|
self.request.identity(&self.profile)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
self.bookmark.update(&self.profile, &self.request);
|
self.bookmark.update(&self.profile, &self.request);
|
||||||
self.request.update(&self.profile);
|
self.request.update(&self.profile);
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ pub trait Request {
|
||||||
) -> Result<(), String>;
|
) -> Result<(), String>;
|
||||||
|
|
||||||
fn update(&self, profile: &Profile);
|
fn update(&self, profile: &Profile);
|
||||||
|
fn identity(&self, profile: &Rc<Profile>);
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
|
|
@ -72,27 +73,12 @@ impl Request for Entry {
|
||||||
|
|
||||||
// Connect events
|
// Connect events
|
||||||
entry.connect_icon_release({
|
entry.connect_icon_release({
|
||||||
let item_action = item_action.clone();
|
|
||||||
let profile = profile.clone();
|
let profile = profile.clone();
|
||||||
move |this, position| match position {
|
move |this, position| match position {
|
||||||
EntryIconPosition::Primary => {
|
EntryIconPosition::Primary => this.identity(&profile),
|
||||||
if let Some(request) = this.uri() {
|
EntryIconPosition::Secondary => {
|
||||||
if ["gemini", "titan"].contains(&request.scheme().as_str()) {
|
this.activate();
|
||||||
return identity::default(&profile, &request, {
|
|
||||||
let item_action = item_action.clone();
|
|
||||||
let profile = profile.clone();
|
|
||||||
let this = this.clone();
|
|
||||||
move || {
|
|
||||||
this.update(&profile);
|
|
||||||
item_action.load.activate(Some(&this.text()), false);
|
|
||||||
} // on apply
|
|
||||||
})
|
|
||||||
.present(Some(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
identity::unsupported().present(Some(this));
|
|
||||||
}
|
}
|
||||||
EntryIconPosition::Secondary => item_action.load.activate(Some(&this.text()), true),
|
|
||||||
_ => todo!(), // unexpected
|
_ => todo!(), // unexpected
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -121,15 +107,15 @@ impl Request for Entry {
|
||||||
|
|
||||||
entry.connect_activate({
|
entry.connect_activate({
|
||||||
let item_action = item_action.clone();
|
let item_action = item_action.clone();
|
||||||
move |entry| {
|
move |this| {
|
||||||
item_action.load.activate(Some(&entry.text()), true);
|
item_action.load.activate(Some(&this.text()), true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
entry.connect_state_flags_changed({
|
entry.connect_state_flags_changed({
|
||||||
// Define last focus state container
|
// Define last focus state container
|
||||||
let has_focus = Cell::new(false);
|
let has_focus = Cell::new(false);
|
||||||
move |entry, state| {
|
move |this, state| {
|
||||||
// Select entire text on first click (release)
|
// Select entire text on first click (release)
|
||||||
// this behavior implemented in most web-browsers,
|
// this behavior implemented in most web-browsers,
|
||||||
// to simply overwrite current request with new value
|
// to simply overwrite current request with new value
|
||||||
|
|
@ -138,9 +124,9 @@ impl Request for Entry {
|
||||||
// * This is experimental feature does not follow native GTK behavior @TODO make optional
|
// * This is experimental feature does not follow native GTK behavior @TODO make optional
|
||||||
if !has_focus.take()
|
if !has_focus.take()
|
||||||
&& state.contains(StateFlags::ACTIVE | StateFlags::FOCUS_WITHIN)
|
&& state.contains(StateFlags::ACTIVE | StateFlags::FOCUS_WITHIN)
|
||||||
&& entry.selection_bounds().is_none()
|
&& this.selection_bounds().is_none()
|
||||||
{
|
{
|
||||||
entry.select_region(0, entry.text_length().into());
|
this.select_region(0, this.text_length().into());
|
||||||
}
|
}
|
||||||
// Update last focus state
|
// Update last focus state
|
||||||
has_focus.replace(state.contains(StateFlags::FOCUS_WITHIN));
|
has_focus.replace(state.contains(StateFlags::FOCUS_WITHIN));
|
||||||
|
|
@ -258,6 +244,23 @@ impl Request for Entry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn identity(&self, profile: &Rc<Profile>) {
|
||||||
|
if let Some(uri) = self.uri() {
|
||||||
|
if ["gemini", "titan"].contains(&uri.scheme().as_str()) {
|
||||||
|
return identity::default(profile, &uri, {
|
||||||
|
let profile = profile.clone();
|
||||||
|
let this = self.clone();
|
||||||
|
move || {
|
||||||
|
this.update(&profile);
|
||||||
|
this.emit_activate();
|
||||||
|
} // on apply
|
||||||
|
})
|
||||||
|
.present(Some(self));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
identity::unsupported().present(Some(self));
|
||||||
|
}
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
fn to_download(&self) {
|
fn to_download(&self) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue