mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-08-31 00:42:01 +00:00
show proxy info as the entry tooltip
This commit is contained in:
parent
fc87c4ce00
commit
1fcc29f3f2
@ -10,8 +10,9 @@ use adw::{AlertDialog, prelude::AdwDialogExt};
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use gtk::{
|
use gtk::{
|
||||||
Entry, EntryIconPosition, StateFlags,
|
Entry, EntryIconPosition, StateFlags,
|
||||||
|
gio::Cancellable,
|
||||||
glib::{GString, Uri, UriFlags, gformat},
|
glib::{GString, Uri, UriFlags, gformat},
|
||||||
prelude::{EditableExt, EntryExt, WidgetExt},
|
prelude::{EditableExt, EntryExt, ProxyResolverExt, WidgetExt},
|
||||||
};
|
};
|
||||||
use info::Info;
|
use info::Info;
|
||||||
use primary_icon::PrimaryIcon;
|
use primary_icon::PrimaryIcon;
|
||||||
@ -125,8 +126,10 @@ impl Request {
|
|||||||
let p = profile.clone();
|
let p = profile.clone();
|
||||||
let s = suggestion.clone();
|
let s = suggestion.clone();
|
||||||
move |e| {
|
move |e| {
|
||||||
|
// Allocate once
|
||||||
|
let t = e.text();
|
||||||
// Update actions
|
// Update actions
|
||||||
a.reload.set_enabled(!e.text().is_empty());
|
a.reload.set_enabled(!t.is_empty());
|
||||||
a.home.set_enabled(home(e).is_some());
|
a.home.set_enabled(home(e).is_some());
|
||||||
// Update icons
|
// Update icons
|
||||||
update_primary_icon(e, &p);
|
update_primary_icon(e, &p);
|
||||||
@ -135,13 +138,25 @@ impl Request {
|
|||||||
if e.focus_child().is_some() {
|
if e.focus_child().is_some() {
|
||||||
s.update(Some(50)); // @TODO optional
|
s.update(Some(50)); // @TODO optional
|
||||||
}
|
}
|
||||||
// Indicate proxy connections
|
// Indicate proxy connections @TODO cancel previous operation on update
|
||||||
{
|
{
|
||||||
const C: &str = "accent";
|
const C: &str = "accent";
|
||||||
if p.proxy.matches(&e.text()).is_some() {
|
match p.proxy.matches(&t) {
|
||||||
e.set_css_classes(&[C])
|
Some(r) => {
|
||||||
} else {
|
e.set_css_classes(&[C]);
|
||||||
e.remove_css_class(C)
|
r.lookup_async(&t, Cancellable::NONE, {
|
||||||
|
let e = e.clone();
|
||||||
|
move |r| {
|
||||||
|
e.set_tooltip_text(Some(&{
|
||||||
|
match r {
|
||||||
|
Ok(h) => format!("Proxy over {}", h.join(",")),
|
||||||
|
Err(e) => e.to_string(),
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
None => e.remove_css_class(C),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user