mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-17 10:18:32 +02:00
chore: Code cleanup
This commit is contained in:
parent
959d1e735f
commit
736bcb8e4d
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||||
description = "A wip universal Linux settings application."
|
description = "A wip universal Linux settings application."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
reset_daemon = "0.3.3"
|
reset_daemon = "0.3.6"
|
||||||
ReSet-Lib = "0.6.1"
|
ReSet-Lib = "0.6.1"
|
||||||
adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] }
|
adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] }
|
||||||
dbus = "0.9.7"
|
dbus = "0.9.7"
|
||||||
|
|
|
@ -158,4 +158,3 @@ fn setRowName(selfImp: &WifiAddressEntryImpl) {
|
||||||
};
|
};
|
||||||
selfImp.resetAddressRow.set_title(&title);
|
selfImp.resetAddressRow.set_title(&title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use crate::components::wifi::wifiBox;
|
use crate::components::wifi::wifiBox;
|
||||||
use ReSet_Lib::network::network::WifiDevice;
|
|
||||||
use adw::{ActionRow, ComboRow, NavigationView, PreferencesGroup};
|
use adw::{ActionRow, ComboRow, NavigationView, PreferencesGroup};
|
||||||
use dbus::Path;
|
use dbus::Path;
|
||||||
use gtk::{prelude::*, StringList};
|
|
||||||
use gtk::subclass::prelude::*;
|
use gtk::subclass::prelude::*;
|
||||||
use gtk::{glib, CompositeTemplate, Switch};
|
use gtk::{glib, CompositeTemplate, Switch};
|
||||||
|
use gtk::{prelude::*, StringList};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::{Arc, Mutex, RwLock};
|
use std::sync::{Arc, Mutex, RwLock};
|
||||||
|
use ReSet_Lib::network::network::WifiDevice;
|
||||||
|
|
||||||
use crate::components::base::listEntry::ListEntry;
|
use crate::components::base::listEntry::ListEntry;
|
||||||
use crate::components::wifi::wifiEntry::WifiEntry;
|
use crate::components::wifi::wifiEntry::WifiEntry;
|
||||||
|
@ -35,7 +35,7 @@ pub struct WifiBox {
|
||||||
pub wifiEntries: Arc<Mutex<HashMap<Vec<u8>, Arc<WifiEntry>>>>,
|
pub wifiEntries: Arc<Mutex<HashMap<Vec<u8>, Arc<WifiEntry>>>>,
|
||||||
pub wifiEntriesPath: Arc<Mutex<HashMap<Path<'static>, Arc<WifiEntry>>>>,
|
pub wifiEntriesPath: Arc<Mutex<HashMap<Path<'static>, Arc<WifiEntry>>>>,
|
||||||
pub savedWifiEntries: Arc<Mutex<Vec<ListEntry>>>,
|
pub savedWifiEntries: Arc<Mutex<Vec<ListEntry>>>,
|
||||||
pub resetWifiDevices: Arc<RwLock<HashMap<String, (WifiDevice,u32)>>>,
|
pub resetWifiDevices: Arc<RwLock<HashMap<String, (WifiDevice, u32)>>>,
|
||||||
pub resetCurrentWifiDevice: Arc<RefCell<WifiDevice>>,
|
pub resetCurrentWifiDevice: Arc<RefCell<WifiDevice>>,
|
||||||
pub resetModelList: Arc<RwLock<StringList>>,
|
pub resetModelList: Arc<RwLock<StringList>>,
|
||||||
pub resetModelIndex: Arc<RwLock<u32>>,
|
pub resetModelIndex: Arc<RwLock<u32>>,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use std::sync::atomic::AtomicBool;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use adw::subclass::prelude::ActionRowImpl;
|
||||||
use adw::ActionRow;
|
use adw::ActionRow;
|
||||||
use gtk::subclass::prelude::*;
|
use gtk::subclass::prelude::*;
|
||||||
use gtk::{glib, Button, CompositeTemplate, Image, Label};
|
use gtk::{glib, Button, CompositeTemplate, Image, Label};
|
||||||
use std::cell::{RefCell, Cell};
|
use std::cell::RefCell;
|
||||||
use ReSet_Lib::network::network::{AccessPoint, WifiStrength};
|
use ReSet_Lib::network::network::{AccessPoint, WifiStrength};
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
pub mod handleSidebarClick;
|
pub mod handleSidebarClick;
|
||||||
|
pub mod resetWindow;
|
||||||
|
pub mod resetWindowImpl;
|
||||||
pub mod sidebarEntry;
|
pub mod sidebarEntry;
|
||||||
pub mod sidebarEntryImpl;
|
pub mod sidebarEntryImpl;
|
||||||
pub mod window;
|
|
||||||
pub mod windowImpl;
|
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
use adw::BreakpointCondition;
|
|
||||||
use adw::glib::clone;
|
use adw::glib::clone;
|
||||||
use adw::subclass::prelude::ObjectSubclassIsExt;
|
use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||||
|
use adw::BreakpointCondition;
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use gtk::{Application, gio, glib, ListBoxRow, Orientation};
|
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
use gtk::{gio, glib, Application, ListBoxRow, Orientation};
|
||||||
|
|
||||||
use crate::components::window::handleSidebarClick::*;
|
use crate::components::window::handleSidebarClick::*;
|
||||||
|
use crate::components::window::resetWindowImpl;
|
||||||
use crate::components::window::sidebarEntry::SidebarEntry;
|
use crate::components::window::sidebarEntry::SidebarEntry;
|
||||||
use crate::components::window::sidebarEntryImpl::Categories;
|
use crate::components::window::sidebarEntryImpl::Categories;
|
||||||
use crate::components::window::windowImpl;
|
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
pub struct Window(ObjectSubclass<windowImpl::Window>)
|
pub struct ReSetWindow(ObjectSubclass<resetWindowImpl::ReSetWindow>)
|
||||||
@extends gtk::ApplicationWindow, gtk::Window, gtk::Widget,
|
@extends gtk::ApplicationWindow, gtk::Window, gtk::Widget,
|
||||||
@implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable,
|
@implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable,
|
||||||
gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
|
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)]
|
#[allow(non_snake_case)]
|
||||||
impl Window {
|
impl ReSetWindow {
|
||||||
pub fn new(app: &Application) -> Self {
|
pub fn new(app: &Application) -> Self {
|
||||||
Object::builder().property("application", app).build()
|
Object::builder().property("application", app).build()
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,15 @@ impl Window {
|
||||||
pub fn setupCallback(&self) {
|
pub fn setupCallback(&self) {
|
||||||
let selfImp = self.imp();
|
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();
|
window.filterList();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
selfImp.resetSideBarToggle.connect_clicked(clone!(@ weak self as window => move |_| {
|
selfImp
|
||||||
|
.resetSideBarToggle
|
||||||
|
.connect_clicked(clone!(@ weak self as window => move |_| {
|
||||||
window.toggleSidebar();
|
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();
|
window.close();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -58,7 +64,9 @@ impl Window {
|
||||||
|
|
||||||
pub fn handleDynamicSidebar(&self) {
|
pub fn handleDynamicSidebar(&self) {
|
||||||
let selfImp = self.imp();
|
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(
|
selfImp.resetSidebarBreakpoint.add_setter(
|
||||||
&Object::from(selfImp.resetOverlaySplitView.get()),
|
&Object::from(selfImp.resetOverlaySplitView.get()),
|
||||||
"collapsed",
|
"collapsed",
|
||||||
|
@ -81,13 +89,25 @@ impl Window {
|
||||||
}
|
}
|
||||||
continue;
|
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);
|
mainEntry.set_visible(true);
|
||||||
} else {
|
} else {
|
||||||
mainEntry.set_visible(false);
|
mainEntry.set_visible(false);
|
||||||
}
|
}
|
||||||
for subEntry in subEntries {
|
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);
|
subEntry.set_visible(true);
|
||||||
mainEntry.set_visible(true);
|
mainEntry.set_visible(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -207,9 +227,11 @@ impl Window {
|
||||||
// peripheralsList,
|
// peripheralsList,
|
||||||
// ));
|
// ));
|
||||||
|
|
||||||
selfImp.resetSidebarList.connect_row_activated(clone!(@ weak selfImp => move |_, _| {
|
selfImp
|
||||||
selfImp.resetSearchEntry.set_text("");
|
.resetSidebarList
|
||||||
}));
|
.connect_row_activated(clone!(@ weak selfImp => move |_, _| {
|
||||||
|
selfImp.resetSearchEntry.set_text("");
|
||||||
|
}));
|
||||||
|
|
||||||
for (mainEntry, subEntries) in sidebarEntries.iter() {
|
for (mainEntry, subEntries) in sidebarEntries.iter() {
|
||||||
selfImp.resetSidebarList.append(mainEntry);
|
selfImp.resetSidebarList.append(mainEntry);
|
||||||
|
@ -226,7 +248,9 @@ impl Window {
|
||||||
|
|
||||||
pub fn setupPopoverButtons(&self) {
|
pub fn setupPopoverButtons(&self) {
|
||||||
let selfImp = self.imp();
|
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()
|
let dialog = adw::AboutWindow::builder()
|
||||||
.application_name("ReSet")
|
.application_name("ReSet")
|
||||||
.application_icon("ReSet")
|
.application_icon("ReSet")
|
||||||
|
@ -245,12 +269,16 @@ impl Window {
|
||||||
window.imp().resetPopoverMenu.popdown();
|
window.imp().resetPopoverMenu.popdown();
|
||||||
dialog.present();
|
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();
|
let preferences = adw::PreferencesWindow::builder().build();
|
||||||
window.imp().resetPopoverMenu.popdown();
|
window.imp().resetPopoverMenu.popdown();
|
||||||
preferences.present();
|
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();
|
let shortcuts = gtk::ShortcutsWindow::builder().build();
|
||||||
window.imp().resetPopoverMenu.popdown();
|
window.imp().resetPopoverMenu.popdown();
|
||||||
shortcuts.present();
|
shortcuts.present();
|
|
@ -10,13 +10,13 @@ use gtk::{glib, Button, CompositeTemplate, FlowBox, ListBox, PopoverMenu, Search
|
||||||
|
|
||||||
use crate::components::base::utils::Listeners;
|
use crate::components::base::utils::Listeners;
|
||||||
use crate::components::wifi::wifiBox::WifiBox;
|
use crate::components::wifi::wifiBox::WifiBox;
|
||||||
|
use crate::components::window::resetWindow;
|
||||||
use crate::components::window::sidebarEntry::SidebarEntry;
|
use crate::components::window::sidebarEntry::SidebarEntry;
|
||||||
use crate::components::window::window;
|
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[derive(CompositeTemplate, Default)]
|
#[derive(CompositeTemplate, Default)]
|
||||||
#[template(resource = "/org/Xetibo/ReSet/resetMainWindow.ui")]
|
#[template(resource = "/org/Xetibo/ReSet/resetMainWindow.ui")]
|
||||||
pub struct Window {
|
pub struct ReSetWindow {
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub resetMain: TemplateChild<FlowBox>,
|
pub resetMain: TemplateChild<FlowBox>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
|
@ -43,14 +43,14 @@ pub struct Window {
|
||||||
pub listeners: Arc<Listeners>,
|
pub listeners: Arc<Listeners>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for Window {}
|
unsafe impl Send for ReSetWindow {}
|
||||||
unsafe impl Sync for Window {}
|
unsafe impl Sync for ReSetWindow {}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
impl ObjectSubclass for Window {
|
impl ObjectSubclass for ReSetWindow {
|
||||||
const ABSTRACT: bool = false;
|
const ABSTRACT: bool = false;
|
||||||
const NAME: &'static str = "resetUI";
|
const NAME: &'static str = "resetUI";
|
||||||
type Type = window::Window;
|
type Type = resetWindow::ReSetWindow;
|
||||||
type ParentType = adw::ApplicationWindow;
|
type ParentType = adw::ApplicationWindow;
|
||||||
|
|
||||||
fn class_init(klass: &mut Self::Class) {
|
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) {
|
fn constructed(&self) {
|
||||||
self.parent_constructed();
|
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 {}
|
|
@ -3,6 +3,7 @@
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use components::window::resetWindow::ReSetWindow;
|
||||||
use dbus::blocking::Connection;
|
use dbus::blocking::Connection;
|
||||||
use dbus::Error;
|
use dbus::Error;
|
||||||
use gtk::gdk::Display;
|
use gtk::gdk::Display;
|
||||||
|
@ -10,8 +11,6 @@ use gtk::prelude::*;
|
||||||
use gtk::{gio, Application, CssProvider};
|
use gtk::{gio, Application, CssProvider};
|
||||||
use reset_daemon::run_daemon;
|
use reset_daemon::run_daemon;
|
||||||
|
|
||||||
use crate::components::window::window::Window;
|
|
||||||
|
|
||||||
mod components;
|
mod components;
|
||||||
|
|
||||||
const APP_ID: &str = "org.Xetibo.ReSet";
|
const APP_ID: &str = "org.Xetibo.ReSet";
|
||||||
|
@ -49,7 +48,7 @@ fn loadCss() {
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
fn buildUI(app: &Application) {
|
fn buildUI(app: &Application) {
|
||||||
let window = Window::new(app);
|
let window = ReSetWindow::new(app);
|
||||||
window.present();
|
window.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue