mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-08-31 00:42:01 +00:00
implement UI frontend for the proxy connection dialog
This commit is contained in:
parent
eac71c07f6
commit
3bf75b40aa
@ -35,10 +35,10 @@ GTK 4 / Libadwaita client written in Rust
|
|||||||
* [ ] History
|
* [ ] History
|
||||||
* [x] Recently visited
|
* [x] Recently visited
|
||||||
* [ ] Recently closed
|
* [ ] Recently closed
|
||||||
* [ ] Proxy (by [SimpleProxyResolver](https://docs.gtk.org/gio/class.SimpleProxyResolver.html))
|
* [x] Proxy (by [SimpleProxyResolver](https://docs.gtk.org/gio/class.SimpleProxyResolver.html))
|
||||||
* [x] Multiple regex rules by the priority
|
* [x] Multiple regex rules by the priority
|
||||||
* [x] Custom ignored hosts
|
* [x] Custom ignored hosts
|
||||||
* [ ] UI controls (frontend)
|
* [x] UI indication with the accent colors
|
||||||
* [ ] Session
|
* [ ] Session
|
||||||
* [ ] Window
|
* [ ] Window
|
||||||
* [x] Size
|
* [x] Size
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//! Proxy settings dialog
|
//! Proxy settings dialog
|
||||||
|
|
||||||
mod ignore;
|
mod ignore;
|
||||||
|
mod misc;
|
||||||
mod rule;
|
mod rule;
|
||||||
|
|
||||||
use super::Profile;
|
use super::Profile;
|
||||||
@ -9,6 +10,7 @@ use adw::{
|
|||||||
prelude::{AdwDialogExt, PreferencesDialogExt, PreferencesGroupExt, PreferencesPageExt},
|
prelude::{AdwDialogExt, PreferencesDialogExt, PreferencesGroupExt, PreferencesPageExt},
|
||||||
};
|
};
|
||||||
use ignore::Ignore;
|
use ignore::Ignore;
|
||||||
|
use misc::Misc;
|
||||||
use rule::Rule;
|
use rule::Rule;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
@ -20,6 +22,7 @@ impl Proxy for adw::PreferencesDialog {
|
|||||||
fn proxy(profile: &Rc<Profile>) -> Self {
|
fn proxy(profile: &Rc<Profile>) -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
let ignore = Ignore::build(profile);
|
let ignore = Ignore::build(profile);
|
||||||
|
let misc = Misc::build(profile);
|
||||||
let rule = Rule::build(profile);
|
let rule = Rule::build(profile);
|
||||||
|
|
||||||
// Init widget
|
// Init widget
|
||||||
@ -54,12 +57,18 @@ impl Proxy for adw::PreferencesDialog {
|
|||||||
p
|
p
|
||||||
});
|
});
|
||||||
|
|
||||||
d.add(
|
d.add(&{
|
||||||
&PreferencesPage::builder()
|
let p = PreferencesPage::builder()
|
||||||
.title("Interface")
|
.title("Interface")
|
||||||
.icon_name("preferences-desktop-display-symbolic")
|
.icon_name("preferences-desktop-display-symbolic")
|
||||||
.build(),
|
.build();
|
||||||
);
|
p.add(&{
|
||||||
|
let g = PreferencesGroup::new();
|
||||||
|
g.add(&misc.widget);
|
||||||
|
g
|
||||||
|
});
|
||||||
|
p
|
||||||
|
});
|
||||||
|
|
||||||
d.connect_closed({
|
d.connect_closed({
|
||||||
let profile = profile.clone();
|
let profile = profile.clone();
|
||||||
@ -77,6 +86,7 @@ impl Proxy for adw::PreferencesDialog {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.proxy.ignore.clear();
|
profile.proxy.ignore.clear();
|
||||||
for i in ignore.take() {
|
for i in ignore.take() {
|
||||||
if i.validate() {
|
if i.validate() {
|
||||||
@ -86,6 +96,11 @@ impl Proxy for adw::PreferencesDialog {
|
|||||||
.add(i.id, i.is_enabled(), i.host().to_string(), i.time)
|
.add(i.id, i.is_enabled(), i.host().to_string(), i.time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
profile
|
||||||
|
.proxy
|
||||||
|
.misc
|
||||||
|
.set_highlight_request_entry(misc.is_highlight_request_entry());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
d
|
d
|
||||||
|
45
src/app/browser/proxy/misc.rs
Normal file
45
src/app/browser/proxy/misc.rs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use super::Profile;
|
||||||
|
use adw::SwitchRow;
|
||||||
|
use gtk::{Box, prelude::BoxExt};
|
||||||
|
|
||||||
|
pub struct Misc {
|
||||||
|
highlight_request_entry: SwitchRow,
|
||||||
|
pub widget: Box,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Misc {
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
pub fn build(profile: &Rc<Profile>) -> Self {
|
||||||
|
// Init components
|
||||||
|
|
||||||
|
let highlight_request_entry = SwitchRow::builder()
|
||||||
|
.active(profile.proxy.misc.is_highlight_request_entry())
|
||||||
|
.hexpand(true)
|
||||||
|
.subtitle("Use accent color for proxy connections")
|
||||||
|
.title("Highlight the request entry")
|
||||||
|
//.subtitle_selectable(true)
|
||||||
|
//.title_selectable(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Init widget
|
||||||
|
|
||||||
|
let widget = Box::builder()
|
||||||
|
.orientation(gtk::Orientation::Horizontal)
|
||||||
|
.spacing(8)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
widget.append(&highlight_request_entry);
|
||||||
|
|
||||||
|
Self {
|
||||||
|
highlight_request_entry,
|
||||||
|
widget,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_highlight_request_entry(&self) -> bool {
|
||||||
|
self.highlight_request_entry.is_active()
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user