mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-19 02:58:33 +02:00
Merge pull request #65 from Xetibo/dashie
feat: Implement new Settings API
This commit is contained in:
commit
ff90e12bde
|
@ -5,8 +5,8 @@ edition = "2021"
|
||||||
description = "A wip universal Linux settings application."
|
description = "A wip universal Linux settings application."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
reset_daemon = "0.2.5"
|
reset_daemon = "0.3.3"
|
||||||
ReSet-Lib = "0.4.6"
|
ReSet-Lib = "0.5.4"
|
||||||
adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] }
|
adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] }
|
||||||
dbus = "0.9.7"
|
dbus = "0.9.7"
|
||||||
gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] }
|
gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] }
|
||||||
|
|
|
@ -68,12 +68,12 @@ fn set_card_profile_of_device(device_index: u32, profile_name: String) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> = proxy.method_call(
|
let _: Result<(), Error> = proxy.method_call(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetAudio",
|
||||||
"SetCardProfileOfDevice",
|
"SetCardProfileOfDevice",
|
||||||
(device_index, profile_name),
|
(device_index, profile_name),
|
||||||
);
|
);
|
||||||
|
|
|
@ -39,12 +39,12 @@ impl Listeners {
|
||||||
thread::spawn(|| {
|
thread::spawn(|| {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(bool,), Error> =
|
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 {
|
impl dbus::message::SignalArgs for SinkAdded {
|
||||||
const NAME: &'static str = "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 {
|
impl GetVal<(Sink,)> for SinkAdded {
|
||||||
|
@ -104,7 +104,7 @@ impl arg::ReadAll for SinkChanged {
|
||||||
|
|
||||||
impl dbus::message::SignalArgs for SinkChanged {
|
impl dbus::message::SignalArgs for SinkChanged {
|
||||||
const NAME: &'static str = "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 {
|
impl GetVal<(Sink,)> for SinkChanged {
|
||||||
|
@ -132,7 +132,7 @@ impl arg::ReadAll for SinkRemoved {
|
||||||
|
|
||||||
impl dbus::message::SignalArgs for SinkRemoved {
|
impl dbus::message::SignalArgs for SinkRemoved {
|
||||||
const NAME: &'static str = "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 {
|
impl GetVal<(u32,)> for SinkRemoved {
|
||||||
|
@ -160,7 +160,7 @@ impl arg::ReadAll for InputStreamAdded {
|
||||||
|
|
||||||
impl dbus::message::SignalArgs for InputStreamAdded {
|
impl dbus::message::SignalArgs for InputStreamAdded {
|
||||||
const NAME: &'static str = "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 {
|
impl GetVal<(InputStream,)> for InputStreamAdded {
|
||||||
|
@ -188,7 +188,7 @@ impl arg::ReadAll for InputStreamChanged {
|
||||||
|
|
||||||
impl dbus::message::SignalArgs for InputStreamChanged {
|
impl dbus::message::SignalArgs for InputStreamChanged {
|
||||||
const NAME: &'static str = "InputStreamChanged";
|
const NAME: &'static str = "InputStreamChanged";
|
||||||
const INTERFACE: &'static str = "org.xetibo.ReSet";
|
const INTERFACE: &'static str = "org.Xetibo.ReSetAudio";
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -210,7 +210,7 @@ impl arg::ReadAll for InputStreamRemoved {
|
||||||
|
|
||||||
impl dbus::message::SignalArgs for InputStreamRemoved {
|
impl dbus::message::SignalArgs for InputStreamRemoved {
|
||||||
const NAME: &'static str = "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 {
|
impl GetVal<(u32,)> for InputStreamRemoved {
|
||||||
|
@ -238,7 +238,7 @@ impl arg::ReadAll for SourceAdded {
|
||||||
|
|
||||||
impl dbus::message::SignalArgs for SourceAdded {
|
impl dbus::message::SignalArgs for SourceAdded {
|
||||||
const NAME: &'static str = "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 {
|
impl GetVal<(Source,)> for SourceAdded {
|
||||||
|
@ -266,7 +266,7 @@ impl arg::ReadAll for SourceChanged {
|
||||||
|
|
||||||
impl dbus::message::SignalArgs for SourceChanged {
|
impl dbus::message::SignalArgs for SourceChanged {
|
||||||
const NAME: &'static str = "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 {
|
impl GetVal<(Source,)> for SourceChanged {
|
||||||
|
@ -294,7 +294,7 @@ impl arg::ReadAll for SourceRemoved {
|
||||||
|
|
||||||
impl dbus::message::SignalArgs for SourceRemoved {
|
impl dbus::message::SignalArgs for SourceRemoved {
|
||||||
const NAME: &'static str = "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 {
|
impl GetVal<(u32,)> for SourceRemoved {
|
||||||
|
@ -322,7 +322,7 @@ impl arg::ReadAll for OutputStreamAdded {
|
||||||
|
|
||||||
impl dbus::message::SignalArgs for OutputStreamAdded {
|
impl dbus::message::SignalArgs for OutputStreamAdded {
|
||||||
const NAME: &'static str = "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 {
|
impl GetVal<(OutputStream,)> for OutputStreamAdded {
|
||||||
|
@ -350,7 +350,7 @@ impl arg::ReadAll for OutputStreamChanged {
|
||||||
|
|
||||||
impl dbus::message::SignalArgs for OutputStreamChanged {
|
impl dbus::message::SignalArgs for OutputStreamChanged {
|
||||||
const NAME: &'static str = "OutputStreamChanged";
|
const NAME: &'static str = "OutputStreamChanged";
|
||||||
const INTERFACE: &'static str = "org.xetibo.ReSet";
|
const INTERFACE: &'static str = "org.Xetibo.ReSetAudio";
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -372,7 +372,7 @@ impl arg::ReadAll for OutputStreamRemoved {
|
||||||
|
|
||||||
impl dbus::message::SignalArgs for OutputStreamRemoved {
|
impl dbus::message::SignalArgs for OutputStreamRemoved {
|
||||||
const NAME: &'static str = "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 {
|
impl GetVal<(u32,)> for OutputStreamRemoved {
|
||||||
|
@ -419,20 +419,20 @@ pub fn start_audio_listener(
|
||||||
|
|
||||||
fn start_dbus_audio_listener(conn: Connection) -> Connection {
|
fn start_dbus_audio_listener(conn: Connection) -> Connection {
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
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
|
conn
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop_dbus_audio_listener(conn: Connection) {
|
fn stop_dbus_audio_listener(conn: Connection) {
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "StopAudioListener", ());
|
let _: Result<(), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "StopAudioListener", ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
@ -12,6 +13,7 @@ use dbus::{Error, Path};
|
||||||
use gtk::gio;
|
use gtk::gio;
|
||||||
use gtk::glib::Variant;
|
use gtk::glib::Variant;
|
||||||
use gtk::prelude::{ActionableExt, ListBoxRowExt};
|
use gtk::prelude::{ActionableExt, ListBoxRowExt};
|
||||||
|
use ReSet_Lib::bluetooth::bluetooth::BluetoothDevice;
|
||||||
use ReSet_Lib::signals::{BluetoothDeviceAdded, BluetoothDeviceRemoved};
|
use ReSet_Lib::signals::{BluetoothDeviceAdded, BluetoothDeviceRemoved};
|
||||||
|
|
||||||
use crate::components::base::listEntry::ListEntry;
|
use crate::components::base::listEntry::ListEntry;
|
||||||
|
@ -48,50 +50,33 @@ impl BluetoothBox {
|
||||||
.resetBluetoothMainTab
|
.resetBluetoothMainTab
|
||||||
.set_action_name(Some("navigation.pop"));
|
.set_action_name(Some("navigation.pop"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn scanForDevices(&self) {
|
pub fn populate_conntected_bluetooth_devices(bluetooth_box: Arc<BluetoothBox>) {
|
||||||
// let selfImp = self.imp();
|
gio::spawn_blocking(move || {
|
||||||
// let mut wifiEntries = selfImp.availableDevices.borrow_mut();
|
let ref_box = bluetooth_box.clone();
|
||||||
// wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
|
let devices = get_connected_devices();
|
||||||
// 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 addConnectedDevices(&self) {
|
glib::spawn_future(async move {
|
||||||
// let selfImp = self.imp();
|
glib::idle_add_once(move || {
|
||||||
// let mut wifiEntries = selfImp.connectedDevices.borrow_mut();
|
let imp = ref_box.imp();
|
||||||
// wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
|
for device in devices {
|
||||||
// DeviceTypes::Mouse,
|
let path = device.path.clone();
|
||||||
// "why are we still here?",
|
let connected = device.connected;
|
||||||
// )));
|
let bluetooth_entry = Arc::new(BluetoothEntry::new(device));
|
||||||
// wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
|
let entry = Arc::new(ListEntry::new(&*bluetooth_entry));
|
||||||
// DeviceTypes::Keyboard,
|
imp.availableDevices
|
||||||
// "just to suffer?",
|
.borrow_mut()
|
||||||
// )));
|
.insert(path, (bluetooth_entry.clone(), entry.clone()));
|
||||||
//
|
if connected {
|
||||||
// for wifiEntry in wifiEntries.iter() {
|
imp.resetBluetoothConnectedDevices.append(&*entry);
|
||||||
// selfImp.resetBluetoothConnectedDevices.append(wifiEntry);
|
} else {
|
||||||
// }
|
imp.resetBluetoothAvailableDevices.append(&*entry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<BluetoothBox>) {
|
pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<BluetoothBox>) {
|
||||||
|
@ -102,26 +87,32 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
|
||||||
|
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> =
|
let _: Result<(), Error> = proxy.method_call(
|
||||||
proxy.method_call("org.xetibo.ReSet", "StartBluetoothSearch", (10000,));
|
"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(
|
let device_added = BluetoothDeviceAdded::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let device_removed = BluetoothDeviceRemoved::match_rule(
|
let device_removed = BluetoothDeviceRemoved::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let device_added_box = bluetooth_box.clone();
|
let device_added_box = bluetooth_box.clone();
|
||||||
let device_removed_box = bluetooth_box.clone();
|
let device_removed_box = bluetooth_box.clone();
|
||||||
let loop_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 res = conn.add_match(device_added, move |ir: BluetoothDeviceAdded, _, _| {
|
||||||
let bluetooth_box = device_added_box.clone();
|
let bluetooth_box = device_added_box.clone();
|
||||||
println!("added");
|
println!("added");
|
||||||
|
@ -129,12 +120,17 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
|
||||||
glib::idle_add_once(move || {
|
glib::idle_add_once(move || {
|
||||||
let imp = bluetooth_box.imp();
|
let imp = bluetooth_box.imp();
|
||||||
let path = ir.bluetooth_device.path.clone();
|
let path = ir.bluetooth_device.path.clone();
|
||||||
|
let connected = ir.bluetooth_device.connected;
|
||||||
let bluetooth_entry = Arc::new(BluetoothEntry::new(ir.bluetooth_device));
|
let bluetooth_entry = Arc::new(BluetoothEntry::new(ir.bluetooth_device));
|
||||||
let entry = Arc::new(ListEntry::new(&*bluetooth_entry));
|
let entry = Arc::new(ListEntry::new(&*bluetooth_entry));
|
||||||
imp.availableDevices
|
imp.availableDevices
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.insert(path, (bluetooth_entry.clone(), entry.clone()));
|
.insert(path, (bluetooth_entry.clone(), entry.clone()));
|
||||||
|
if connected {
|
||||||
|
imp.resetBluetoothConnectedDevices.append(&*entry);
|
||||||
|
} else {
|
||||||
imp.resetBluetoothAvailableDevices.append(&*entry);
|
imp.resetBluetoothAvailableDevices.append(&*entry);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
true
|
true
|
||||||
|
@ -154,7 +150,9 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
|
||||||
let list_entry = map.get(&ir.bluetooth_device);
|
let list_entry = map.get(&ir.bluetooth_device);
|
||||||
if list_entry.is_some() {
|
if list_entry.is_some() {
|
||||||
imp.resetBluetoothAvailableDevices
|
imp.resetBluetoothAvailableDevices
|
||||||
.remove(&*list_entry.unwrap().0);
|
.remove(&*list_entry.unwrap().1);
|
||||||
|
imp.resetBluetoothConnectedDevices
|
||||||
|
.remove(&*list_entry.unwrap().1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -166,17 +164,17 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
|
||||||
}
|
}
|
||||||
|
|
||||||
listeners.bluetooth_listener.store(true, Ordering::SeqCst);
|
listeners.bluetooth_listener.store(true, Ordering::SeqCst);
|
||||||
let _time = SystemTime::now();
|
let time = SystemTime::now();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let _ = conn.process(Duration::from_millis(1000));
|
let _ = conn.process(Duration::from_millis(1000));
|
||||||
if !listeners.bluetooth_listener.load(Ordering::SeqCst)
|
if !listeners.bluetooth_listener.load(Ordering::SeqCst)
|
||||||
// || time.elapsed().unwrap() > Duration::from_millis(5000)
|
|| time.elapsed().unwrap() > Duration::from_millis(25000)
|
||||||
{
|
{
|
||||||
glib::spawn_future(async move {
|
glib::spawn_future(async move {
|
||||||
glib::idle_add_once(move || {
|
glib::idle_add_once(move || {
|
||||||
let imp = loop_box.imp();
|
let imp = loop_box.imp();
|
||||||
imp.resetBluetoothConnectedDevices.remove_all();
|
imp.resetBluetoothAvailableDevices.remove_all();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
println!("stopping bluetooth listener");
|
println!("stopping bluetooth listener");
|
||||||
|
@ -186,3 +184,21 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_connected_devices() -> Vec<BluetoothDevice> {
|
||||||
|
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<BluetoothDevice>,), Error> = proxy.method_call(
|
||||||
|
"org.Xetibo.ReSetBluetooth",
|
||||||
|
"GetConnectedBluetoothDevices",
|
||||||
|
(),
|
||||||
|
);
|
||||||
|
if res.is_err() {
|
||||||
|
return Vec::new();
|
||||||
|
}
|
||||||
|
res.unwrap().0
|
||||||
|
}
|
||||||
|
|
|
@ -52,8 +52,6 @@ impl ObjectImpl for BluetoothBox {
|
||||||
self.parent_constructed();
|
self.parent_constructed();
|
||||||
let obj = self.obj();
|
let obj = self.obj();
|
||||||
obj.setupCallbacks();
|
obj.setupCallbacks();
|
||||||
obj.scanForDevices();
|
|
||||||
obj.addConnectedDevices();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::rc::Rc;
|
||||||
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::components::bluetooth::bluetoothEntryImpl;
|
use crate::components::bluetooth::bluetoothEntryImpl;
|
||||||
|
@ -8,7 +10,7 @@ use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||||
use dbus::blocking::Connection;
|
use dbus::blocking::Connection;
|
||||||
use dbus::{Error, Path};
|
use dbus::{Error, Path};
|
||||||
use glib::clone;
|
use glib::clone;
|
||||||
use gtk::prelude::WidgetExt;
|
use gtk::prelude::{ButtonExt, WidgetExt};
|
||||||
use gtk::{gio, GestureClick};
|
use gtk::{gio, GestureClick};
|
||||||
use ReSet_Lib::bluetooth::bluetooth::BluetoothDevice;
|
use ReSet_Lib::bluetooth::bluetooth::BluetoothDevice;
|
||||||
|
|
||||||
|
@ -23,10 +25,7 @@ impl BluetoothEntry {
|
||||||
let entry: BluetoothEntry = Object::builder().build();
|
let entry: BluetoothEntry = Object::builder().build();
|
||||||
let entryImp = entry.imp();
|
let entryImp = entry.imp();
|
||||||
entryImp.resetBluetoothLabel.get().set_text(&device.name);
|
entryImp.resetBluetoothLabel.get().set_text(&device.name);
|
||||||
entryImp
|
entryImp.resetBluetoothAddress.get().set_text(&device.alias);
|
||||||
.resetBluetoothAddress
|
|
||||||
.get()
|
|
||||||
.set_text(&device.address);
|
|
||||||
// entryImp
|
// entryImp
|
||||||
// .resetBluetoothDeviceType
|
// .resetBluetoothDeviceType
|
||||||
// .get()
|
// .get()
|
||||||
|
@ -37,9 +36,17 @@ impl BluetoothEntry {
|
||||||
// DeviceTypes::Controller => Some("input-gaming-symbolic"),
|
// DeviceTypes::Controller => Some("input-gaming-symbolic"),
|
||||||
// DeviceTypes::None => Some("text-x-generic-symbolic"), // no generic bluetooth device icon found
|
// 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 gesture = GestureClick::new();
|
||||||
let connected = false;
|
let connected = device.connected;
|
||||||
// TODO implement this connected
|
|
||||||
entryImp.device.replace(device);
|
entryImp.device.replace(device);
|
||||||
gesture.connect_released(clone!(@weak entryImp => move |_, _, _, _| {
|
gesture.connect_released(clone!(@weak entryImp => move |_, _, _, _| {
|
||||||
let device = entryImp.device.borrow_mut();
|
let device = entryImp.device.borrow_mut();
|
||||||
|
@ -60,12 +67,15 @@ fn connect_to_device(path: Path<'static>) {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(bool,), Error> =
|
let _: Result<(bool,), Error> = proxy.method_call(
|
||||||
proxy.method_call("org.xetibo.ReSet", "ConnectToBluetoothDevice", (path,));
|
"org.Xetibo.ReSetBluetooth",
|
||||||
|
"ConnectToBluetoothDevice",
|
||||||
|
(path,),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,12 +83,15 @@ fn pair_with_device(path: Path<'static>) {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(bool,), Error> =
|
let _: Result<(bool,), Error> = proxy.method_call(
|
||||||
proxy.method_call("org.xetibo.ReSet", "PairWithBluetoothDevice", (path,));
|
"org.Xetibo.ReSetBluetooth",
|
||||||
|
"PairWithBluetoothDevice",
|
||||||
|
(path,),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,11 +99,27 @@ fn disconnect_from_device(path: Path<'static>) {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/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),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(bool,), Error> =
|
let _: Result<(bool,), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "DisconnectFromBluetoothDevice", (path,));
|
proxy.method_call("org.Xetibo.ReSetBluetooth", "RemoveDevicePairing", (path,));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,12 +141,12 @@ fn set_outputstream_volume(value: f64, index: u32, channels: u16) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> = proxy.method_call(
|
let _: Result<(), Error> = proxy.method_call(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetAudio",
|
||||||
"SetOutputStreamVolume",
|
"SetOutputStreamVolume",
|
||||||
(index, channels, value as u32),
|
(index, channels, value as u32),
|
||||||
);
|
);
|
||||||
|
@ -162,12 +162,12 @@ fn toggle_output_stream_mute(index: u32, muted: bool) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> =
|
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() {
|
// if res.is_err() {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
@ -180,12 +180,12 @@ fn set_source_of_output_stream(stream: u32, source: u32) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(bool,), Error> = proxy.method_call(
|
let _: Result<(bool,), Error> = proxy.method_call(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetAudio",
|
||||||
"SetSourceOfOutputStream",
|
"SetSourceOfOutputStream",
|
||||||
(stream, source),
|
(stream, source),
|
||||||
);
|
);
|
||||||
|
|
|
@ -248,12 +248,12 @@ pub fn populate_cards(input_box: Arc<SourceBox>) {
|
||||||
fn get_output_streams() -> Vec<OutputStream> {
|
fn get_output_streams() -> Vec<OutputStream> {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(Vec<OutputStream>,), Error> =
|
let res: Result<(Vec<OutputStream>,), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "ListOutputStreams", ());
|
proxy.method_call("org.Xetibo.ReSetAudio", "ListOutputStreams", ());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
@ -263,12 +263,12 @@ fn get_output_streams() -> Vec<OutputStream> {
|
||||||
fn get_sources() -> Vec<Source> {
|
fn get_sources() -> Vec<Source> {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(Vec<Source>,), Error> =
|
let res: Result<(Vec<Source>,), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "ListSources", ());
|
proxy.method_call("org.Xetibo.ReSetAudio", "ListSources", ());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
@ -278,11 +278,11 @@ fn get_sources() -> Vec<Source> {
|
||||||
fn get_cards() -> Vec<Card> {
|
fn get_cards() -> Vec<Card> {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(Vec<Card>,), Error> = proxy.method_call("org.xetibo.ReSet", "ListCards", ());
|
let res: Result<(Vec<Card>,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListCards", ());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
@ -292,12 +292,12 @@ fn get_cards() -> Vec<Card> {
|
||||||
fn get_default_source() -> Source {
|
fn get_default_source() -> Source {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(Source,), Error> =
|
let res: Result<(Source,), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "GetDefaultSource", ());
|
proxy.method_call("org.Xetibo.ReSetAudio", "GetDefaultSource", ());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
return Source::default();
|
return Source::default();
|
||||||
}
|
}
|
||||||
|
@ -306,33 +306,33 @@ fn get_default_source() -> Source {
|
||||||
|
|
||||||
pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) -> Connection {
|
pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) -> Connection {
|
||||||
let source_added = SourceAdded::match_rule(
|
let source_added = SourceAdded::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let source_removed = SourceRemoved::match_rule(
|
let source_removed = SourceRemoved::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let source_changed = SourceChanged::match_rule(
|
let source_changed = SourceChanged::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let output_stream_added = OutputStreamAdded::match_rule(
|
let output_stream_added = OutputStreamAdded::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let output_stream_removed = OutputStreamRemoved::match_rule(
|
let output_stream_removed = OutputStreamRemoved::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let output_stream_changed = OutputStreamChanged::match_rule(
|
let output_stream_changed = OutputStreamChanged::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
|
|
||||||
|
|
|
@ -94,12 +94,12 @@ pub fn set_source_volume(value: f64, index: u32, channels: u16) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> = proxy.method_call(
|
let _: Result<(), Error> = proxy.method_call(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetAudio",
|
||||||
"SetSourceVolume",
|
"SetSourceVolume",
|
||||||
(index, channels, value as u32),
|
(index, channels, value as u32),
|
||||||
);
|
);
|
||||||
|
@ -115,12 +115,12 @@ pub fn toggle_source_mute(index: u32, muted: bool) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> =
|
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() {
|
// if res.is_err() {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
@ -133,12 +133,12 @@ pub fn set_default_source(name: Arc<String>) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> =
|
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() {
|
// if res.is_err() {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -157,12 +157,12 @@ fn set_inputstream_volume(value: f64, index: u32, channels: u16) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> = proxy.method_call(
|
let _: Result<(), Error> = proxy.method_call(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetAudio",
|
||||||
"SetInputStreamVolume",
|
"SetInputStreamVolume",
|
||||||
(index, channels, value as u32),
|
(index, channels, value as u32),
|
||||||
);
|
);
|
||||||
|
@ -178,12 +178,12 @@ fn toggle_input_stream_mute(index: u32, muted: bool) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> =
|
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() {
|
// if res.is_err() {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
@ -196,12 +196,12 @@ fn set_sink_of_input_stream(stream: u32, sink: u32) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> =
|
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() {
|
// if res.is_err() {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -254,12 +254,12 @@ pub fn populate_cards(output_box: Arc<SinkBox>) {
|
||||||
fn get_input_streams() -> Vec<InputStream> {
|
fn get_input_streams() -> Vec<InputStream> {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(Vec<InputStream>,), Error> =
|
let res: Result<(Vec<InputStream>,), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "ListInputStreams", ());
|
proxy.method_call("org.Xetibo.ReSetAudio", "ListInputStreams", ());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
@ -269,11 +269,11 @@ fn get_input_streams() -> Vec<InputStream> {
|
||||||
fn get_sinks() -> Vec<Sink> {
|
fn get_sinks() -> Vec<Sink> {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(Vec<Sink>,), Error> = proxy.method_call("org.xetibo.ReSet", "ListSinks", ());
|
let res: Result<(Vec<Sink>,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListSinks", ());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
@ -283,11 +283,11 @@ fn get_sinks() -> Vec<Sink> {
|
||||||
fn get_default_sink() -> Sink {
|
fn get_default_sink() -> Sink {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
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() {
|
if res.is_err() {
|
||||||
return Sink::default();
|
return Sink::default();
|
||||||
}
|
}
|
||||||
|
@ -297,11 +297,11 @@ fn get_default_sink() -> Sink {
|
||||||
fn get_cards() -> Vec<Card> {
|
fn get_cards() -> Vec<Card> {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(Vec<Card>,), Error> = proxy.method_call("org.xetibo.ReSet", "ListCards", ());
|
let res: Result<(Vec<Card>,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListCards", ());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
@ -310,33 +310,33 @@ fn get_cards() -> Vec<Card> {
|
||||||
|
|
||||||
pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Connection {
|
pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Connection {
|
||||||
let sink_added = SinkAdded::match_rule(
|
let sink_added = SinkAdded::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let sink_removed = SinkRemoved::match_rule(
|
let sink_removed = SinkRemoved::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let sink_changed = SinkChanged::match_rule(
|
let sink_changed = SinkChanged::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let input_stream_added = InputStreamAdded::match_rule(
|
let input_stream_added = InputStreamAdded::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let input_stream_removed = InputStreamRemoved::match_rule(
|
let input_stream_removed = InputStreamRemoved::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let input_stream_changed = InputStreamChanged::match_rule(
|
let input_stream_changed = InputStreamChanged::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
|
|
||||||
|
|
|
@ -89,12 +89,12 @@ pub fn set_sink_volume(value: f64, index: u32, channels: u16) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> = proxy.method_call(
|
let _: Result<(), Error> = proxy.method_call(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetAudio",
|
||||||
"SetSinkVolume",
|
"SetSinkVolume",
|
||||||
(index, channels, value as u32),
|
(index, channels, value as u32),
|
||||||
);
|
);
|
||||||
|
@ -110,12 +110,12 @@ pub fn toggle_sink_mute(index: u32, muted: bool) -> bool {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> =
|
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() {
|
// if res.is_err() {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
@ -128,12 +128,12 @@ pub fn set_default_sink(name: Arc<String>) {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> =
|
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() {
|
// if res.is_err() {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
use adw::ComboRow;
|
use std::time::Duration;
|
||||||
|
|
||||||
use adw::gdk::pango::EllipsizeMode;
|
use adw::gdk::pango::EllipsizeMode;
|
||||||
use adw::prelude::ListModelExtManual;
|
use adw::prelude::ListModelExtManual;
|
||||||
|
use adw::ComboRow;
|
||||||
|
use dbus::blocking::{Connection, Proxy};
|
||||||
use glib::{Cast, Object};
|
use glib::{Cast, Object};
|
||||||
use gtk::{Align, SignalListItemFactory, StringObject};
|
|
||||||
use gtk::prelude::{GObjectPropertyExpressionExt, ListBoxRowExt, ListItemExt, WidgetExt};
|
use gtk::prelude::{GObjectPropertyExpressionExt, ListBoxRowExt, ListItemExt, WidgetExt};
|
||||||
|
use gtk::{Align, SignalListItemFactory, StringObject};
|
||||||
|
|
||||||
pub fn createDropdownLabelFactory() -> SignalListItemFactory {
|
pub fn createDropdownLabelFactory() -> SignalListItemFactory {
|
||||||
let factory = SignalListItemFactory::new();
|
let factory = SignalListItemFactory::new();
|
||||||
|
@ -20,7 +23,13 @@ pub fn createDropdownLabelFactory() -> SignalListItemFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setComboRowEllipsis(element: ComboRow) {
|
pub fn setComboRowEllipsis(element: ComboRow) {
|
||||||
for (i, child) in element.child().unwrap().observe_children().iter::<Object>().enumerate() {
|
for (i, child) in element
|
||||||
|
.child()
|
||||||
|
.unwrap()
|
||||||
|
.observe_children()
|
||||||
|
.iter::<Object>()
|
||||||
|
.enumerate()
|
||||||
|
{
|
||||||
if i == 2 {
|
if i == 2 {
|
||||||
if let Ok(object) = child {
|
if let Ok(object) = child {
|
||||||
if let Some(item) = object.downcast_ref::<gtk::Box>() {
|
if let Some(item) = object.downcast_ref::<gtk::Box>() {
|
||||||
|
|
|
@ -49,11 +49,11 @@ fn delete_connection(path: Path<'static>) {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let _: Result<(), Error> =
|
let _: Result<(), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "DeleteConnection", (path,));
|
proxy.method_call("org.Xetibo.ReSetWireless", "DeleteConnection", (path,));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,14 @@ use ReSet_Lib::network::connection::Connection as ResetConnection;
|
||||||
pub fn getConnectionSettings(path: Path<'static>) -> ResetConnection {
|
pub fn getConnectionSettings(path: Path<'static>) -> ResetConnection {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<
|
let res: Result<
|
||||||
(HashMap<String, HashMap<String, dbus::arg::Variant<Box<dyn RefArg>>>>,),
|
(HashMap<String, HashMap<String, dbus::arg::Variant<Box<dyn RefArg>>>>,),
|
||||||
Error,
|
Error,
|
||||||
> = proxy.method_call("org.xetibo.ReSet", "GetConnectionSettings", (path,));
|
> = proxy.method_call("org.xetibo.ReSetWireless", "GetConnectionSettings", (path,));
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
ResetConnection::default();
|
ResetConnection::default();
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,22 +112,22 @@ pub fn show_stored_connections(wifiBox: Arc<WifiBox>) {
|
||||||
pub fn dbus_start_network_events() {
|
pub fn dbus_start_network_events() {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
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<AccessPoint> {
|
pub fn get_access_points() -> Vec<AccessPoint> {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(Vec<AccessPoint>,), Error> =
|
let res: Result<(Vec<AccessPoint>,), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "ListAccessPoints", ());
|
proxy.method_call("org.Xetibo.ReSetWireless", "ListAccessPoints", ());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
@ -138,12 +138,12 @@ pub fn get_access_points() -> Vec<AccessPoint> {
|
||||||
pub fn get_stored_connections() -> Vec<(Path<'static>, Vec<u8>)> {
|
pub fn get_stored_connections() -> Vec<(Path<'static>, Vec<u8>)> {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(Vec<(Path<'static>, Vec<u8>)>,), Error> =
|
let res: Result<(Vec<(Path<'static>, Vec<u8>)>,), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "ListStoredConnections", ());
|
proxy.method_call("org.Xetibo.ReSetWireless", "ListStoredConnections", ());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("we got error...");
|
println!("we got error...");
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
|
@ -164,18 +164,18 @@ pub fn start_event_listener(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) {
|
||||||
let removed_ref = wifi_box.clone();
|
let removed_ref = wifi_box.clone();
|
||||||
let changed_ref = wifi_box.clone(); // TODO implement changed
|
let changed_ref = wifi_box.clone(); // TODO implement changed
|
||||||
let access_point_added = AccessPointAdded::match_rule(
|
let access_point_added = AccessPointAdded::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let access_point_removed = AccessPointRemoved::match_rule(
|
let access_point_removed = AccessPointRemoved::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let access_point_changed = AccessPointChanged::match_rule(
|
let access_point_changed = AccessPointChanged::match_rule(
|
||||||
Some(&"org.xetibo.ReSet".into()),
|
Some(&"org.Xetibo.ReSetDaemon".into()),
|
||||||
Some(&Path::from("/org/xetibo/ReSet")),
|
Some(&Path::from("/org/Xetibo/ReSetDaemon")),
|
||||||
)
|
)
|
||||||
.static_clone();
|
.static_clone();
|
||||||
let res = conn.add_match(access_point_added, move |ir: AccessPointAdded, _, _| {
|
let res = conn.add_match(access_point_added, move |ir: AccessPointAdded, _, _| {
|
||||||
|
|
|
@ -95,12 +95,12 @@ pub fn click_disconnect(entry: Arc<WifiEntry>) {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(10000),
|
Duration::from_millis(10000),
|
||||||
);
|
);
|
||||||
let res: Result<(bool,), Error> =
|
let res: Result<(bool,), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "DisconnectFromCurrentAccessPoint", ());
|
proxy.method_call("org.Xetibo.ReSetWireless", "DisconnectFromCurrentAccessPoint", ());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("res of disconnect was error bro");
|
println!("res of disconnect was error bro");
|
||||||
return;
|
return;
|
||||||
|
@ -120,12 +120,12 @@ pub fn click_stored_network(entry: Arc<WifiEntry>) {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(10000),
|
Duration::from_millis(10000),
|
||||||
);
|
);
|
||||||
let res: Result<(bool,), Error> = proxy.method_call(
|
let res: Result<(bool,), Error> = proxy.method_call(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetWireless",
|
||||||
"ConnectToKnownAccessPoint",
|
"ConnectToKnownAccessPoint",
|
||||||
(access_point,),
|
(access_point,),
|
||||||
);
|
);
|
||||||
|
@ -170,12 +170,12 @@ pub fn click_new_network(entry: Arc<WifiEntry>) {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(10000),
|
Duration::from_millis(10000),
|
||||||
);
|
);
|
||||||
let res: Result<(bool,), Error> = proxy.method_call(
|
let res: Result<(bool,), Error> = proxy.method_call(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetWireless",
|
||||||
"ConnectToNewAccessPoint",
|
"ConnectToNewAccessPoint",
|
||||||
(access_point, password),
|
(access_point, password),
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use crate::components::base::settingBox::SettingBox;
|
use crate::components::base::settingBox::SettingBox;
|
||||||
use crate::components::base::utils::{start_audio_listener, Listeners};
|
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::input::sourceBox::{populate_sources, SourceBox};
|
||||||
use crate::components::output::sinkBox::{populate_sinks, SinkBox};
|
use crate::components::output::sinkBox::{populate_sinks, SinkBox};
|
||||||
use crate::components::wifi::wifiBox::{
|
use crate::components::wifi::wifiBox::{
|
||||||
|
@ -22,6 +22,7 @@ pub const HANDLE_CONNECTIVITY_CLICK: fn(Arc<Listeners>, FlowBox) =
|
||||||
scanForWifi(listeners.clone(), wifiBox.clone());
|
scanForWifi(listeners.clone(), wifiBox.clone());
|
||||||
let wifiFrame = wrapInFrame(SettingBox::new(&*wifiBox));
|
let wifiFrame = wrapInFrame(SettingBox::new(&*wifiBox));
|
||||||
let bluetooth_box = Arc::new(BluetoothBox::new());
|
let bluetooth_box = Arc::new(BluetoothBox::new());
|
||||||
|
populate_conntected_bluetooth_devices(bluetooth_box.clone());
|
||||||
start_bluetooth_listener(listeners.clone(), bluetooth_box.clone());
|
start_bluetooth_listener(listeners.clone(), bluetooth_box.clone());
|
||||||
let bluetoothFrame = wrapInFrame(SettingBox::new(&*bluetooth_box));
|
let bluetoothFrame = wrapInFrame(SettingBox::new(&*bluetooth_box));
|
||||||
resetMain.remove_all();
|
resetMain.remove_all();
|
||||||
|
@ -50,6 +51,7 @@ pub const HANDLE_BLUETOOTH_CLICK: fn(Arc<Listeners>, FlowBox) =
|
||||||
listeners.stop_audio_listener();
|
listeners.stop_audio_listener();
|
||||||
let bluetooth_box = Arc::new(BluetoothBox::new());
|
let bluetooth_box = Arc::new(BluetoothBox::new());
|
||||||
start_bluetooth_listener(listeners.clone(), bluetooth_box.clone());
|
start_bluetooth_listener(listeners.clone(), bluetooth_box.clone());
|
||||||
|
populate_conntected_bluetooth_devices(bluetooth_box.clone());
|
||||||
let bluetoothFrame = wrapInFrame(SettingBox::new(&*bluetooth_box));
|
let bluetoothFrame = wrapInFrame(SettingBox::new(&*bluetooth_box));
|
||||||
resetMain.remove_all();
|
resetMain.remove_all();
|
||||||
resetMain.insert(&bluetoothFrame, -1);
|
resetMain.insert(&bluetoothFrame, -1);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
use adw::BreakpointCondition;
|
||||||
use adw::glib::clone;
|
use adw::glib::clone;
|
||||||
use adw::subclass::prelude::ObjectSubclassIsExt;
|
use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||||
use adw::BreakpointCondition;
|
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
|
use gtk::{Application, gio, glib, ListBoxRow, Orientation};
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk::{gio, glib, Application, ListBoxRow, Orientation};
|
|
||||||
|
|
||||||
use crate::components::window::handleSidebarClick::*;
|
use crate::components::window::handleSidebarClick::*;
|
||||||
use crate::components::window::sidebarEntry::SidebarEntry;
|
use crate::components::window::sidebarEntry::SidebarEntry;
|
||||||
|
@ -18,6 +18,7 @@ glib::wrapper! {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for Window {}
|
unsafe impl Send for Window {}
|
||||||
|
|
||||||
unsafe impl Sync for Window {}
|
unsafe impl Sync for Window {}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
@ -29,15 +30,11 @@ impl Window {
|
||||||
pub fn setupCallback(&self) {
|
pub fn setupCallback(&self) {
|
||||||
let selfImp = self.imp();
|
let selfImp = self.imp();
|
||||||
|
|
||||||
selfImp
|
selfImp.resetSearchEntry.connect_search_changed(clone!(@ weak self as window => move |_| {
|
||||||
.resetSearchEntry
|
|
||||||
.connect_search_changed(clone!(@ weak self as window => move |_| {
|
|
||||||
window.filterList();
|
window.filterList();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
selfImp
|
selfImp.resetSideBarToggle.connect_clicked(clone!(@ weak self as window => move |_| {
|
||||||
.resetSideBarToggle
|
|
||||||
.connect_clicked(clone!(@ weak self as window => move |_| {
|
|
||||||
window.toggleSidebar();
|
window.toggleSidebar();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -49,9 +46,7 @@ impl Window {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
selfImp
|
selfImp.resetClose.connect_clicked(clone!(@ weak self as window => move |_| {
|
||||||
.resetClose
|
|
||||||
.connect_clicked(clone!(@ weak self as window => move |_| {
|
|
||||||
window.close();
|
window.close();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -63,9 +58,7 @@ impl Window {
|
||||||
|
|
||||||
pub fn handleDynamicSidebar(&self) {
|
pub fn handleDynamicSidebar(&self) {
|
||||||
let selfImp = self.imp();
|
let selfImp = self.imp();
|
||||||
selfImp
|
selfImp.resetSidebarBreakpoint.set_condition(BreakpointCondition::parse("max-width: 700sp").as_ref().ok());
|
||||||
.resetSidebarBreakpoint
|
|
||||||
.set_condition(BreakpointCondition::parse("max-width: 700sp").as_ref().ok());
|
|
||||||
selfImp.resetSidebarBreakpoint.add_setter(
|
selfImp.resetSidebarBreakpoint.add_setter(
|
||||||
&Object::from(selfImp.resetOverlaySplitView.get()),
|
&Object::from(selfImp.resetOverlaySplitView.get()),
|
||||||
"collapsed",
|
"collapsed",
|
||||||
|
@ -88,25 +81,13 @@ impl Window {
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if mainEntry
|
if mainEntry.imp().name.borrow().to_lowercase().contains(&text.to_lowercase()) {
|
||||||
.imp()
|
|
||||||
.name
|
|
||||||
.borrow()
|
|
||||||
.to_lowercase()
|
|
||||||
.contains(&text.to_lowercase())
|
|
||||||
{
|
|
||||||
mainEntry.set_visible(true);
|
mainEntry.set_visible(true);
|
||||||
} else {
|
} else {
|
||||||
mainEntry.set_visible(false);
|
mainEntry.set_visible(false);
|
||||||
}
|
}
|
||||||
for subEntry in subEntries {
|
for subEntry in subEntries {
|
||||||
if subEntry
|
if subEntry.imp().name.borrow().to_lowercase().contains(&text.to_lowercase()) {
|
||||||
.imp()
|
|
||||||
.name
|
|
||||||
.borrow()
|
|
||||||
.to_lowercase()
|
|
||||||
.contains(&text.to_lowercase())
|
|
||||||
{
|
|
||||||
subEntry.set_visible(true);
|
subEntry.set_visible(true);
|
||||||
mainEntry.set_visible(true);
|
mainEntry.set_visible(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -226,6 +207,10 @@ impl Window {
|
||||||
peripheralsList,
|
peripheralsList,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
selfImp.resetSidebarList.connect_row_activated(clone!(@ weak selfImp => move |_, _| {
|
||||||
|
selfImp.resetSearchEntry.set_text("");
|
||||||
|
}));
|
||||||
|
|
||||||
for (mainEntry, subEntries) in sidebarEntries.iter() {
|
for (mainEntry, subEntries) in sidebarEntries.iter() {
|
||||||
selfImp.resetSidebarList.append(mainEntry);
|
selfImp.resetSidebarList.append(mainEntry);
|
||||||
for subEntry in subEntries {
|
for subEntry in subEntries {
|
||||||
|
@ -241,9 +226,7 @@ impl Window {
|
||||||
|
|
||||||
pub fn setupPopoverButtons(&self) {
|
pub fn setupPopoverButtons(&self) {
|
||||||
let selfImp = self.imp();
|
let selfImp = self.imp();
|
||||||
selfImp
|
selfImp.resetAboutButton.connect_clicked(clone!(@ weak self as window => move |_| {
|
||||||
.resetAboutButton
|
|
||||||
.connect_clicked(clone!(@ weak self as window => move |_| {
|
|
||||||
let dialog = adw::AboutWindow::builder()
|
let dialog = adw::AboutWindow::builder()
|
||||||
.application_name("ReSet")
|
.application_name("ReSet")
|
||||||
.application_icon("ReSet")
|
.application_icon("ReSet")
|
||||||
|
@ -262,16 +245,12 @@ impl Window {
|
||||||
window.imp().resetPopoverMenu.popdown();
|
window.imp().resetPopoverMenu.popdown();
|
||||||
dialog.present();
|
dialog.present();
|
||||||
}));
|
}));
|
||||||
selfImp
|
selfImp.resetPreferenceButton.connect_clicked(clone!(@weak self as window => move |_| {
|
||||||
.resetPreferenceButton
|
|
||||||
.connect_clicked(clone!(@weak self as window => move |_| {
|
|
||||||
let preferences = adw::PreferencesWindow::builder().build();
|
let preferences = adw::PreferencesWindow::builder().build();
|
||||||
window.imp().resetPopoverMenu.popdown();
|
window.imp().resetPopoverMenu.popdown();
|
||||||
preferences.present();
|
preferences.present();
|
||||||
}));
|
}));
|
||||||
selfImp
|
selfImp.resetShortcutsButton.connect_clicked(clone!(@weak self as window => move |_| {
|
||||||
.resetShortcutsButton
|
|
||||||
.connect_clicked(clone!(@weak self as window => move |_| {
|
|
||||||
let shortcuts = gtk::ShortcutsWindow::builder().build();
|
let shortcuts = gtk::ShortcutsWindow::builder().build();
|
||||||
window.imp().resetPopoverMenu.popdown();
|
window.imp().resetPopoverMenu.popdown();
|
||||||
shortcuts.present();
|
shortcuts.present();
|
||||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -34,6 +34,7 @@ async fn main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.connect_activate(buildUI);
|
app.connect_activate(buildUI);
|
||||||
|
app.connect_shutdown(shutdown);
|
||||||
app.run();
|
app.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,15 +55,28 @@ fn buildUI(app: &Application) {
|
||||||
window.present();
|
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() {
|
async fn daemon_check() {
|
||||||
let handle = thread::spawn(|| {
|
let handle = thread::spawn(|| {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.Xetibo.ReSetDaemon",
|
||||||
"/org/xetibo/ReSet",
|
"/org/Xetibo/ReSetDaemon",
|
||||||
Duration::from_millis(100),
|
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
|
res
|
||||||
});
|
});
|
||||||
let res = handle.join();
|
let res = handle.join();
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="resetBluetoothButton">
|
<object class="GtkButton" id="resetBluetoothButton">
|
||||||
<property name="has-frame">False</property>
|
<property name="has-frame">False</property>
|
||||||
<property name="icon-name">emblem-system-symbolic</property>
|
<property name="icon-name">user-trash-symbolic</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -165,9 +165,9 @@
|
||||||
(11,2,"GtkBox","resetBluetoothEntry",None,None,None,None,None,None),
|
(11,2,"GtkBox","resetBluetoothEntry",None,None,None,None,None,None),
|
||||||
(11,3,"GtkImage","resetBluetoothDeviceType",2,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,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,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,11,"GtkBox","resetAudioInput",None,None,None,None,None,None),
|
||||||
(12,12,"GtkLabel",None,11,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),
|
(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,"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,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","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,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","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),
|
(11,7,"GtkLabel","label","LoremIpsum Wireless Mouse",None,None,None,None,None,None,None,None,None),
|
||||||
|
|
Loading…
Reference in a new issue