diff --git a/Cargo.toml b/Cargo.toml index 6befb5a..9ea2d73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" description = "A wip universal Linux settings application." [dependencies] -reset_daemon = "0.3.3" +reset_daemon = "0.3.6" ReSet-Lib = "0.6.1" adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] } dbus = "0.9.7" diff --git a/src/components/wifi/wifiAddressEntry.rs b/src/components/wifi/wifiAddressEntry.rs index 8bf6320..dc8a74a 100644 --- a/src/components/wifi/wifiAddressEntry.rs +++ b/src/components/wifi/wifiAddressEntry.rs @@ -158,4 +158,3 @@ fn setRowName(selfImp: &WifiAddressEntryImpl) { }; selfImp.resetAddressRow.set_title(&title); } - diff --git a/src/components/wifi/wifiBoxImpl.rs b/src/components/wifi/wifiBoxImpl.rs index ba061ea..7f4b86a 100644 --- a/src/components/wifi/wifiBoxImpl.rs +++ b/src/components/wifi/wifiBoxImpl.rs @@ -1,13 +1,13 @@ use crate::components::wifi::wifiBox; -use ReSet_Lib::network::network::WifiDevice; use adw::{ActionRow, ComboRow, NavigationView, PreferencesGroup}; use dbus::Path; -use gtk::{prelude::*, StringList}; use gtk::subclass::prelude::*; use gtk::{glib, CompositeTemplate, Switch}; +use gtk::{prelude::*, StringList}; use std::cell::RefCell; use std::collections::HashMap; use std::sync::{Arc, Mutex, RwLock}; +use ReSet_Lib::network::network::WifiDevice; use crate::components::base::listEntry::ListEntry; use crate::components::wifi::wifiEntry::WifiEntry; @@ -35,7 +35,7 @@ pub struct WifiBox { pub wifiEntries: Arc, Arc>>>, pub wifiEntriesPath: Arc, Arc>>>, pub savedWifiEntries: Arc>>, - pub resetWifiDevices: Arc>>, + pub resetWifiDevices: Arc>>, pub resetCurrentWifiDevice: Arc>, pub resetModelList: Arc>, pub resetModelIndex: Arc>, diff --git a/src/components/wifi/wifiEntry.rs b/src/components/wifi/wifiEntry.rs index 8bae311..943b342 100644 --- a/src/components/wifi/wifiEntry.rs +++ b/src/components/wifi/wifiEntry.rs @@ -1,4 +1,3 @@ -use std::sync::atomic::AtomicBool; use std::sync::Arc; use std::time::Duration; diff --git a/src/components/wifi/wifiEntryImpl.rs b/src/components/wifi/wifiEntryImpl.rs index e2e27cd..81fb42d 100644 --- a/src/components/wifi/wifiEntryImpl.rs +++ b/src/components/wifi/wifiEntryImpl.rs @@ -5,7 +5,7 @@ use adw::subclass::prelude::ActionRowImpl; use adw::ActionRow; use gtk::subclass::prelude::*; use gtk::{glib, Button, CompositeTemplate, Image, Label}; -use std::cell::{RefCell, Cell}; +use std::cell::RefCell; use ReSet_Lib::network::network::{AccessPoint, WifiStrength}; #[allow(non_snake_case)] diff --git a/src/components/window/mod.rs b/src/components/window/mod.rs index c44c930..6260cbf 100644 --- a/src/components/window/mod.rs +++ b/src/components/window/mod.rs @@ -1,6 +1,6 @@ #![allow(non_snake_case)] pub mod handleSidebarClick; +pub mod resetWindow; +pub mod resetWindowImpl; pub mod sidebarEntry; pub mod sidebarEntryImpl; -pub mod window; -pub mod windowImpl; diff --git a/src/components/window/window.rs b/src/components/window/resetWindow.rs similarity index 82% rename from src/components/window/window.rs rename to src/components/window/resetWindow.rs index 81b67e3..1d989a9 100644 --- a/src/components/window/window.rs +++ b/src/components/window/resetWindow.rs @@ -1,28 +1,28 @@ -use adw::BreakpointCondition; use adw::glib::clone; use adw::subclass::prelude::ObjectSubclassIsExt; +use adw::BreakpointCondition; use glib::Object; -use gtk::{Application, gio, glib, ListBoxRow, Orientation}; use gtk::prelude::*; +use gtk::{gio, glib, Application, ListBoxRow, Orientation}; use crate::components::window::handleSidebarClick::*; +use crate::components::window::resetWindowImpl; use crate::components::window::sidebarEntry::SidebarEntry; use crate::components::window::sidebarEntryImpl::Categories; -use crate::components::window::windowImpl; glib::wrapper! { - pub struct Window(ObjectSubclass) + pub struct ReSetWindow(ObjectSubclass) @extends gtk::ApplicationWindow, gtk::Window, gtk::Widget, @implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager; } -unsafe impl Send for Window {} +unsafe impl Send for ReSetWindow {} -unsafe impl Sync for Window {} +unsafe impl Sync for ReSetWindow {} #[allow(non_snake_case)] -impl Window { +impl ReSetWindow { pub fn new(app: &Application) -> Self { Object::builder().property("application", app).build() } @@ -30,11 +30,15 @@ impl Window { pub fn setupCallback(&self) { let selfImp = self.imp(); - selfImp.resetSearchEntry.connect_search_changed(clone!(@ weak self as window => move |_| { + selfImp + .resetSearchEntry + .connect_search_changed(clone!(@ weak self as window => move |_| { window.filterList(); })); - selfImp.resetSideBarToggle.connect_clicked(clone!(@ weak self as window => move |_| { + selfImp + .resetSideBarToggle + .connect_clicked(clone!(@ weak self as window => move |_| { window.toggleSidebar(); })); @@ -46,7 +50,9 @@ impl Window { }), ); - selfImp.resetClose.connect_clicked(clone!(@ weak self as window => move |_| { + selfImp + .resetClose + .connect_clicked(clone!(@ weak self as window => move |_| { window.close(); })); @@ -58,7 +64,9 @@ impl Window { pub fn handleDynamicSidebar(&self) { let selfImp = self.imp(); - selfImp.resetSidebarBreakpoint.set_condition(BreakpointCondition::parse("max-width: 700sp").as_ref().ok()); + selfImp + .resetSidebarBreakpoint + .set_condition(BreakpointCondition::parse("max-width: 700sp").as_ref().ok()); selfImp.resetSidebarBreakpoint.add_setter( &Object::from(selfImp.resetOverlaySplitView.get()), "collapsed", @@ -81,13 +89,25 @@ impl Window { } continue; } - if mainEntry.imp().name.borrow().to_lowercase().contains(&text.to_lowercase()) { + if mainEntry + .imp() + .name + .borrow() + .to_lowercase() + .contains(&text.to_lowercase()) + { mainEntry.set_visible(true); } else { mainEntry.set_visible(false); } for subEntry in subEntries { - if subEntry.imp().name.borrow().to_lowercase().contains(&text.to_lowercase()) { + if subEntry + .imp() + .name + .borrow() + .to_lowercase() + .contains(&text.to_lowercase()) + { subEntry.set_visible(true); mainEntry.set_visible(true); } else { @@ -207,9 +227,11 @@ impl Window { // peripheralsList, // )); - selfImp.resetSidebarList.connect_row_activated(clone!(@ weak selfImp => move |_, _| { - selfImp.resetSearchEntry.set_text(""); - })); + selfImp + .resetSidebarList + .connect_row_activated(clone!(@ weak selfImp => move |_, _| { + selfImp.resetSearchEntry.set_text(""); + })); for (mainEntry, subEntries) in sidebarEntries.iter() { selfImp.resetSidebarList.append(mainEntry); @@ -226,7 +248,9 @@ impl Window { pub fn setupPopoverButtons(&self) { let selfImp = self.imp(); - selfImp.resetAboutButton.connect_clicked(clone!(@ weak self as window => move |_| { + selfImp + .resetAboutButton + .connect_clicked(clone!(@ weak self as window => move |_| { let dialog = adw::AboutWindow::builder() .application_name("ReSet") .application_icon("ReSet") @@ -245,12 +269,16 @@ impl Window { window.imp().resetPopoverMenu.popdown(); dialog.present(); })); - selfImp.resetPreferenceButton.connect_clicked(clone!(@weak self as window => move |_| { + selfImp + .resetPreferenceButton + .connect_clicked(clone!(@weak self as window => move |_| { let preferences = adw::PreferencesWindow::builder().build(); window.imp().resetPopoverMenu.popdown(); preferences.present(); })); - selfImp.resetShortcutsButton.connect_clicked(clone!(@weak self as window => move |_| { + selfImp + .resetShortcutsButton + .connect_clicked(clone!(@weak self as window => move |_| { let shortcuts = gtk::ShortcutsWindow::builder().build(); window.imp().resetPopoverMenu.popdown(); shortcuts.present(); diff --git a/src/components/window/windowImpl.rs b/src/components/window/resetWindowImpl.rs similarity index 83% rename from src/components/window/windowImpl.rs rename to src/components/window/resetWindowImpl.rs index a1168be..1ec8343 100644 --- a/src/components/window/windowImpl.rs +++ b/src/components/window/resetWindowImpl.rs @@ -10,13 +10,13 @@ use gtk::{glib, Button, CompositeTemplate, FlowBox, ListBox, PopoverMenu, Search use crate::components::base::utils::Listeners; use crate::components::wifi::wifiBox::WifiBox; +use crate::components::window::resetWindow; use crate::components::window::sidebarEntry::SidebarEntry; -use crate::components::window::window; #[allow(non_snake_case)] #[derive(CompositeTemplate, Default)] #[template(resource = "/org/Xetibo/ReSet/resetMainWindow.ui")] -pub struct Window { +pub struct ReSetWindow { #[template_child] pub resetMain: TemplateChild, #[template_child] @@ -43,14 +43,14 @@ pub struct Window { pub listeners: Arc, } -unsafe impl Send for Window {} -unsafe impl Sync for Window {} +unsafe impl Send for ReSetWindow {} +unsafe impl Sync for ReSetWindow {} #[glib::object_subclass] -impl ObjectSubclass for Window { +impl ObjectSubclass for ReSetWindow { const ABSTRACT: bool = false; const NAME: &'static str = "resetUI"; - type Type = window::Window; + type Type = resetWindow::ReSetWindow; type ParentType = adw::ApplicationWindow; fn class_init(klass: &mut Self::Class) { @@ -63,7 +63,7 @@ impl ObjectSubclass for Window { } } -impl ObjectImpl for Window { +impl ObjectImpl for ReSetWindow { fn constructed(&self) { self.parent_constructed(); @@ -75,10 +75,10 @@ impl ObjectImpl for Window { } } -impl WidgetImpl for Window {} +impl WidgetImpl for ReSetWindow {} -impl WindowImpl for Window {} +impl WindowImpl for ReSetWindow {} -impl ApplicationWindowImpl for Window {} +impl ApplicationWindowImpl for ReSetWindow {} -impl AdwApplicationWindowImpl for Window {} +impl AdwApplicationWindowImpl for ReSetWindow {} diff --git a/src/main.rs b/src/main.rs index 505614d..d0a71e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use std::thread; use std::time::Duration; +use components::window::resetWindow::ReSetWindow; use dbus::blocking::Connection; use dbus::Error; use gtk::gdk::Display; @@ -10,8 +11,6 @@ use gtk::prelude::*; use gtk::{gio, Application, CssProvider}; use reset_daemon::run_daemon; -use crate::components::window::window::Window; - mod components; const APP_ID: &str = "org.Xetibo.ReSet"; @@ -49,7 +48,7 @@ fn loadCss() { #[allow(non_snake_case)] fn buildUI(app: &Application) { - let window = Window::new(app); + let window = ReSetWindow::new(app); window.present(); }