From eed10e8b635afa42d997bf44da179d96163feaf6 Mon Sep 17 00:00:00 2001 From: Fabio Lenherr / DashieTM Date: Wed, 22 Nov 2023 17:50:12 +0100 Subject: [PATCH 1/5] feat: Improve Wifi event handling --- Cargo.toml | 2 +- src/components/base/utils.rs | 1 + src/components/wifi/wifiBox.rs | 235 ++++++++++---------- src/components/wifi/wifiBoxImpl.rs | 4 +- src/components/wifi/wifiEntry.rs | 38 ++-- src/components/window/handleSidebarClick.rs | 8 +- 6 files changed, 156 insertions(+), 132 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6cbd864..11543fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ description = "A wip universal Linux settings application." [dependencies] reset_daemon = "0.2.3" -ReSet-Lib = "0.4.0" +ReSet-Lib = "0.4.6" adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] } dbus = "0.9.7" gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] } diff --git a/src/components/base/utils.rs b/src/components/base/utils.rs index 6e12d15..0e5ea4d 100644 --- a/src/components/base/utils.rs +++ b/src/components/base/utils.rs @@ -402,6 +402,7 @@ pub fn start_audio_listener( } listeners.pulse_listener.store(true, Ordering::SeqCst); + println!("starting audio listener"); loop { let _ = conn.process(Duration::from_millis(1000)); diff --git a/src/components/wifi/wifiBox.rs b/src/components/wifi/wifiBox.rs index c7d0349..b8a4a0c 100644 --- a/src/components/wifi/wifiBox.rs +++ b/src/components/wifi/wifiBox.rs @@ -14,15 +14,16 @@ use adw::prelude::{ListBoxRowExt, PreferencesGroupExt}; use adw::subclass::prelude::ObjectSubclassIsExt; use dbus::arg::{AppendAll, ReadAll, RefArg}; use dbus::blocking::Connection; +use dbus::message::SignalArgs; use dbus::Error; use dbus::Path; -use glib::ObjectExt; +use glib::{ObjectExt, PropertySet}; use gtk::gio; use gtk::glib::Variant; -use gtk::prelude::ActionableExt; -use ReSet_Lib::network::network::AccessPoint; -use ReSet_Lib::signals::AccessPointRemoved; +use gtk::prelude::{ActionableExt, WidgetExt}; +use ReSet_Lib::network::network::{AccessPoint, WifiStrength}; use ReSet_Lib::signals::{AccessPointAdded, GetVal}; +use ReSet_Lib::signals::{AccessPointChanged, AccessPointRemoved}; use ReSet_Lib::utils::Events; use crate::components::wifi::wifiBoxImpl; @@ -66,89 +67,28 @@ pub fn scanForWifi(listeners: Arc, wifiBox: Arc) { let wifibox_ref = wifiBox.clone(); let wifibox_ref_listener = wifiBox.clone(); let wifiEntries = wifiBox.imp().wifiEntries.clone(); + let wifiEntriesPath = wifiBox.imp().wifiEntriesPath.clone(); gio::spawn_blocking(move || { let accessPoints = get_access_points(); - let wifiEntriesListener = wifiEntries.clone(); let wifiEntries = wifiEntries.clone(); + let wifiEntriesPath = wifiEntriesPath.clone(); + dbus_start_network_events(); glib::spawn_future(async move { glib::idle_add_once(move || { let mut wifiEntries = wifiEntries.lock().unwrap(); + let mut wifiEntriesPath = wifiEntriesPath.lock().unwrap(); let selfImp = wifibox_ref.imp(); for accessPoint in accessPoints { let ssid = accessPoint.ssid.clone(); + let path = accessPoint.dbus_path.clone(); let entry = WifiEntry::new(accessPoint, selfImp); wifiEntries.insert(ssid, entry.clone()); + wifiEntriesPath.insert(path, entry.clone()); selfImp.resetWifiList.add(&*entry); } }); }); - if listeners.network_listener.load(Ordering::SeqCst) { - return; - } - listeners.network_listener.store(true, Ordering::SeqCst); - dbus_start_network_events(); - let (sender, receiver): ( - Sender>, - Receiver>, - ) = channel(); - let sender_ref = Arc::new(sender); - let res = start_event_listener::< - (AccessPoint,), - (AccessPoint,), - AccessPointAdded, - AccessPointRemoved, - >(listeners.clone(), sender_ref); - if res.is_err() { - println!("Could not connect listener"); - } - loop { - let wifiEntriesListener = wifiEntriesListener.clone(); - if listeners - .network_listener - .load(std::sync::atomic::Ordering::SeqCst) - == false - { - break; - } - let res = receiver.recv(); - if res.is_ok() { - let access_point = res.unwrap(); - match access_point { - Events::AddedEvent(access_point) => { - let wifiEntriesListener = wifiEntriesListener.clone(); - let wifiBoxImpl = wifibox_ref_listener.clone(); - glib::spawn_future(async move { - glib::idle_add_once(move || { - let mut wifiEntries = wifiEntriesListener.lock().unwrap(); - let ssid = access_point.0.ssid.clone(); - if wifiEntries.get(&ssid).is_some() { - return; - } - let entry = WifiEntry::new(access_point.0, wifiBoxImpl.imp()); - wifiEntries.insert(ssid, entry.clone()); - wifiBoxImpl.imp().resetWifiList.add(&*entry); - }); - }); - } - Events::RemovedEvent(access_point) => { - let wifiBoxImpl = wifibox_ref_listener.clone(); - glib::spawn_future(async move { - glib::idle_add_once(move || { - let mut wifiEntries = wifiEntriesListener.lock().unwrap(); - let entry = wifiEntries.remove(&access_point.0.ssid); - if entry.is_none() { - return; - } - wifiBoxImpl.imp().resetWifiList.remove(&*entry.unwrap()); - }); - }); - } - }; - } else { - println!("no message there :)"); - } - } }); } @@ -236,75 +176,146 @@ pub fn getConnectionSettings(path: Path<'static>) -> ResetConnection { res.unwrap() } -// temporary, testing this with lib is pain -// +pub fn start_event_listener(listeners: Arc, wifi_box: Arc) { + gio::spawn_blocking(move || { + if listeners.network_listener.load(Ordering::SeqCst) { + return; + } + listeners.network_listener.store(true, Ordering::SeqCst); -pub fn start_event_listener< - AddedType: ReadAll + AppendAll + Send + Sync + 'static, - RemovedType: ReadAll + AppendAll + Send + Sync + 'static, - AddedEvent: ReadAll + AppendAll + dbus::message::SignalArgs + GetVal, - RemovedEvent: ReadAll + AppendAll + dbus::message::SignalArgs + GetVal, ->( - listeners: Arc, - sender: Arc>>, -) -> Result<(), dbus::Error> { - thread::spawn(move || { - let added_sender = sender.clone(); - let removed_sender = sender.clone(); let conn = Connection::new_session().unwrap(); - let mr = AddedEvent::match_rule( + let added_ref = wifi_box.clone(); + let removed_ref = wifi_box.clone(); + let changed_ref = wifi_box.clone(); // TODO implement changed + let access_point_added = AccessPointAdded::match_rule( Some(&"org.xetibo.ReSet".into()), Some(&Path::from("/org/xetibo/ReSet")), ) .static_clone(); - let mrb = RemovedEvent::match_rule( + let access_point_removed = AccessPointRemoved::match_rule( Some(&"org.xetibo.ReSet".into()), Some(&Path::from("/org/xetibo/ReSet")), ) .static_clone(); - let res = conn.add_match(mr, move |ir: AddedEvent, _, _| { + let access_point_changed = AccessPointChanged::match_rule( + Some(&"org.xetibo.ReSet".into()), + Some(&Path::from("/org/xetibo/ReSet")), + ) + .static_clone(); + let res = conn.add_match(access_point_added, move |ir: AccessPointAdded, _, _| { println!("received added event"); - let res = added_sender.send(Events::AddedEvent(ir.get_value())); - if res.is_err() { - println!("fail on sending added"); - return false; - } + // TODO handle add + let wifi_box = added_ref.clone(); + glib::spawn_future(async move { + glib::idle_add_once(move || { + let imp = wifi_box.imp(); + let mut wifiEntries = imp.wifiEntries.lock().unwrap(); + let mut wifiEntriesPath = imp.wifiEntriesPath.lock().unwrap(); + let ssid = ir.access_point.ssid.clone(); + let path = ir.access_point.dbus_path.clone(); + if wifiEntries.get(&ssid).is_some() { + return; + } + let entry = WifiEntry::new(ir.access_point, imp); + wifiEntries.insert(ssid, entry.clone()); + wifiEntriesPath.insert(path, entry.clone()); + imp.resetWifiList.add(&*entry); + }); + }); true }); if res.is_err() { println!("fail on add"); - return Err(dbus::Error::new_custom( - "SignalMatchFailed", - "Failed to match signal on ReSet.", - )); + return; } - let res = conn.add_match(mrb, move |ir: RemovedEvent, _, _| { + let res = conn.add_match(access_point_removed, move |ir: AccessPointRemoved, _, _| { println!("received removed event"); - let res = removed_sender.send(Events::RemovedEvent(ir.get_value())); - if res.is_err() { - println!("fail on sending removed"); - return false; - } + // TODO handle remove + let wifi_box = removed_ref.clone(); + glib::spawn_future(async move { + glib::idle_add_once(move || { + let imp = wifi_box.imp(); + let mut wifiEntries = imp.wifiEntries.lock().unwrap(); + let mut wifiEntriesPath = imp.wifiEntriesPath.lock().unwrap(); + let entry = wifiEntriesPath.remove(&ir.access_point); + if entry.is_none() { + return; + } + let entry = entry.unwrap(); + let ssid = entry.imp().accessPoint.borrow().ssid.clone(); + wifiEntries.remove(&ssid); + imp.resetWifiList.remove(&*entry); + }); + }); true }); if res.is_err() { println!("fail on remove"); - return Err(dbus::Error::new_custom( - "SignalMatchFailed", - "Failed to match signal on ReSet.", - )); + return; + } + let res = conn.add_match(access_point_changed, move |ir: AccessPointChanged, _, _| { + println!("received changed event"); + dbg!(ir.access_point.clone()); + let wifi_box = changed_ref.clone(); + glib::spawn_future(async move { + glib::idle_add_local_once(move || { + let imp = wifi_box.imp(); + let wifiEntries = imp.wifiEntries.lock().unwrap(); + let entry = wifiEntries.get(&ir.access_point.ssid); + if entry.is_none() { + return; + } + let entry = entry.unwrap(); + let entryImp = entry.imp(); + let strength = WifiStrength::from_u8(ir.access_point.strength); + let ssid = ir.access_point.ssid.clone(); + let name_opt = String::from_utf8(ssid).unwrap_or_else(|_| String::from("")); + let name = name_opt.as_str(); + entryImp.wifiStrength.set(strength); + entryImp.resetWifiLabel.get().set_text(name); + entryImp.resetWifiEncrypted.set_visible(false); + // TODO handle encryption thing + entryImp + .resetWifiStrength + .get() + .set_from_icon_name(match strength { + WifiStrength::Excellent => { + Some("network-wireless-signal-excellent-symbolic") + } + WifiStrength::Ok => Some("network-wireless-signal-ok-symbolic"), + WifiStrength::Weak => Some("network-wireless-signal-weak-symbolic"), + WifiStrength::None => Some("network-wireless-signal-none-symbolic"), + }); + if !ir.access_point.stored { + entryImp.resetWifiEditButton.set_sensitive(false); + } + if ir.access_point.connected { + entryImp + .resetWifiConnected + .get() + .set_from_icon_name(Some("network-wireless-connected-symbolic")); + } else { + entryImp.resetWifiConnected.get().set_from_icon_name(None); + } + { + let mut wifiName = entryImp.wifiName.borrow_mut(); + *wifiName = String::from(name); + } + }); + }); + true + }); + if res.is_err() { + println!("fail on change"); + return; } - listeners.network_listener.store(true, Ordering::SeqCst); println!("starting thread listener"); loop { - let _ = conn.process(Duration::from_millis(1000))?; + let _ = conn.process(Duration::from_millis(1000)); if !listeners.network_listener.load(Ordering::SeqCst) { println!("stopping thread listener"); break; } - thread::sleep(Duration::from_millis(1000)); } - Ok(()) }); - Ok(()) } diff --git a/src/components/wifi/wifiBoxImpl.rs b/src/components/wifi/wifiBoxImpl.rs index a4e3030..6263d2d 100644 --- a/src/components/wifi/wifiBoxImpl.rs +++ b/src/components/wifi/wifiBoxImpl.rs @@ -1,10 +1,11 @@ use crate::components::wifi::wifiBox; +use adw::{ActionRow, ComboRow, NavigationView, PreferencesGroup}; +use dbus::Path; use gtk::prelude::*; use gtk::subclass::prelude::*; use gtk::{glib, CompositeTemplate, ListBox, Switch}; use std::collections::HashMap; use std::sync::{Arc, Mutex}; -use adw::{ActionRow, ComboRow, NavigationView, PreferencesGroup}; use crate::components::base::listEntry::ListEntry; use crate::components::wifi::wifiEntry::WifiEntry; @@ -30,6 +31,7 @@ pub struct WifiBox { #[template_child] pub resetAvailableNetworks: TemplateChild, pub wifiEntries: Arc, Arc>>>, + pub wifiEntriesPath: Arc, Arc>>>, pub savedWifiEntries: Arc>>, } diff --git a/src/components/wifi/wifiEntry.rs b/src/components/wifi/wifiEntry.rs index 87d09da..9a45cde 100644 --- a/src/components/wifi/wifiEntry.rs +++ b/src/components/wifi/wifiEntry.rs @@ -13,9 +13,9 @@ use gtk::prelude::{ListBoxRowExt, WidgetExt}; use gtk::{gio, AlertDialog, GestureClick}; use ReSet_Lib::network::network::{AccessPoint, WifiStrength}; -use crate::components::wifi::{wifiEntryImpl}; use crate::components::wifi::wifiBox::getConnectionSettings; use crate::components::wifi::wifiBoxImpl::WifiBox; +use crate::components::wifi::wifiEntryImpl; use crate::components::wifi::wifiOptions::WifiOptions; use super::savedWifiEntry::SavedWifiEntry; @@ -71,7 +71,7 @@ impl WifiEntry { entry.connect_activated(clone!(@weak entryImp => move |_| { let access_point = entryImp.accessPoint.borrow(); if access_point.connected { - click_disconnect(); + click_disconnect(stored_entry.clone()); } else if access_point.stored { click_stored_network(stored_entry.clone()); } else { @@ -91,8 +91,9 @@ impl WifiEntry { } } -pub fn click_disconnect() { +pub fn click_disconnect(entry: Arc) { println!("called disconnect"); + let entry_ref = entry.clone(); gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( @@ -106,7 +107,10 @@ pub fn click_disconnect() { println!("res of disconnect was error bro"); return; } - println!("disconnect worked"); + let imp = entry_ref.imp(); + imp.resetWifiConnected.get().set_from_icon_name(None); + imp.accessPoint.borrow_mut().connected = false; + println!("disconnect worked"); }); } pub fn click_stored_network(entry: Arc) { @@ -114,11 +118,6 @@ pub fn click_stored_network(entry: Arc) { let entryImp = entry.imp(); let access_point = entryImp.accessPoint.borrow().clone(); let entry_ref = entry.clone(); - let popup = entry.imp().resetWifiPopup.imp(); - popup.resetPopupLabel.set_text("Connecting..."); - popup.resetPopupLabel.set_visible(true); - popup.resetPopupEntry.set_sensitive(false); - popup.resetPopupButton.set_sensitive(false); gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); @@ -135,20 +134,22 @@ pub fn click_stored_network(entry: Arc) { glib::spawn_future(async move { glib::idle_add_once(move || { let imp = entry_ref.imp(); - let popup = imp.resetWifiPopup.imp(); if res.is_err() { - popup.resetPopupLabel.set_text("Could not connect to dbus."); + println!("wat bro?"); result.store(false, std::sync::atomic::Ordering::SeqCst); return; } if res.unwrap() == (false,) { - popup - .resetPopupLabel - .set_text("Could not connect to access point."); + println!("error bro?"); result.store(false, std::sync::atomic::Ordering::SeqCst); return; } - entry_ref.imp().resetWifiPopup.popdown(); + let imp = entry_ref.imp(); + println!("wateroni"); + imp.resetWifiConnected + .get() + .set_from_icon_name(Some("network-wireless-connected-symbolic")); + imp.accessPoint.borrow_mut().connected = true; result.store(true, std::sync::atomic::Ordering::SeqCst); }); }); @@ -205,7 +206,12 @@ pub fn click_new_network(entry: Arc) { return; } println!("worked?"); - entry_ref.imp().resetWifiPopup.popdown(); + let imp = entry_ref.imp(); + imp.resetWifiPopup.popdown(); + imp.resetWifiEditButton.set_sensitive(true); + imp.resetWifiConnected + .get() + .set_from_icon_name(Some("network-wireless-connected-symbolic")); result.store(true, std::sync::atomic::Ordering::SeqCst); }); }); diff --git a/src/components/window/handleSidebarClick.rs b/src/components/window/handleSidebarClick.rs index 5352c31..0505660 100644 --- a/src/components/window/handleSidebarClick.rs +++ b/src/components/window/handleSidebarClick.rs @@ -1,13 +1,15 @@ use gtk::prelude::FrameExt; -use std::sync::Arc; use std::sync::atomic::Ordering; +use std::sync::Arc; use crate::components::base::settingBox::SettingBox; use crate::components::base::utils::{start_audio_listener, Listeners}; use crate::components::bluetooth::bluetoothBox::{start_bluetooth_listener, BluetoothBox}; use crate::components::input::sourceBox::{populate_sources, SourceBox}; use crate::components::output::sinkBox::{populate_sinks, SinkBox}; -use crate::components::wifi::wifiBox::{scanForWifi, show_stored_connections, WifiBox}; +use crate::components::wifi::wifiBox::{ + scanForWifi, show_stored_connections, start_event_listener, WifiBox, +}; use gtk::prelude::WidgetExt; use gtk::{FlowBox, Frame, Label}; @@ -15,6 +17,7 @@ pub const HANDLE_CONNECTIVITY_CLICK: fn(Arc, FlowBox) = |listeners: Arc, resetMain: FlowBox| { listeners.stop_audio_listener(); let wifiBox = Arc::new(WifiBox::new()); + start_event_listener(listeners.clone(), wifiBox.clone()); show_stored_connections(wifiBox.clone()); scanForWifi(listeners.clone(), wifiBox.clone()); let wifiFrame = wrapInFrame(SettingBox::new(&*wifiBox)); @@ -32,6 +35,7 @@ pub const HANDLE_WIFI_CLICK: fn(Arc, FlowBox) = listeners.stop_audio_listener(); listeners.stop_bluetooth_listener(); let wifiBox = Arc::new(WifiBox::new()); + start_event_listener(listeners.clone(), wifiBox.clone()); show_stored_connections(wifiBox.clone()); scanForWifi(listeners.clone(), wifiBox.clone()); let wifiFrame = wrapInFrame(SettingBox::new(&*wifiBox)); From e1cd11e601bdf3d1f83de3a790fe67fa4209ed0b Mon Sep 17 00:00:00 2001 From: Fabio Lenherr / DashieTM Date: Thu, 23 Nov 2023 10:23:51 +0100 Subject: [PATCH 2/5] chore: Code cleanup --- Cargo.toml | 2 +- src/components/base/cardEntry.rs | 2 +- src/components/base/utils.rs | 10 +++++----- src/components/bluetooth/bluetoothBox.rs | 2 +- src/components/input/outputStreamEntry.rs | 2 +- src/components/input/sourceBox.rs | 6 +++--- src/components/input/sourceBoxImpl.rs | 2 +- src/components/input/sourceEntry.rs | 2 +- src/components/output/inputStreamEntry.rs | 2 +- src/components/output/sinkBox.rs | 4 ++-- src/components/output/sinkBoxImpl.rs | 2 +- src/components/output/sinkEntry.rs | 2 +- src/components/wifi/wifiAddressEntry.rs | 6 +++--- src/components/wifi/wifiBox.rs | 18 +++++++++--------- src/components/wifi/wifiBoxImpl.rs | 2 +- src/components/wifi/wifiEntry.rs | 10 +++++----- src/components/wifi/wifiOptions.rs | 20 ++++++++++---------- src/components/wifi/wifiRouteEntry.rs | 10 +++++----- src/components/window/handleSidebarClick.rs | 2 +- src/components/window/window.rs | 2 +- src/components/window/windowImpl.rs | 2 +- 21 files changed, 55 insertions(+), 55 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 11543fe..8289c2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" description = "A wip universal Linux settings application." [dependencies] -reset_daemon = "0.2.3" +reset_daemon = "0.2.4" ReSet-Lib = "0.4.6" adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] } dbus = "0.9.7" diff --git a/src/components/base/cardEntry.rs b/src/components/base/cardEntry.rs index 4ecb67e..6f0ce9d 100644 --- a/src/components/base/cardEntry.rs +++ b/src/components/base/cardEntry.rs @@ -5,7 +5,7 @@ use adw::glib::Object; use adw::prelude::{ComboRowExt, PreferencesRowExt}; use dbus::blocking::Connection; use dbus::Error; -use glib::{Cast, clone, ObjectExt, ToValue}; +use glib::{Cast, clone, ObjectExt}; use glib::subclass::types::ObjectSubclassIsExt; use gtk::{Align, gio, SignalListItemFactory, StringList, StringObject}; use gtk::prelude::{GObjectPropertyExpressionExt, ListItemExt, WidgetExt}; diff --git a/src/components/base/utils.rs b/src/components/base/utils.rs index 0e5ea4d..c9cb5ff 100644 --- a/src/components/base/utils.rs +++ b/src/components/base/utils.rs @@ -137,7 +137,7 @@ impl dbus::message::SignalArgs for SinkRemoved { impl GetVal<(u32,)> for SinkRemoved { fn get_value(&self) -> (u32,) { - (self.index.clone(),) + (self.index,) } } @@ -215,7 +215,7 @@ impl dbus::message::SignalArgs for InputStreamRemoved { impl GetVal<(u32,)> for InputStreamRemoved { fn get_value(&self) -> (u32,) { - (self.index.clone(),) + (self.index,) } } @@ -299,7 +299,7 @@ impl dbus::message::SignalArgs for SourceRemoved { impl GetVal<(u32,)> for SourceRemoved { fn get_value(&self) -> (u32,) { - (self.index.clone(),) + (self.index,) } } @@ -377,7 +377,7 @@ impl dbus::message::SignalArgs for OutputStreamRemoved { impl GetVal<(u32,)> for OutputStreamRemoved { fn get_value(&self) -> (u32,) { - (self.index.clone(),) + (self.index,) } } @@ -387,7 +387,7 @@ pub fn start_audio_listener( source_box: Option>, ) { gio::spawn_blocking(move || { - let mut conn = Connection::new_session().unwrap(); + let conn = Connection::new_session().unwrap(); if listeners.pulse_listener.load(Ordering::SeqCst) { return; } diff --git a/src/components/bluetooth/bluetoothBox.rs b/src/components/bluetooth/bluetoothBox.rs index f2e0872..c03037d 100644 --- a/src/components/bluetooth/bluetoothBox.rs +++ b/src/components/bluetooth/bluetoothBox.rs @@ -166,7 +166,7 @@ pub fn start_bluetooth_listener(listeners: Arc, bluetooth_box: Arc) { let default_sink = output_box_imp.resetDefaultSource.clone(); let source = default_sink.borrow(); - let volume = source.volume.first().unwrap_or_else(|| &(0 as u32)); + let volume = source.volume.first().unwrap_or(&0_u32); let fraction = (*volume as f64 / 655.36).round(); let percentage = (fraction).to_string() + "%"; output_box_imp.resetVolumePercentage.set_text(&percentage); @@ -441,7 +441,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc) -> let output_box = source_box.clone(); let output_box_imp = output_box.imp(); let is_default = ir.source.name == default_source.name; - let volume = ir.source.volume.first().unwrap_or_else(|| &(0 as u32)); + let volume = ir.source.volume.first().unwrap_or(&0_u32); let fraction = (*volume as f64 / 655.36).round(); let percentage = (fraction).to_string() + "%"; let list = output_box_imp.resetSourceList.read().unwrap(); @@ -531,7 +531,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc) -> } let name = ir.stream.application_name.clone() + ": " + ir.stream.name.as_str(); imp.resetSourceName.set_text(name.as_str()); - let volume = ir.stream.volume.first().unwrap_or_else(|| &(0 as u32)); + let volume = ir.stream.volume.first().unwrap_or(&0_u32); let fraction = (*volume as f64 / 655.36).round(); let percentage = (fraction).to_string() + "%"; imp.resetVolumePercentage.set_text(&percentage); diff --git a/src/components/input/sourceBoxImpl.rs b/src/components/input/sourceBoxImpl.rs index cc29a0d..4209436 100644 --- a/src/components/input/sourceBoxImpl.rs +++ b/src/components/input/sourceBoxImpl.rs @@ -7,7 +7,7 @@ use adw::{ActionRow, ComboRow, PreferencesGroup}; use crate::components::base::listEntry::ListEntry; use crate::components::input::sourceBox; use gtk::subclass::prelude::*; -use gtk::{glib, CheckButton, CompositeTemplate, DropDown, StringList, TemplateChild}; +use gtk::{glib, CheckButton, CompositeTemplate, StringList, TemplateChild}; use gtk::{prelude::*, Button, Label, ProgressBar, Scale}; use ReSet_Lib::audio::audio::Source; diff --git a/src/components/input/sourceEntry.rs b/src/components/input/sourceEntry.rs index f8dd676..f22eff4 100644 --- a/src/components/input/sourceEntry.rs +++ b/src/components/input/sourceEntry.rs @@ -30,7 +30,7 @@ impl SourceEntry { let imp = obj.imp(); imp.resetSourceName.set_text(stream.alias.clone().as_str()); let name = Arc::new(stream.name.clone()); - let volume = stream.volume.first().unwrap_or_else(|| &(0 as u32)); + let volume = stream.volume.first().unwrap_or(&0_u32); let fraction = (*volume as f64 / 655.36).round(); let percentage = (fraction).to_string() + "%"; imp.resetVolumePercentage.set_text(&percentage); diff --git a/src/components/output/inputStreamEntry.rs b/src/components/output/inputStreamEntry.rs index 3c80f5b..e8cd95d 100644 --- a/src/components/output/inputStreamEntry.rs +++ b/src/components/output/inputStreamEntry.rs @@ -37,7 +37,7 @@ impl InputStreamEntry { } let name = stream.application_name.clone() + ": " + stream.name.as_str(); imp.resetSinkName.set_text(name.as_str()); - let volume = stream.volume.first().unwrap_or_else(|| &(0 as u32)); + let volume = stream.volume.first().unwrap_or(&0_u32); let fraction = (*volume as f64 / 655.36).round(); let percentage = (fraction).to_string() + "%"; imp.resetVolumePercentage.set_text(&percentage); diff --git a/src/components/output/sinkBox.rs b/src/components/output/sinkBox.rs index 3dbcebd..87174b7 100644 --- a/src/components/output/sinkBox.rs +++ b/src/components/output/sinkBox.rs @@ -445,7 +445,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc) -> Co let output_box = sink_box.clone(); let output_box_imp = output_box.imp(); let is_default = ir.sink.name == default_sink.name; - let volume = ir.sink.volume.first().unwrap_or_else(|| &(0 as u32)); + let volume = ir.sink.volume.first().unwrap_or(&0_u32); let fraction = (*volume as f64 / 655.36).round(); let percentage = (fraction).to_string() + "%"; @@ -532,7 +532,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc) -> Co } let name = ir.stream.application_name.clone() + ": " + ir.stream.name.as_str(); imp.resetSinkName.set_text(name.as_str()); - let volume = ir.stream.volume.first().unwrap_or_else(|| &(0 as u32)); + let volume = ir.stream.volume.first().unwrap_or(&0_u32); let fraction = (*volume as f64 / 655.36).round(); let percentage = (fraction).to_string() + "%"; imp.resetVolumePercentage.set_text(&percentage); diff --git a/src/components/output/sinkBoxImpl.rs b/src/components/output/sinkBoxImpl.rs index e87438f..26aa88e 100644 --- a/src/components/output/sinkBoxImpl.rs +++ b/src/components/output/sinkBoxImpl.rs @@ -8,7 +8,7 @@ use crate::components::base::listEntry::ListEntry; use crate::components::output::inputStreamEntry::InputStreamEntry; use gtk::subclass::prelude::*; use gtk::{ - glib, Box, Button, CheckButton, CompositeTemplate, DropDown, Label, StringList, TemplateChild, + glib, Box, Button, CheckButton, CompositeTemplate, Label, StringList, TemplateChild, }; use gtk::{prelude::*, ProgressBar, Scale}; use ReSet_Lib::audio::audio::Sink; diff --git a/src/components/output/sinkEntry.rs b/src/components/output/sinkEntry.rs index 592532a..303c17e 100644 --- a/src/components/output/sinkEntry.rs +++ b/src/components/output/sinkEntry.rs @@ -28,7 +28,7 @@ impl SinkEntry { let imp = obj.imp(); imp.resetSinkName.set_text(stream.alias.clone().as_str()); let name = Arc::new(stream.name.clone()); - let volume = stream.volume.first().unwrap_or_else(|| &(0 as u32)); + let volume = stream.volume.first().unwrap_or(&0_u32); let fraction = (*volume as f64 / 655.36).round(); let percentage = (fraction).to_string() + "%"; imp.resetVolumePercentage.set_text(&percentage); diff --git a/src/components/wifi/wifiAddressEntry.rs b/src/components/wifi/wifiAddressEntry.rs index ca651ae..62f569d 100644 --- a/src/components/wifi/wifiAddressEntry.rs +++ b/src/components/wifi/wifiAddressEntry.rs @@ -25,9 +25,9 @@ impl WifiAddressEntry { let addr = getValueFromKey(&map, "address"); let prefix = getValueFromKey(&map, "prefix-length"); - entryImp.resetAddressAddress.set_text(&*addr); - entryImp.resetAddressNetmask.set_text(&*prefix); - entryImp.resetAddressRow.set_title(&*format!("{}, {}", addr, prefix)); + entryImp.resetAddressAddress.set_text(&addr); + entryImp.resetAddressNetmask.set_text(&prefix); + entryImp.resetAddressRow.set_title(&format!("{}, {}", addr, prefix)); } entry } diff --git a/src/components/wifi/wifiBox.rs b/src/components/wifi/wifiBox.rs index b8a4a0c..ea7df37 100644 --- a/src/components/wifi/wifiBox.rs +++ b/src/components/wifi/wifiBox.rs @@ -1,18 +1,18 @@ use std::collections::HashMap; -use std::net::Shutdown::Read; + use std::sync::atomic::Ordering; -use std::sync::mpsc::{channel, Receiver, Sender}; + use std::sync::Arc; -use std::thread; + use std::time::Duration; -use crate::components::base::listEntry::ListEntry; + use crate::components::base::utils::Listeners; use adw::glib; use adw::glib::Object; use adw::prelude::{ListBoxRowExt, PreferencesGroupExt}; use adw::subclass::prelude::ObjectSubclassIsExt; -use dbus::arg::{AppendAll, ReadAll, RefArg}; +use dbus::arg::{RefArg}; use dbus::blocking::Connection; use dbus::message::SignalArgs; use dbus::Error; @@ -22,9 +22,9 @@ use gtk::gio; use gtk::glib::Variant; use gtk::prelude::{ActionableExt, WidgetExt}; use ReSet_Lib::network::network::{AccessPoint, WifiStrength}; -use ReSet_Lib::signals::{AccessPointAdded, GetVal}; +use ReSet_Lib::signals::{AccessPointAdded}; use ReSet_Lib::signals::{AccessPointChanged, AccessPointRemoved}; -use ReSet_Lib::utils::Events; + use crate::components::wifi::wifiBoxImpl; use crate::components::wifi::wifiEntry::WifiEntry; @@ -63,9 +63,9 @@ impl WifiBox { } } -pub fn scanForWifi(listeners: Arc, wifiBox: Arc) { +pub fn scanForWifi(_listeners: Arc, wifiBox: Arc) { let wifibox_ref = wifiBox.clone(); - let wifibox_ref_listener = wifiBox.clone(); + let _wifibox_ref_listener = wifiBox.clone(); let wifiEntries = wifiBox.imp().wifiEntries.clone(); let wifiEntriesPath = wifiBox.imp().wifiEntriesPath.clone(); diff --git a/src/components/wifi/wifiBoxImpl.rs b/src/components/wifi/wifiBoxImpl.rs index 6263d2d..60a6c1a 100644 --- a/src/components/wifi/wifiBoxImpl.rs +++ b/src/components/wifi/wifiBoxImpl.rs @@ -3,7 +3,7 @@ use adw::{ActionRow, ComboRow, NavigationView, PreferencesGroup}; use dbus::Path; use gtk::prelude::*; use gtk::subclass::prelude::*; -use gtk::{glib, CompositeTemplate, ListBox, Switch}; +use gtk::{glib, CompositeTemplate, Switch}; use std::collections::HashMap; use std::sync::{Arc, Mutex}; diff --git a/src/components/wifi/wifiEntry.rs b/src/components/wifi/wifiEntry.rs index 9a45cde..aac9e41 100644 --- a/src/components/wifi/wifiEntry.rs +++ b/src/components/wifi/wifiEntry.rs @@ -7,10 +7,10 @@ use adw::glib::{Object, PropertySet}; use adw::prelude::{ActionRowExt, ButtonExt, EditableExt, PopoverExt}; use adw::subclass::prelude::ObjectSubclassIsExt; use dbus::blocking::Connection; -use dbus::{Error, Path}; -use glib::{clone, Cast}; +use dbus::{Error}; +use glib::{clone}; use gtk::prelude::{ListBoxRowExt, WidgetExt}; -use gtk::{gio, AlertDialog, GestureClick}; +use gtk::{gio}; use ReSet_Lib::network::network::{AccessPoint, WifiStrength}; use crate::components::wifi::wifiBox::getConnectionSettings; @@ -18,7 +18,7 @@ use crate::components::wifi::wifiBoxImpl::WifiBox; use crate::components::wifi::wifiEntryImpl; use crate::components::wifi::wifiOptions::WifiOptions; -use super::savedWifiEntry::SavedWifiEntry; + glib::wrapper! { pub struct WifiEntry(ObjectSubclass) @@ -133,7 +133,7 @@ pub fn click_stored_network(entry: Arc) { ); glib::spawn_future(async move { glib::idle_add_once(move || { - let imp = entry_ref.imp(); + let _imp = entry_ref.imp(); if res.is_err() { println!("wat bro?"); result.store(false, std::sync::atomic::Ordering::SeqCst); diff --git a/src/components/wifi/wifiOptions.rs b/src/components/wifi/wifiOptions.rs index 1dfb17a..6b32cbb 100644 --- a/src/components/wifi/wifiOptions.rs +++ b/src/components/wifi/wifiOptions.rs @@ -5,7 +5,7 @@ use adw::glib::Object; use adw::prelude::{ActionRowExt, ComboRowExt, PreferencesGroupExt}; use adw::subclass::prelude::ObjectSubclassIsExt; use dbus::arg::PropMap; -use glib::{PropertySet, Cast, ObjectExt, clone}; +use glib::{PropertySet, ObjectExt}; use gtk::prelude::{EditableExt, WidgetExt}; use ReSet_Lib::network::connection::{Connection, Enum, TypeSettings}; @@ -31,13 +31,13 @@ impl WifiOptions { let selfImp = self.imp(); let conn = selfImp.connection.borrow(); // General - selfImp.resetWifiName.set_subtitle(&*conn.settings.name); + selfImp.resetWifiName.set_subtitle(&conn.settings.name); selfImp.resetWifiAutoConnect.set_active(conn.settings.autoconnect); - selfImp.resetWifiMetered.set_active(if conn.settings.metered != -1 { true } else { false }); + selfImp.resetWifiMetered.set_active(conn.settings.metered != -1); match &conn.device { - TypeSettings::WIFI(wifi) => {} - TypeSettings::ETHERNET(ethernet) => {} - TypeSettings::VPN(vpn) => {} + TypeSettings::WIFI(_wifi) => {} + TypeSettings::ETHERNET(_ethernet) => {} + TypeSettings::VPN(_vpn) => {} TypeSettings::None => {} }; // IPv4 @@ -52,8 +52,8 @@ impl WifiOptions { .join(".") }) .collect(); - selfImp.resetIP4DNS.set_text(&*ipv4Dns.join(", ")); - selfImp.resetIP4Gateway.set_text(&*conn.ipv4.gateway); + selfImp.resetIP4DNS.set_text(&ipv4Dns.join(", ")); + selfImp.resetIP4Gateway.set_text(&conn.ipv4.gateway); if conn.ipv4.address_data.is_empty() { selfImp.resetIP4AddressGroup.add(&WifiAddressEntry::new(None)) @@ -82,8 +82,8 @@ impl WifiOptions { .join(":") }) .collect(); - selfImp.resetIP6DNS.set_text(&*ipv6Dns.join(", ")); - selfImp.resetIP6Gateway.set_text(&*conn.ipv6.gateway); + selfImp.resetIP6DNS.set_text(&ipv6Dns.join(", ")); + selfImp.resetIP6Gateway.set_text(&conn.ipv6.gateway); if conn.ipv6.address_data.is_empty() { selfImp.resetIP6AddressGroup.add(&WifiAddressEntry::new(None)) diff --git a/src/components/wifi/wifiRouteEntry.rs b/src/components/wifi/wifiRouteEntry.rs index 0de75bf..f2deceb 100644 --- a/src/components/wifi/wifiRouteEntry.rs +++ b/src/components/wifi/wifiRouteEntry.rs @@ -26,11 +26,11 @@ impl WifiRouteEntry { let gateway = getValueFromKey(&map, "gateway"); let metric = getValueFromKey(&map, "metric"); - entryImp.resetRouteAddress.set_text(&*addr); - entryImp.resetRouteNetmask.set_text(&*prefix); - entryImp.resetRouteGateway.set_text(&*gateway); - entryImp.resetRouteMetric.set_text(&*metric); - entryImp.resetRouteRow.set_title(&*format!("{}, {}, {}, {}", addr, prefix, gateway, metric)); + entryImp.resetRouteAddress.set_text(&addr); + entryImp.resetRouteNetmask.set_text(&prefix); + entryImp.resetRouteGateway.set_text(&gateway); + entryImp.resetRouteMetric.set_text(&metric); + entryImp.resetRouteRow.set_title(&format!("{}, {}, {}, {}", addr, prefix, gateway, metric)); } entry } diff --git a/src/components/window/handleSidebarClick.rs b/src/components/window/handleSidebarClick.rs index 0505660..292ad90 100644 --- a/src/components/window/handleSidebarClick.rs +++ b/src/components/window/handleSidebarClick.rs @@ -94,7 +94,7 @@ pub const HANDLE_VOLUME_CLICK: fn(Arc, FlowBox) = listeners.stop_bluetooth_listener(); let audioOutput = Arc::new(SinkBox::new()); start_audio_listener(listeners.clone(), Some(audioOutput.clone()), None); - while !listeners.pulse_listener.load(Ordering::SeqCst) {} + while !listeners.pulse_listener.load(Ordering::SeqCst) { std::hint::spin_loop() } populate_sinks(audioOutput.clone()); let audioFrame = wrapInFrame(SettingBox::new(&*audioOutput)); resetMain.remove_all(); diff --git a/src/components/window/window.rs b/src/components/window/window.rs index 4d18560..61c66e1 100644 --- a/src/components/window/window.rs +++ b/src/components/window/window.rs @@ -81,7 +81,7 @@ impl Window { pub fn filterList(&self) { let text = self.imp().resetSearchEntry.text().to_string(); for (mainEntry, subEntries) in self.imp().sidebarEntries.borrow().iter() { - if text == "" { + if text.is_empty() { mainEntry.set_visible(true); for subEntry in subEntries { subEntry.set_visible(true); diff --git a/src/components/window/windowImpl.rs b/src/components/window/windowImpl.rs index c468dcc..4c096d1 100644 --- a/src/components/window/windowImpl.rs +++ b/src/components/window/windowImpl.rs @@ -6,7 +6,7 @@ use adw::subclass::prelude::AdwApplicationWindowImpl; use adw::{Breakpoint, OverlaySplitView}; use glib::subclass::InitializingObject; use gtk::subclass::prelude::*; -use gtk::{glib, Box, Button, CompositeTemplate, FlowBox, ListBox, PopoverMenu, SearchEntry}; +use gtk::{glib, Button, CompositeTemplate, FlowBox, ListBox, PopoverMenu, SearchEntry}; use crate::components::base::utils::Listeners; use crate::components::wifi::wifiBox::WifiBox; From 5c99e7e59ad79aa6b39a05f6fed8b91d80ca6a61 Mon Sep 17 00:00:00 2001 From: Fabio Lenherr / DashieTM Date: Thu, 23 Nov 2023 10:28:48 +0100 Subject: [PATCH 3/5] wat --- src/components/wifi/wifiEntry.rs | 8 +++----- src/components/wifi/wifiEntryImpl.rs | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/wifi/wifiEntry.rs b/src/components/wifi/wifiEntry.rs index aac9e41..fc90b6d 100644 --- a/src/components/wifi/wifiEntry.rs +++ b/src/components/wifi/wifiEntry.rs @@ -7,10 +7,10 @@ use adw::glib::{Object, PropertySet}; use adw::prelude::{ActionRowExt, ButtonExt, EditableExt, PopoverExt}; use adw::subclass::prelude::ObjectSubclassIsExt; use dbus::blocking::Connection; -use dbus::{Error}; -use glib::{clone}; +use dbus::Error; +use glib::clone; +use gtk::gio; use gtk::prelude::{ListBoxRowExt, WidgetExt}; -use gtk::{gio}; use ReSet_Lib::network::network::{AccessPoint, WifiStrength}; use crate::components::wifi::wifiBox::getConnectionSettings; @@ -18,8 +18,6 @@ use crate::components::wifi::wifiBoxImpl::WifiBox; use crate::components::wifi::wifiEntryImpl; use crate::components::wifi::wifiOptions::WifiOptions; - - glib::wrapper! { pub struct WifiEntry(ObjectSubclass) @extends adw::ActionRow, gtk::Widget, diff --git a/src/components/wifi/wifiEntryImpl.rs b/src/components/wifi/wifiEntryImpl.rs index cc44c09..b5bb30c 100644 --- a/src/components/wifi/wifiEntryImpl.rs +++ b/src/components/wifi/wifiEntryImpl.rs @@ -8,7 +8,6 @@ use adw::subclass::preferences_row::PreferencesRowImpl; use adw::subclass::prelude::ActionRowImpl; use ReSet_Lib::network::network::{AccessPoint, WifiStrength}; -#[allow(non_snake_case)] #[derive(Default, CompositeTemplate)] #[template(resource = "/org/Xetibo/ReSet/resetWifiEntry.ui")] pub struct WifiEntry { From 75fbb062fcadf23d20f2ab34964674d7c5ad1856 Mon Sep 17 00:00:00 2001 From: Fabio Lenherr / DashieTM Date: Sat, 25 Nov 2023 16:26:48 +0100 Subject: [PATCH 4/5] feat: Add Wifi Device Changes --- src/components/base/cardEntryImpl.rs | 1 + src/components/base/listEntryImpl.rs | 1 + src/components/base/popupImpl.rs | 1 + src/components/base/settingBoxImpl.rs | 1 + src/components/bluetooth/bluetoothBoxImpl.rs | 1 + src/components/bluetooth/bluetoothEntryImpl.rs | 1 + src/components/input/outputStreamEntryImpl.rs | 1 + src/components/input/sourceBoxImpl.rs | 1 + src/components/input/sourceEntryImpl.rs | 1 + src/components/output/inputStreamEntryImpl.rs | 1 + src/components/output/sinkBoxImpl.rs | 1 + src/components/output/sinkEntryImpl.rs | 1 + src/components/wifi/savedWifiEntryImpl.rs | 1 + src/components/wifi/wifiAddressEntryImpl.rs | 1 + src/components/wifi/wifiBox.rs | 2 -- src/components/wifi/wifiBoxImpl.rs | 1 + src/components/wifi/wifiEntryImpl.rs | 2 ++ src/components/wifi/wifiOptionsImpl.rs | 1 + src/components/wifi/wifiRouteEntryImpl.rs | 1 + src/components/window/sidebarEntryImpl.rs | 1 + src/components/window/windowImpl.rs | 1 + 21 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/components/base/cardEntryImpl.rs b/src/components/base/cardEntryImpl.rs index df61a08..8d15944 100644 --- a/src/components/base/cardEntryImpl.rs +++ b/src/components/base/cardEntryImpl.rs @@ -21,6 +21,7 @@ pub struct CardEntry { #[glib::object_subclass] impl ObjectSubclass for CardEntry { + const ABSTRACT: bool = false; const NAME: &'static str = "resetCardEntry"; type Type = cardEntry::CardEntry; type ParentType = ComboRow; diff --git a/src/components/base/listEntryImpl.rs b/src/components/base/listEntryImpl.rs index 0cb1c74..932df7f 100644 --- a/src/components/base/listEntryImpl.rs +++ b/src/components/base/listEntryImpl.rs @@ -9,6 +9,7 @@ pub struct ListEntry {} #[glib::object_subclass] impl ObjectSubclass for ListEntry { + const ABSTRACT: bool = false; const NAME: &'static str = "resetListBoxRow"; type Type = listEntry::ListEntry; type ParentType = gtk::ListBoxRow; diff --git a/src/components/base/popupImpl.rs b/src/components/base/popupImpl.rs index cab6fa4..35dfa2a 100644 --- a/src/components/base/popupImpl.rs +++ b/src/components/base/popupImpl.rs @@ -24,6 +24,7 @@ unsafe impl Sync for Popup {} #[glib::object_subclass] impl ObjectSubclass for Popup { + const ABSTRACT: bool = false; const NAME: &'static str = "resetPopup"; type Type = popup::Popup; type ParentType = Popover; diff --git a/src/components/base/settingBoxImpl.rs b/src/components/base/settingBoxImpl.rs index b446b44..03a21f2 100644 --- a/src/components/base/settingBoxImpl.rs +++ b/src/components/base/settingBoxImpl.rs @@ -9,6 +9,7 @@ pub struct SettingBox {} #[glib::object_subclass] impl ObjectSubclass for SettingBox { + const ABSTRACT: bool = false; const NAME: &'static str = "resetSettingBox"; type Type = settingBox::SettingBox; type ParentType = gtk::Box; diff --git a/src/components/bluetooth/bluetoothBoxImpl.rs b/src/components/bluetooth/bluetoothBoxImpl.rs index 0df46af..a718625 100644 --- a/src/components/bluetooth/bluetoothBoxImpl.rs +++ b/src/components/bluetooth/bluetoothBoxImpl.rs @@ -31,6 +31,7 @@ pub struct BluetoothBox { #[glib::object_subclass] impl ObjectSubclass for BluetoothBox { + const ABSTRACT: bool = false; const NAME: &'static str = "resetBluetooth"; type Type = bluetoothBox::BluetoothBox; type ParentType = gtk::Box; diff --git a/src/components/bluetooth/bluetoothEntryImpl.rs b/src/components/bluetooth/bluetoothEntryImpl.rs index 7dfe7bc..5846ade 100644 --- a/src/components/bluetooth/bluetoothEntryImpl.rs +++ b/src/components/bluetooth/bluetoothEntryImpl.rs @@ -31,6 +31,7 @@ pub struct BluetoothEntry { #[glib::object_subclass] impl ObjectSubclass for BluetoothEntry { + const ABSTRACT: bool = false; const NAME: &'static str = "resetBluetoothEntry"; type Type = bluetoothEntry::BluetoothEntry; type ParentType = gtk::Box; diff --git a/src/components/input/outputStreamEntryImpl.rs b/src/components/input/outputStreamEntryImpl.rs index 3a3bed1..641db53 100644 --- a/src/components/input/outputStreamEntryImpl.rs +++ b/src/components/input/outputStreamEntryImpl.rs @@ -30,6 +30,7 @@ pub struct OutputStreamEntry { #[glib::object_subclass] impl ObjectSubclass for OutputStreamEntry { + const ABSTRACT: bool = false; const NAME: &'static str = "resetOutputStreamEntry"; type Type = outputStreamEntry::OutputStreamEntry; type ParentType = gtk::Box; diff --git a/src/components/input/sourceBoxImpl.rs b/src/components/input/sourceBoxImpl.rs index 4209436..2a1cdae 100644 --- a/src/components/input/sourceBoxImpl.rs +++ b/src/components/input/sourceBoxImpl.rs @@ -56,6 +56,7 @@ pub struct SourceBox { #[glib::object_subclass] impl ObjectSubclass for SourceBox { + const ABSTRACT: bool = false; const NAME: &'static str = "resetAudioInput"; type Type = sourceBox::SourceBox; type ParentType = gtk::Box; diff --git a/src/components/input/sourceEntryImpl.rs b/src/components/input/sourceEntryImpl.rs index 1d4f516..0309485 100644 --- a/src/components/input/sourceEntryImpl.rs +++ b/src/components/input/sourceEntryImpl.rs @@ -30,6 +30,7 @@ pub struct SourceEntry { #[glib::object_subclass] impl ObjectSubclass for SourceEntry { + const ABSTRACT: bool = false; const NAME: &'static str = "resetSourceEntry"; type Type = sourceEntry::SourceEntry; type ParentType = gtk::Box; diff --git a/src/components/output/inputStreamEntryImpl.rs b/src/components/output/inputStreamEntryImpl.rs index b42e0db..1b0c383 100644 --- a/src/components/output/inputStreamEntryImpl.rs +++ b/src/components/output/inputStreamEntryImpl.rs @@ -31,6 +31,7 @@ pub struct InputStreamEntry { #[glib::object_subclass] impl ObjectSubclass for InputStreamEntry { + const ABSTRACT: bool = false; const NAME: &'static str = "resetInputStreamEntry"; type Type = inputStreamEntry::InputStreamEntry; type ParentType = gtk::Box; diff --git a/src/components/output/sinkBoxImpl.rs b/src/components/output/sinkBoxImpl.rs index 26aa88e..c1d1b98 100644 --- a/src/components/output/sinkBoxImpl.rs +++ b/src/components/output/sinkBoxImpl.rs @@ -59,6 +59,7 @@ pub struct SinkBox { #[glib::object_subclass] impl ObjectSubclass for SinkBox { + const ABSTRACT: bool = false; const NAME: &'static str = "resetAudioOutput"; type Type = sinkBox::SinkBox; type ParentType = gtk::Box; diff --git a/src/components/output/sinkEntryImpl.rs b/src/components/output/sinkEntryImpl.rs index 661817a..0531391 100644 --- a/src/components/output/sinkEntryImpl.rs +++ b/src/components/output/sinkEntryImpl.rs @@ -29,6 +29,7 @@ pub struct SinkEntry { #[glib::object_subclass] impl ObjectSubclass for SinkEntry { + const ABSTRACT: bool = false; const NAME: &'static str = "resetSinkEntry"; type Type = sinkEntry::SinkEntry; type ParentType = gtk::Box; diff --git a/src/components/wifi/savedWifiEntryImpl.rs b/src/components/wifi/savedWifiEntryImpl.rs index baef5f9..6958d5d 100644 --- a/src/components/wifi/savedWifiEntryImpl.rs +++ b/src/components/wifi/savedWifiEntryImpl.rs @@ -27,6 +27,7 @@ unsafe impl Sync for SavedWifiEntry {} #[glib::object_subclass] impl ObjectSubclass for SavedWifiEntry { + const ABSTRACT: bool = false; const NAME: &'static str = "resetSavedWifiEntry"; type Type = savedWifiEntry::SavedWifiEntry; type ParentType = ActionRow; diff --git a/src/components/wifi/wifiAddressEntryImpl.rs b/src/components/wifi/wifiAddressEntryImpl.rs index 1e48982..fa34157 100644 --- a/src/components/wifi/wifiAddressEntryImpl.rs +++ b/src/components/wifi/wifiAddressEntryImpl.rs @@ -19,6 +19,7 @@ pub struct WifiAddressEntryImpl { #[glib::object_subclass] impl ObjectSubclass for WifiAddressEntryImpl { + const ABSTRACT: bool = false; const NAME: &'static str = "resetWifiAddressEntry"; type Type = wifiAddressEntry::WifiAddressEntry; type ParentType = gtk::Box; diff --git a/src/components/wifi/wifiBox.rs b/src/components/wifi/wifiBox.rs index ea7df37..ecab1a0 100644 --- a/src/components/wifi/wifiBox.rs +++ b/src/components/wifi/wifiBox.rs @@ -204,7 +204,6 @@ pub fn start_event_listener(listeners: Arc, wifi_box: Arc) { .static_clone(); let res = conn.add_match(access_point_added, move |ir: AccessPointAdded, _, _| { println!("received added event"); - // TODO handle add let wifi_box = added_ref.clone(); glib::spawn_future(async move { glib::idle_add_once(move || { @@ -230,7 +229,6 @@ pub fn start_event_listener(listeners: Arc, wifi_box: Arc) { } let res = conn.add_match(access_point_removed, move |ir: AccessPointRemoved, _, _| { println!("received removed event"); - // TODO handle remove let wifi_box = removed_ref.clone(); glib::spawn_future(async move { glib::idle_add_once(move || { diff --git a/src/components/wifi/wifiBoxImpl.rs b/src/components/wifi/wifiBoxImpl.rs index 60a6c1a..4824aac 100644 --- a/src/components/wifi/wifiBoxImpl.rs +++ b/src/components/wifi/wifiBoxImpl.rs @@ -40,6 +40,7 @@ unsafe impl Sync for WifiBox {} #[glib::object_subclass] impl ObjectSubclass for WifiBox { + const ABSTRACT: bool = false; const NAME: &'static str = "resetWifi"; type Type = wifiBox::WifiBox; type ParentType = gtk::Box; diff --git a/src/components/wifi/wifiEntryImpl.rs b/src/components/wifi/wifiEntryImpl.rs index b5bb30c..c60ce62 100644 --- a/src/components/wifi/wifiEntryImpl.rs +++ b/src/components/wifi/wifiEntryImpl.rs @@ -8,6 +8,7 @@ use adw::subclass::preferences_row::PreferencesRowImpl; use adw::subclass::prelude::ActionRowImpl; use ReSet_Lib::network::network::{AccessPoint, WifiStrength}; +#[allow(non_snake_case)] #[derive(Default, CompositeTemplate)] #[template(resource = "/org/Xetibo/ReSet/resetWifiEntry.ui")] pub struct WifiEntry { @@ -33,6 +34,7 @@ unsafe impl Sync for WifiEntry {} #[glib::object_subclass] impl ObjectSubclass for WifiEntry { + const ABSTRACT: bool = false; const NAME: &'static str = "resetWifiEntry"; type Type = wifiEntry::WifiEntry; type ParentType = ActionRow; diff --git a/src/components/wifi/wifiOptionsImpl.rs b/src/components/wifi/wifiOptionsImpl.rs index 25790ca..5c0cee7 100644 --- a/src/components/wifi/wifiOptionsImpl.rs +++ b/src/components/wifi/wifiOptionsImpl.rs @@ -59,6 +59,7 @@ pub struct WifiOptions { #[glib::object_subclass] impl ObjectSubclass for WifiOptions { + const ABSTRACT: bool = false; const NAME: &'static str = "resetWifiOptions"; type Type = wifiOptions::WifiOptions; type ParentType = NavigationPage; diff --git a/src/components/wifi/wifiRouteEntryImpl.rs b/src/components/wifi/wifiRouteEntryImpl.rs index 26bb261..d71e543 100644 --- a/src/components/wifi/wifiRouteEntryImpl.rs +++ b/src/components/wifi/wifiRouteEntryImpl.rs @@ -23,6 +23,7 @@ pub struct WifiRouteEntryImpl { #[glib::object_subclass] impl ObjectSubclass for WifiRouteEntryImpl { + const ABSTRACT: bool = false; const NAME: &'static str = "resetWifiRouteEntry"; type Type = wifiRouteEntry::WifiRouteEntry; type ParentType = gtk::Box; diff --git a/src/components/window/sidebarEntryImpl.rs b/src/components/window/sidebarEntryImpl.rs index 38520a4..3c47197 100644 --- a/src/components/window/sidebarEntryImpl.rs +++ b/src/components/window/sidebarEntryImpl.rs @@ -47,6 +47,7 @@ impl Default for SidebarAction { #[glib::object_subclass] impl ObjectSubclass for SidebarEntry { + const ABSTRACT: bool = false; const NAME: &'static str = "resetSidebarEntry"; type Type = sidebarEntry::SidebarEntry; type ParentType = ListBoxRow; diff --git a/src/components/window/windowImpl.rs b/src/components/window/windowImpl.rs index 4c096d1..a1168be 100644 --- a/src/components/window/windowImpl.rs +++ b/src/components/window/windowImpl.rs @@ -48,6 +48,7 @@ unsafe impl Sync for Window {} #[glib::object_subclass] impl ObjectSubclass for Window { + const ABSTRACT: bool = false; const NAME: &'static str = "resetUI"; type Type = window::Window; type ParentType = adw::ApplicationWindow; From 0cc8e557a85d9e44cdbbd64bd5260d17fc53a854 Mon Sep 17 00:00:00 2001 From: Fabio Lenherr / DashieTM Date: Sat, 25 Nov 2023 16:28:25 +0100 Subject: [PATCH 5/5] chore: Bump version of daemon --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8289c2b..96602b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" description = "A wip universal Linux settings application." [dependencies] -reset_daemon = "0.2.4" +reset_daemon = "0.2.5" ReSet-Lib = "0.4.6" adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] } dbus = "0.9.7"