implement UI frontend for the proxy connection dialog

This commit is contained in:
yggverse 2025-07-26 08:24:28 +03:00
parent eac71c07f6
commit 3bf75b40aa
3 changed files with 66 additions and 6 deletions

View File

@ -35,10 +35,10 @@ GTK 4 / Libadwaita client written in Rust
* [ ] History
* [x] Recently visited
* [ ] 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] Custom ignored hosts
* [ ] UI controls (frontend)
* [x] UI indication with the accent colors
* [ ] Session
* [ ] Window
* [x] Size

View File

@ -1,6 +1,7 @@
//! Proxy settings dialog
mod ignore;
mod misc;
mod rule;
use super::Profile;
@ -9,6 +10,7 @@ use adw::{
prelude::{AdwDialogExt, PreferencesDialogExt, PreferencesGroupExt, PreferencesPageExt},
};
use ignore::Ignore;
use misc::Misc;
use rule::Rule;
use std::rc::Rc;
@ -20,6 +22,7 @@ impl Proxy for adw::PreferencesDialog {
fn proxy(profile: &Rc<Profile>) -> Self {
// Init components
let ignore = Ignore::build(profile);
let misc = Misc::build(profile);
let rule = Rule::build(profile);
// Init widget
@ -54,12 +57,18 @@ impl Proxy for adw::PreferencesDialog {
p
});
d.add(
&PreferencesPage::builder()
d.add(&{
let p = PreferencesPage::builder()
.title("Interface")
.icon_name("preferences-desktop-display-symbolic")
.build(),
);
.build();
p.add(&{
let g = PreferencesGroup::new();
g.add(&misc.widget);
g
});
p
});
d.connect_closed({
let profile = profile.clone();
@ -77,6 +86,7 @@ impl Proxy for adw::PreferencesDialog {
)
}
}
profile.proxy.ignore.clear();
for i in ignore.take() {
if i.validate() {
@ -86,6 +96,11 @@ impl Proxy for adw::PreferencesDialog {
.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

View 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()
}
}