diff --git a/Cargo.toml b/Cargo.toml index 2a8cbf1..f380968 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ edition = "2021" description = "A wip universal Linux settings application." [dependencies] -reset_daemon = "0.2.5" -ReSet-Lib = "0.4.6" +reset_daemon = "0.3.3" +ReSet-Lib = "0.5.4" 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/cardEntry.rs b/src/components/base/cardEntry.rs index 804acac..0f671dd 100644 --- a/src/components/base/cardEntry.rs +++ b/src/components/base/cardEntry.rs @@ -68,12 +68,12 @@ fn set_card_profile_of_device(device_index: u32, profile_name: String) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetCardProfileOfDevice", (device_index, profile_name), ); diff --git a/src/components/base/utils.rs b/src/components/base/utils.rs index c9cb5ff..2fdf939 100644 --- a/src/components/base/utils.rs +++ b/src/components/base/utils.rs @@ -39,12 +39,12 @@ impl Listeners { thread::spawn(|| { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(bool,), Error> = - proxy.method_call("org.xetibo.ReSet", "StopNetworkListener", ()); + proxy.method_call("org.Xetibo.ReSetWireless", "StopNetworkListener", ()); }); } @@ -76,7 +76,7 @@ impl arg::ReadAll for SinkAdded { impl dbus::message::SignalArgs for SinkAdded { const NAME: &'static str = "SinkAdded"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(Sink,)> for SinkAdded { @@ -104,7 +104,7 @@ impl arg::ReadAll for SinkChanged { impl dbus::message::SignalArgs for SinkChanged { const NAME: &'static str = "SinkChanged"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(Sink,)> for SinkChanged { @@ -132,7 +132,7 @@ impl arg::ReadAll for SinkRemoved { impl dbus::message::SignalArgs for SinkRemoved { const NAME: &'static str = "SinkRemoved"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(u32,)> for SinkRemoved { @@ -160,7 +160,7 @@ impl arg::ReadAll for InputStreamAdded { impl dbus::message::SignalArgs for InputStreamAdded { const NAME: &'static str = "InputStreamAdded"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(InputStream,)> for InputStreamAdded { @@ -188,7 +188,7 @@ impl arg::ReadAll for InputStreamChanged { impl dbus::message::SignalArgs for InputStreamChanged { const NAME: &'static str = "InputStreamChanged"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } #[derive(Debug)] @@ -210,7 +210,7 @@ impl arg::ReadAll for InputStreamRemoved { impl dbus::message::SignalArgs for InputStreamRemoved { const NAME: &'static str = "InputStreamRemoved"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(u32,)> for InputStreamRemoved { @@ -238,7 +238,7 @@ impl arg::ReadAll for SourceAdded { impl dbus::message::SignalArgs for SourceAdded { const NAME: &'static str = "SourceAdded"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(Source,)> for SourceAdded { @@ -266,7 +266,7 @@ impl arg::ReadAll for SourceChanged { impl dbus::message::SignalArgs for SourceChanged { const NAME: &'static str = "SourceChanged"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(Source,)> for SourceChanged { @@ -294,7 +294,7 @@ impl arg::ReadAll for SourceRemoved { impl dbus::message::SignalArgs for SourceRemoved { const NAME: &'static str = "SourceRemoved"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(u32,)> for SourceRemoved { @@ -322,7 +322,7 @@ impl arg::ReadAll for OutputStreamAdded { impl dbus::message::SignalArgs for OutputStreamAdded { const NAME: &'static str = "OutputStreamAdded"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(OutputStream,)> for OutputStreamAdded { @@ -350,7 +350,7 @@ impl arg::ReadAll for OutputStreamChanged { impl dbus::message::SignalArgs for OutputStreamChanged { const NAME: &'static str = "OutputStreamChanged"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } #[derive(Debug)] @@ -372,7 +372,7 @@ impl arg::ReadAll for OutputStreamRemoved { impl dbus::message::SignalArgs for OutputStreamRemoved { const NAME: &'static str = "OutputStreamRemoved"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(u32,)> for OutputStreamRemoved { @@ -419,20 +419,20 @@ pub fn start_audio_listener( fn start_dbus_audio_listener(conn: Connection) -> Connection { let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let _: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "StartAudioListener", ()); + let _: Result<(), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "StartAudioListener", ()); conn } fn stop_dbus_audio_listener(conn: Connection) { let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let _: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "StopAudioListener", ()); + let _: Result<(), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "StopAudioListener", ()); } diff --git a/src/components/bluetooth/bluetoothBox.rs b/src/components/bluetooth/bluetoothBox.rs index c03037d..bcc6342 100644 --- a/src/components/bluetooth/bluetoothBox.rs +++ b/src/components/bluetooth/bluetoothBox.rs @@ -1,3 +1,4 @@ +use std::collections::HashMap; use std::sync::atomic::Ordering; use std::sync::Arc; use std::thread; @@ -12,6 +13,7 @@ use dbus::{Error, Path}; use gtk::gio; use gtk::glib::Variant; use gtk::prelude::{ActionableExt, ListBoxRowExt}; +use ReSet_Lib::bluetooth::bluetooth::BluetoothDevice; use ReSet_Lib::signals::{BluetoothDeviceAdded, BluetoothDeviceRemoved}; use crate::components::base::listEntry::ListEntry; @@ -48,50 +50,33 @@ impl BluetoothBox { .resetBluetoothMainTab .set_action_name(Some("navigation.pop")); } +} - pub fn scanForDevices(&self) { - // let selfImp = self.imp(); - // let mut wifiEntries = selfImp.availableDevices.borrow_mut(); - // wifiEntries.push(ListEntry::new(&BluetoothEntry::new( - // DeviceTypes::Mouse, - // "ina mouse", - // ))); - // wifiEntries.push(ListEntry::new(&BluetoothEntry::new( - // DeviceTypes::Keyboard, - // "inaboard", - // ))); - // wifiEntries.push(ListEntry::new(&BluetoothEntry::new( - // DeviceTypes::Controller, - // "ina controller", - // ))); - // wifiEntries.push( - // ListEntry::new(&BluetoothEntry::new( - // DeviceTypes::Controller, - // "ina best waifu", - // )) - // ); - // - // for wifiEntry in wifiEntries.iter() { - // selfImp.resetBluetoothAvailableDevices.append(wifiEntry); - // } - } +pub fn populate_conntected_bluetooth_devices(bluetooth_box: Arc) { + gio::spawn_blocking(move || { + let ref_box = bluetooth_box.clone(); + let devices = get_connected_devices(); - pub fn addConnectedDevices(&self) { - // let selfImp = self.imp(); - // let mut wifiEntries = selfImp.connectedDevices.borrow_mut(); - // wifiEntries.push(ListEntry::new(&BluetoothEntry::new( - // DeviceTypes::Mouse, - // "why are we still here?", - // ))); - // wifiEntries.push(ListEntry::new(&BluetoothEntry::new( - // DeviceTypes::Keyboard, - // "just to suffer?", - // ))); - // - // for wifiEntry in wifiEntries.iter() { - // selfImp.resetBluetoothConnectedDevices.append(wifiEntry); - // } - } + glib::spawn_future(async move { + glib::idle_add_once(move || { + let imp = ref_box.imp(); + for device in devices { + let path = device.path.clone(); + let connected = device.connected; + let bluetooth_entry = Arc::new(BluetoothEntry::new(device)); + let entry = Arc::new(ListEntry::new(&*bluetooth_entry)); + imp.availableDevices + .borrow_mut() + .insert(path, (bluetooth_entry.clone(), entry.clone())); + if connected { + imp.resetBluetoothConnectedDevices.append(&*entry); + } else { + imp.resetBluetoothAvailableDevices.append(&*entry); + } + } + }); + }); + }); } pub fn start_bluetooth_listener(listeners: Arc, bluetooth_box: Arc) { @@ -102,26 +87,32 @@ pub fn start_bluetooth_listener(listeners: Arc, bluetooth_box: Arc = - proxy.method_call("org.xetibo.ReSet", "StartBluetoothSearch", (10000,)); + let _: Result<(), Error> = proxy.method_call( + "org.Xetibo.ReSetBluetooth", + "StartBluetoothListener", + #[allow(clippy::unnecessary_cast)] + (25000 as u32,), + // leave me alone clippy, I am dealing with C code + ); let device_added = BluetoothDeviceAdded::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let device_removed = BluetoothDeviceRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let device_added_box = bluetooth_box.clone(); let device_removed_box = bluetooth_box.clone(); let loop_box = bluetooth_box.clone(); + // TODO handle device changed let res = conn.add_match(device_added, move |ir: BluetoothDeviceAdded, _, _| { let bluetooth_box = device_added_box.clone(); println!("added"); @@ -129,12 +120,17 @@ pub fn start_bluetooth_listener(listeners: Arc, bluetooth_box: Arc, bluetooth_box: Arc, bluetooth_box: Arc Duration::from_millis(5000) + || time.elapsed().unwrap() > Duration::from_millis(25000) { glib::spawn_future(async move { glib::idle_add_once(move || { let imp = loop_box.imp(); - imp.resetBluetoothConnectedDevices.remove_all(); + imp.resetBluetoothAvailableDevices.remove_all(); }); }); println!("stopping bluetooth listener"); @@ -186,3 +184,21 @@ pub fn start_bluetooth_listener(listeners: Arc, bluetooth_box: Arc Vec { + let conn = Connection::new_session().unwrap(); + let proxy = conn.with_proxy( + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", + Duration::from_millis(1000), + ); + let res: Result<(Vec,), Error> = proxy.method_call( + "org.Xetibo.ReSetBluetooth", + "GetConnectedBluetoothDevices", + (), + ); + if res.is_err() { + return Vec::new(); + } + res.unwrap().0 +} diff --git a/src/components/bluetooth/bluetoothBoxImpl.rs b/src/components/bluetooth/bluetoothBoxImpl.rs index a718625..55cbd30 100644 --- a/src/components/bluetooth/bluetoothBoxImpl.rs +++ b/src/components/bluetooth/bluetoothBoxImpl.rs @@ -52,8 +52,6 @@ impl ObjectImpl for BluetoothBox { self.parent_constructed(); let obj = self.obj(); obj.setupCallbacks(); - obj.scanForDevices(); - obj.addConnectedDevices(); } } diff --git a/src/components/bluetooth/bluetoothEntry.rs b/src/components/bluetooth/bluetoothEntry.rs index f917555..718e2c1 100644 --- a/src/components/bluetooth/bluetoothEntry.rs +++ b/src/components/bluetooth/bluetoothEntry.rs @@ -1,3 +1,5 @@ +use std::rc::Rc; +use std::sync::Arc; use std::time::Duration; use crate::components::bluetooth::bluetoothEntryImpl; @@ -8,7 +10,7 @@ use adw::subclass::prelude::ObjectSubclassIsExt; use dbus::blocking::Connection; use dbus::{Error, Path}; use glib::clone; -use gtk::prelude::WidgetExt; +use gtk::prelude::{ButtonExt, WidgetExt}; use gtk::{gio, GestureClick}; use ReSet_Lib::bluetooth::bluetooth::BluetoothDevice; @@ -23,10 +25,7 @@ impl BluetoothEntry { let entry: BluetoothEntry = Object::builder().build(); let entryImp = entry.imp(); entryImp.resetBluetoothLabel.get().set_text(&device.name); - entryImp - .resetBluetoothAddress - .get() - .set_text(&device.address); + entryImp.resetBluetoothAddress.get().set_text(&device.alias); // entryImp // .resetBluetoothDeviceType // .get() @@ -37,9 +36,17 @@ impl BluetoothEntry { // DeviceTypes::Controller => Some("input-gaming-symbolic"), // DeviceTypes::None => Some("text-x-generic-symbolic"), // no generic bluetooth device icon found // }); + if device.paired { + entryImp.resetBluetoothButton.set_sensitive(true); + } else { + entryImp.resetBluetoothButton.set_sensitive(false); + } + let path = Arc::new(device.path.clone()); + entryImp.resetBluetoothButton.connect_clicked(move |_| { + remove_device_pairing((*path).clone()); + }); let gesture = GestureClick::new(); - let connected = false; - // TODO implement this connected + let connected = device.connected; entryImp.device.replace(device); gesture.connect_released(clone!(@weak entryImp => move |_, _, _, _| { let device = entryImp.device.borrow_mut(); @@ -48,7 +55,7 @@ impl BluetoothEntry { } else if device.paired { connect_to_device(device.path.clone()); } else { - pair_with_device(device.path.clone()); + pair_with_device(device.path.clone()); } })); entry.add_controller(gesture); @@ -60,12 +67,15 @@ fn connect_to_device(path: Path<'static>) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let _: Result<(bool,), Error> = - proxy.method_call("org.xetibo.ReSet", "ConnectToBluetoothDevice", (path,)); + let _: Result<(bool,), Error> = proxy.method_call( + "org.Xetibo.ReSetBluetooth", + "ConnectToBluetoothDevice", + (path,), + ); }); } @@ -73,12 +83,15 @@ fn pair_with_device(path: Path<'static>) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let _: Result<(bool,), Error> = - proxy.method_call("org.xetibo.ReSet", "PairWithBluetoothDevice", (path,)); + let _: Result<(bool,), Error> = proxy.method_call( + "org.Xetibo.ReSetBluetooth", + "PairWithBluetoothDevice", + (path,), + ); }); } @@ -86,11 +99,27 @@ fn disconnect_from_device(path: Path<'static>) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", + Duration::from_millis(1000), + ); + let _: Result<(bool,), Error> = proxy.method_call( + "org.Xetibo.ReSetBluetooth", + "DisconnectFromBluetoothDevice", + (path,), + ); + }); +} + +fn remove_device_pairing(path: Path<'static>) { + gio::spawn_blocking(move || { + let conn = Connection::new_session().unwrap(); + let proxy = conn.with_proxy( + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(bool,), Error> = - proxy.method_call("org.xetibo.ReSet", "DisconnectFromBluetoothDevice", (path,)); + proxy.method_call("org.Xetibo.ReSetBluetooth", "RemoveDevicePairing", (path,)); }); } diff --git a/src/components/input/outputStreamEntry.rs b/src/components/input/outputStreamEntry.rs index 9e1e231..175204e 100644 --- a/src/components/input/outputStreamEntry.rs +++ b/src/components/input/outputStreamEntry.rs @@ -141,12 +141,12 @@ fn set_outputstream_volume(value: f64, index: u32, channels: u16) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetOutputStreamVolume", (index, channels, value as u32), ); @@ -162,12 +162,12 @@ fn toggle_output_stream_mute(index: u32, muted: bool) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetOutputStreamMute", (index, muted)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetOutputStreamMute", (index, muted)); // if res.is_err() { // return false; // } @@ -180,12 +180,12 @@ fn set_source_of_output_stream(stream: u32, source: u32) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(bool,), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetSourceOfOutputStream", (stream, source), ); diff --git a/src/components/input/sourceBox.rs b/src/components/input/sourceBox.rs index 3a97d87..f943a2e 100644 --- a/src/components/input/sourceBox.rs +++ b/src/components/input/sourceBox.rs @@ -248,12 +248,12 @@ pub fn populate_cards(input_box: Arc) { fn get_output_streams() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Vec,), Error> = - proxy.method_call("org.xetibo.ReSet", "ListOutputStreams", ()); + proxy.method_call("org.Xetibo.ReSetAudio", "ListOutputStreams", ()); if res.is_err() { return Vec::new(); } @@ -263,12 +263,12 @@ fn get_output_streams() -> Vec { fn get_sources() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Vec,), Error> = - proxy.method_call("org.xetibo.ReSet", "ListSources", ()); + proxy.method_call("org.Xetibo.ReSetAudio", "ListSources", ()); if res.is_err() { return Vec::new(); } @@ -278,11 +278,11 @@ fn get_sources() -> Vec { fn get_cards() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let res: Result<(Vec,), Error> = proxy.method_call("org.xetibo.ReSet", "ListCards", ()); + let res: Result<(Vec,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListCards", ()); if res.is_err() { return Vec::new(); } @@ -292,12 +292,12 @@ fn get_cards() -> Vec { fn get_default_source() -> Source { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Source,), Error> = - proxy.method_call("org.xetibo.ReSet", "GetDefaultSource", ()); + proxy.method_call("org.Xetibo.ReSetAudio", "GetDefaultSource", ()); if res.is_err() { return Source::default(); } @@ -306,33 +306,33 @@ fn get_default_source() -> Source { pub fn start_input_box_listener(conn: Connection, source_box: Arc) -> Connection { let source_added = SourceAdded::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let source_removed = SourceRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let source_changed = SourceChanged::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let output_stream_added = OutputStreamAdded::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let output_stream_removed = OutputStreamRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let output_stream_changed = OutputStreamChanged::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); diff --git a/src/components/input/sourceEntry.rs b/src/components/input/sourceEntry.rs index 423f20d..0d4202b 100644 --- a/src/components/input/sourceEntry.rs +++ b/src/components/input/sourceEntry.rs @@ -94,12 +94,12 @@ pub fn set_source_volume(value: f64, index: u32, channels: u16) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetSourceVolume", (index, channels, value as u32), ); @@ -115,12 +115,12 @@ pub fn toggle_source_mute(index: u32, muted: bool) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetSourceMute", (index, muted)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetSourceMute", (index, muted)); // if res.is_err() { // return false; // } @@ -133,12 +133,12 @@ pub fn set_default_source(name: Arc) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetDefaultSink", (name.as_str(),)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetDefaultSink", (name.as_str(),)); // if res.is_err() { // return; // } diff --git a/src/components/output/inputStreamEntry.rs b/src/components/output/inputStreamEntry.rs index 24f79fd..ba09b87 100644 --- a/src/components/output/inputStreamEntry.rs +++ b/src/components/output/inputStreamEntry.rs @@ -157,12 +157,12 @@ fn set_inputstream_volume(value: f64, index: u32, channels: u16) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetInputStreamVolume", (index, channels, value as u32), ); @@ -178,12 +178,12 @@ fn toggle_input_stream_mute(index: u32, muted: bool) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetInputStreamMute", (index, muted)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetInputStreamMute", (index, muted)); // if res.is_err() { // return false; // } @@ -196,12 +196,12 @@ fn set_sink_of_input_stream(stream: u32, sink: u32) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetSinkOfInputStream", (stream, sink)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetSinkOfInputStream", (stream, sink)); // if res.is_err() { // return false; // } diff --git a/src/components/output/sinkBox.rs b/src/components/output/sinkBox.rs index 117e124..a9cc7a1 100644 --- a/src/components/output/sinkBox.rs +++ b/src/components/output/sinkBox.rs @@ -254,12 +254,12 @@ pub fn populate_cards(output_box: Arc) { fn get_input_streams() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Vec,), Error> = - proxy.method_call("org.xetibo.ReSet", "ListInputStreams", ()); + proxy.method_call("org.Xetibo.ReSetAudio", "ListInputStreams", ()); if res.is_err() { return Vec::new(); } @@ -269,11 +269,11 @@ fn get_input_streams() -> Vec { fn get_sinks() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let res: Result<(Vec,), Error> = proxy.method_call("org.xetibo.ReSet", "ListSinks", ()); + let res: Result<(Vec,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListSinks", ()); if res.is_err() { return Vec::new(); } @@ -283,11 +283,11 @@ fn get_sinks() -> Vec { fn get_default_sink() -> Sink { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let res: Result<(Sink,), Error> = proxy.method_call("org.xetibo.ReSet", "GetDefaultSink", ()); + let res: Result<(Sink,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "GetDefaultSink", ()); if res.is_err() { return Sink::default(); } @@ -297,11 +297,11 @@ fn get_default_sink() -> Sink { fn get_cards() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let res: Result<(Vec,), Error> = proxy.method_call("org.xetibo.ReSet", "ListCards", ()); + let res: Result<(Vec,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListCards", ()); if res.is_err() { return Vec::new(); } @@ -310,33 +310,33 @@ fn get_cards() -> Vec { pub fn start_output_box_listener(conn: Connection, sink_box: Arc) -> Connection { let sink_added = SinkAdded::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let sink_removed = SinkRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let sink_changed = SinkChanged::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let input_stream_added = InputStreamAdded::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let input_stream_removed = InputStreamRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let input_stream_changed = InputStreamChanged::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); diff --git a/src/components/output/sinkEntry.rs b/src/components/output/sinkEntry.rs index 06fb6c0..31c0e2d 100644 --- a/src/components/output/sinkEntry.rs +++ b/src/components/output/sinkEntry.rs @@ -89,12 +89,12 @@ pub fn set_sink_volume(value: f64, index: u32, channels: u16) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetSinkVolume", (index, channels, value as u32), ); @@ -110,12 +110,12 @@ pub fn toggle_sink_mute(index: u32, muted: bool) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetSinkMute", (index, muted)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetSinkMute", (index, muted)); // if res.is_err() { // return false; // } @@ -128,12 +128,12 @@ pub fn set_default_sink(name: Arc) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetDefaultSink", (name.as_str(),)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetDefaultSink", (name.as_str(),)); // if res.is_err() { // return; // } diff --git a/src/components/utils.rs b/src/components/utils.rs index e218519..2162c9f 100644 --- a/src/components/utils.rs +++ b/src/components/utils.rs @@ -1,9 +1,12 @@ -use adw::ComboRow; +use std::time::Duration; + use adw::gdk::pango::EllipsizeMode; use adw::prelude::ListModelExtManual; +use adw::ComboRow; +use dbus::blocking::{Connection, Proxy}; use glib::{Cast, Object}; -use gtk::{Align, SignalListItemFactory, StringObject}; use gtk::prelude::{GObjectPropertyExpressionExt, ListBoxRowExt, ListItemExt, WidgetExt}; +use gtk::{Align, SignalListItemFactory, StringObject}; pub fn createDropdownLabelFactory() -> SignalListItemFactory { let factory = SignalListItemFactory::new(); @@ -20,7 +23,13 @@ pub fn createDropdownLabelFactory() -> SignalListItemFactory { } pub fn setComboRowEllipsis(element: ComboRow) { - for (i, child) in element.child().unwrap().observe_children().iter::().enumerate() { + for (i, child) in element + .child() + .unwrap() + .observe_children() + .iter::() + .enumerate() + { if i == 2 { if let Ok(object) = child { if let Some(item) = object.downcast_ref::() { @@ -34,4 +43,4 @@ pub fn setComboRowEllipsis(element: ComboRow) { } } } -} \ No newline at end of file +} diff --git a/src/components/wifi/savedWifiEntry.rs b/src/components/wifi/savedWifiEntry.rs index 5546ebb..8c2137d 100644 --- a/src/components/wifi/savedWifiEntry.rs +++ b/src/components/wifi/savedWifiEntry.rs @@ -49,11 +49,11 @@ fn delete_connection(path: Path<'static>) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "DeleteConnection", (path,)); + proxy.method_call("org.Xetibo.ReSetWireless", "DeleteConnection", (path,)); }); } diff --git a/src/components/wifi/utils.rs b/src/components/wifi/utils.rs index 3b0898e..a956e70 100644 --- a/src/components/wifi/utils.rs +++ b/src/components/wifi/utils.rs @@ -9,14 +9,14 @@ use ReSet_Lib::network::connection::Connection as ResetConnection; pub fn getConnectionSettings(path: Path<'static>) -> ResetConnection { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result< (HashMap>>>,), Error, - > = proxy.method_call("org.xetibo.ReSet", "GetConnectionSettings", (path,)); + > = proxy.method_call("org.xetibo.ReSetWireless", "GetConnectionSettings", (path,)); if res.is_err() { ResetConnection::default(); } diff --git a/src/components/wifi/wifiBox.rs b/src/components/wifi/wifiBox.rs index 4f0bfd7..ef13542 100644 --- a/src/components/wifi/wifiBox.rs +++ b/src/components/wifi/wifiBox.rs @@ -112,22 +112,22 @@ pub fn show_stored_connections(wifiBox: Arc) { pub fn dbus_start_network_events() { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let _: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "StartNetworkListener", ()); + let _: Result<(), Error> = proxy.method_call("org.Xetibo.ReSetWireless", "StartNetworkListener", ()); } pub fn get_access_points() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Vec,), Error> = - proxy.method_call("org.xetibo.ReSet", "ListAccessPoints", ()); + proxy.method_call("org.Xetibo.ReSetWireless", "ListAccessPoints", ()); if res.is_err() { return Vec::new(); } @@ -138,12 +138,12 @@ pub fn get_access_points() -> Vec { pub fn get_stored_connections() -> Vec<(Path<'static>, Vec)> { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Vec<(Path<'static>, Vec)>,), Error> = - proxy.method_call("org.xetibo.ReSet", "ListStoredConnections", ()); + proxy.method_call("org.Xetibo.ReSetWireless", "ListStoredConnections", ()); if res.is_err() { println!("we got error..."); return Vec::new(); @@ -164,18 +164,18 @@ pub fn start_event_listener(listeners: Arc, wifi_box: Arc) { 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")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let access_point_removed = AccessPointRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let access_point_changed = AccessPointChanged::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let res = conn.add_match(access_point_added, move |ir: AccessPointAdded, _, _| { diff --git a/src/components/wifi/wifiEntry.rs b/src/components/wifi/wifiEntry.rs index ace6dec..b9228ad 100644 --- a/src/components/wifi/wifiEntry.rs +++ b/src/components/wifi/wifiEntry.rs @@ -95,12 +95,12 @@ pub fn click_disconnect(entry: Arc) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(10000), ); let res: Result<(bool,), Error> = - proxy.method_call("org.xetibo.ReSet", "DisconnectFromCurrentAccessPoint", ()); + proxy.method_call("org.Xetibo.ReSetWireless", "DisconnectFromCurrentAccessPoint", ()); if res.is_err() { println!("res of disconnect was error bro"); return; @@ -120,12 +120,12 @@ pub fn click_stored_network(entry: Arc) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(10000), ); let res: Result<(bool,), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetWireless", "ConnectToKnownAccessPoint", (access_point,), ); @@ -170,12 +170,12 @@ pub fn click_new_network(entry: Arc) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(10000), ); let res: Result<(bool,), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetWireless", "ConnectToNewAccessPoint", (access_point, password), ); diff --git a/src/components/window/handleSidebarClick.rs b/src/components/window/handleSidebarClick.rs index 292ad90..7ad3183 100644 --- a/src/components/window/handleSidebarClick.rs +++ b/src/components/window/handleSidebarClick.rs @@ -4,7 +4,7 @@ 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::bluetooth::bluetoothBox::{start_bluetooth_listener, BluetoothBox, populate_conntected_bluetooth_devices}; use crate::components::input::sourceBox::{populate_sources, SourceBox}; use crate::components::output::sinkBox::{populate_sinks, SinkBox}; use crate::components::wifi::wifiBox::{ @@ -22,6 +22,7 @@ pub const HANDLE_CONNECTIVITY_CLICK: fn(Arc, FlowBox) = scanForWifi(listeners.clone(), wifiBox.clone()); let wifiFrame = wrapInFrame(SettingBox::new(&*wifiBox)); let bluetooth_box = Arc::new(BluetoothBox::new()); + populate_conntected_bluetooth_devices(bluetooth_box.clone()); start_bluetooth_listener(listeners.clone(), bluetooth_box.clone()); let bluetoothFrame = wrapInFrame(SettingBox::new(&*bluetooth_box)); resetMain.remove_all(); @@ -50,6 +51,7 @@ pub const HANDLE_BLUETOOTH_CLICK: fn(Arc, FlowBox) = listeners.stop_audio_listener(); let bluetooth_box = Arc::new(BluetoothBox::new()); start_bluetooth_listener(listeners.clone(), bluetooth_box.clone()); + populate_conntected_bluetooth_devices(bluetooth_box.clone()); let bluetoothFrame = wrapInFrame(SettingBox::new(&*bluetooth_box)); resetMain.remove_all(); resetMain.insert(&bluetoothFrame, -1); diff --git a/src/components/window/window.rs b/src/components/window/window.rs index 61c66e1..7b82ccd 100644 --- a/src/components/window/window.rs +++ b/src/components/window/window.rs @@ -1,9 +1,9 @@ +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::sidebarEntry::SidebarEntry; @@ -18,6 +18,7 @@ glib::wrapper! { } unsafe impl Send for Window {} + unsafe impl Sync for Window {} #[allow(non_snake_case)] @@ -29,15 +30,11 @@ 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(); })); @@ -49,9 +46,7 @@ impl Window { }), ); - selfImp - .resetClose - .connect_clicked(clone!(@ weak self as window => move |_| { + selfImp.resetClose.connect_clicked(clone!(@ weak self as window => move |_| { window.close(); })); @@ -63,9 +58,7 @@ 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", @@ -88,25 +81,13 @@ 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 { @@ -226,6 +207,10 @@ impl Window { peripheralsList, )); + selfImp.resetSidebarList.connect_row_activated(clone!(@ weak selfImp => move |_, _| { + selfImp.resetSearchEntry.set_text(""); + })); + for (mainEntry, subEntries) in sidebarEntries.iter() { selfImp.resetSidebarList.append(mainEntry); for subEntry in subEntries { @@ -241,9 +226,7 @@ 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") @@ -262,16 +245,12 @@ 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/main.rs b/src/main.rs index 4054993..69cc7a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,6 +34,7 @@ async fn main() { }); app.connect_activate(buildUI); + app.connect_shutdown(shutdown); app.run(); } @@ -54,15 +55,28 @@ fn buildUI(app: &Application) { window.present(); } +fn shutdown(_: &Application) { + thread::spawn(|| { + let conn = Connection::new_session().unwrap(); + let proxy = conn.with_proxy( + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", + Duration::from_millis(100), + ); + let res: Result<(), Error> = proxy.method_call("org.Xetibo.ReSetDaemon", "UnregisterClient", ("ReSet",)); + res + }); +} + async fn daemon_check() { let handle = thread::spawn(|| { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(100), ); - let res: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "Check", ()); + let res: Result<(), Error> = proxy.method_call("org.Xetibo.ReSetDaemon", "RegisterClient", ("ReSet",)); res }); let res = handle.join(); diff --git a/src/resources/resetBluetoothEntry.ui b/src/resources/resetBluetoothEntry.ui index 6f50c07..fa705b8 100644 --- a/src/resources/resetBluetoothEntry.ui +++ b/src/resources/resetBluetoothEntry.ui @@ -44,7 +44,7 @@ False - emblem-system-symbolic + user-trash-symbolic diff --git a/src/resources/resetUI.cmb b/src/resources/resetUI.cmb index 2a325c1..65ef1bd 100644 --- a/src/resources/resetUI.cmb +++ b/src/resources/resetUI.cmb @@ -165,9 +165,9 @@ (11,2,"GtkBox","resetBluetoothEntry",None,None,None,None,None,None), (11,3,"GtkImage","resetBluetoothDeviceType",2,None,None,None,None,None), (11,5,"GtkButton","resetBluetoothButton",2,None,None,None,3,None), - (11,6,"GtkBox",None,2,None,None,None,2,None), + (11,6,"GtkBox",None,2,None,None,None,1,None), (11,7,"GtkLabel","resetBluetoothLabel",6,None,None,None,None,None), - (11,8,"GtkLabel","resetBluetoothAddress",6,None,None,None,1,None), + (11,8,"GtkLabel","resetBluetoothAddress",6,None,None,None,2,None), (12,11,"GtkBox","resetAudioInput",None,None,None,None,None,None), (12,12,"GtkLabel",None,11,None,None,None,None,None), (12,13,"AdwNavigationView",None,11,None,None,None,1,None), @@ -598,7 +598,7 @@ (11,3,"GtkImage","icon-name","input-mouse-symbolic",None,None,None,None,None,None,None,None,None), (11,3,"GtkWidget","margin-end","15",None,None,None,None,None,None,None,None,None), (11,5,"GtkButton","has-frame","False",None,None,None,None,None,None,None,None,None), - (11,5,"GtkButton","icon-name","emblem-system-symbolic",None,None,None,None,None,None,None,None,None), + (11,5,"GtkButton","icon-name","user-trash-symbolic",None,None,None,None,None,None,None,None,None), (11,6,"GtkOrientable","orientation","vertical",None,None,None,None,None,None,None,None,None), (11,7,"GtkLabel","ellipsize","end",None,None,None,None,None,None,None,None,None), (11,7,"GtkLabel","label","LoremIpsum Wireless Mouse",None,None,None,None,None,None,None,None,None),