diff --git a/README.md b/README.md index cf321623..af14ffc5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/app/browser/proxy.rs b/src/app/browser/proxy.rs index b80e7fa5..6983f1cb 100644 --- a/src/app/browser/proxy.rs +++ b/src/app/browser/proxy.rs @@ -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) -> 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 diff --git a/src/app/browser/proxy/misc.rs b/src/app/browser/proxy/misc.rs new file mode 100644 index 00000000..34dda22c --- /dev/null +++ b/src/app/browser/proxy/misc.rs @@ -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) -> 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() + } +}