mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-12 08:28:32 +02:00
feat: Add dynamic bluetooth buttons
This commit is contained in:
parent
741d678ffd
commit
286302354e
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||||
description = "A wip universal Linux settings application."
|
description = "A wip universal Linux settings application."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
reset_daemon = "0.4.3"
|
reset_daemon = "0.4.5"
|
||||||
re_set-lib = "0.6.5"
|
re_set-lib = "0.6.5"
|
||||||
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"
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
{
|
{
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"archive-type": "tar-gzip",
|
"archive-type": "tar-gzip",
|
||||||
"url": "https://static.crates.io/crates/ReSet-Lib/ReSet-Lib-0.6.1.crate",
|
"url": "https://static.crates.io/crates/ReSet-Lib/ReSet-Lib-0.6.3.crate",
|
||||||
"sha256": "f0339936189c09ce78f125841314a08cf797e11a762b4eb2084f3434b2b455f5",
|
"sha256": "299882cb1f2c9516ffb3ad541b103f495c53c1fc424d39d6b729bfea35640d9d",
|
||||||
"dest": "cargo/vendor/ReSet-Lib-0.6.1"
|
"dest": "cargo/vendor/ReSet-Lib-0.6.3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "inline",
|
"type": "inline",
|
||||||
"contents": "{\"package\": \"f0339936189c09ce78f125841314a08cf797e11a762b4eb2084f3434b2b455f5\", \"files\": {}}",
|
"contents": "{\"package\": \"299882cb1f2c9516ffb3ad541b103f495c53c1fc424d39d6b729bfea35640d9d\", \"files\": {}}",
|
||||||
"dest": "cargo/vendor/ReSet-Lib-0.6.1",
|
"dest": "cargo/vendor/ReSet-Lib-0.6.3",
|
||||||
"dest-filename": ".cargo-checksum.json"
|
"dest-filename": ".cargo-checksum.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -821,14 +821,14 @@
|
||||||
{
|
{
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"archive-type": "tar-gzip",
|
"archive-type": "tar-gzip",
|
||||||
"url": "https://static.crates.io/crates/mio/mio-0.8.9.crate",
|
"url": "https://static.crates.io/crates/mio/mio-0.8.10.crate",
|
||||||
"sha256": "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0",
|
"sha256": "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09",
|
||||||
"dest": "cargo/vendor/mio-0.8.9"
|
"dest": "cargo/vendor/mio-0.8.10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "inline",
|
"type": "inline",
|
||||||
"contents": "{\"package\": \"3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0\", \"files\": {}}",
|
"contents": "{\"package\": \"8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09\", \"files\": {}}",
|
||||||
"dest": "cargo/vendor/mio-0.8.9",
|
"dest": "cargo/vendor/mio-0.8.10",
|
||||||
"dest-filename": ".cargo-checksum.json"
|
"dest-filename": ".cargo-checksum.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -886,14 +886,14 @@
|
||||||
{
|
{
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"archive-type": "tar-gzip",
|
"archive-type": "tar-gzip",
|
||||||
"url": "https://static.crates.io/crates/once_cell/once_cell-1.18.0.crate",
|
"url": "https://static.crates.io/crates/once_cell/once_cell-1.19.0.crate",
|
||||||
"sha256": "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d",
|
"sha256": "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92",
|
||||||
"dest": "cargo/vendor/once_cell-1.18.0"
|
"dest": "cargo/vendor/once_cell-1.19.0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "inline",
|
"type": "inline",
|
||||||
"contents": "{\"package\": \"dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d\", \"files\": {}}",
|
"contents": "{\"package\": \"3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92\", \"files\": {}}",
|
||||||
"dest": "cargo/vendor/once_cell-1.18.0",
|
"dest": "cargo/vendor/once_cell-1.19.0",
|
||||||
"dest-filename": ".cargo-checksum.json"
|
"dest-filename": ".cargo-checksum.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -977,14 +977,14 @@
|
||||||
{
|
{
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"archive-type": "tar-gzip",
|
"archive-type": "tar-gzip",
|
||||||
"url": "https://static.crates.io/crates/proc-macro-crate/proc-macro-crate-2.0.0.crate",
|
"url": "https://static.crates.io/crates/proc-macro-crate/proc-macro-crate-2.0.1.crate",
|
||||||
"sha256": "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8",
|
"sha256": "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a",
|
||||||
"dest": "cargo/vendor/proc-macro-crate-2.0.0"
|
"dest": "cargo/vendor/proc-macro-crate-2.0.1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "inline",
|
"type": "inline",
|
||||||
"contents": "{\"package\": \"7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8\", \"files\": {}}",
|
"contents": "{\"package\": \"97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a\", \"files\": {}}",
|
||||||
"dest": "cargo/vendor/proc-macro-crate-2.0.0",
|
"dest": "cargo/vendor/proc-macro-crate-2.0.1",
|
||||||
"dest-filename": ".cargo-checksum.json"
|
"dest-filename": ".cargo-checksum.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1068,14 +1068,14 @@
|
||||||
{
|
{
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"archive-type": "tar-gzip",
|
"archive-type": "tar-gzip",
|
||||||
"url": "https://static.crates.io/crates/reset_daemon/reset_daemon-0.3.7.crate",
|
"url": "https://static.crates.io/crates/reset_daemon/reset_daemon-0.3.9.crate",
|
||||||
"sha256": "94cf69e4ef90fde3fa13c27f0d31565ff260dc6191aaabe771d52db12d49b30f",
|
"sha256": "7bc399eebff1f7e3ea2c642b83eabf76425eaed6d3c955645691b24aa6b1504c",
|
||||||
"dest": "cargo/vendor/reset_daemon-0.3.7"
|
"dest": "cargo/vendor/reset_daemon-0.3.9"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "inline",
|
"type": "inline",
|
||||||
"contents": "{\"package\": \"94cf69e4ef90fde3fa13c27f0d31565ff260dc6191aaabe771d52db12d49b30f\", \"files\": {}}",
|
"contents": "{\"package\": \"7bc399eebff1f7e3ea2c642b83eabf76425eaed6d3c955645691b24aa6b1504c\", \"files\": {}}",
|
||||||
"dest": "cargo/vendor/reset_daemon-0.3.7",
|
"dest": "cargo/vendor/reset_daemon-0.3.9",
|
||||||
"dest-filename": ".cargo-checksum.json"
|
"dest-filename": ".cargo-checksum.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1302,27 +1302,27 @@
|
||||||
{
|
{
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"archive-type": "tar-gzip",
|
"archive-type": "tar-gzip",
|
||||||
"url": "https://static.crates.io/crates/toml/toml-0.8.8.crate",
|
"url": "https://static.crates.io/crates/toml/toml-0.8.2.crate",
|
||||||
"sha256": "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35",
|
"sha256": "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d",
|
||||||
"dest": "cargo/vendor/toml-0.8.8"
|
"dest": "cargo/vendor/toml-0.8.2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "inline",
|
"type": "inline",
|
||||||
"contents": "{\"package\": \"a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35\", \"files\": {}}",
|
"contents": "{\"package\": \"185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d\", \"files\": {}}",
|
||||||
"dest": "cargo/vendor/toml-0.8.8",
|
"dest": "cargo/vendor/toml-0.8.2",
|
||||||
"dest-filename": ".cargo-checksum.json"
|
"dest-filename": ".cargo-checksum.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"archive-type": "tar-gzip",
|
"archive-type": "tar-gzip",
|
||||||
"url": "https://static.crates.io/crates/toml_datetime/toml_datetime-0.6.5.crate",
|
"url": "https://static.crates.io/crates/toml_datetime/toml_datetime-0.6.3.crate",
|
||||||
"sha256": "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1",
|
"sha256": "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b",
|
||||||
"dest": "cargo/vendor/toml_datetime-0.6.5"
|
"dest": "cargo/vendor/toml_datetime-0.6.3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "inline",
|
"type": "inline",
|
||||||
"contents": "{\"package\": \"3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1\", \"files\": {}}",
|
"contents": "{\"package\": \"7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b\", \"files\": {}}",
|
||||||
"dest": "cargo/vendor/toml_datetime-0.6.5",
|
"dest": "cargo/vendor/toml_datetime-0.6.3",
|
||||||
"dest-filename": ".cargo-checksum.json"
|
"dest-filename": ".cargo-checksum.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1341,27 +1341,14 @@
|
||||||
{
|
{
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"archive-type": "tar-gzip",
|
"archive-type": "tar-gzip",
|
||||||
"url": "https://static.crates.io/crates/toml_edit/toml_edit-0.20.7.crate",
|
"url": "https://static.crates.io/crates/toml_edit/toml_edit-0.20.2.crate",
|
||||||
"sha256": "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81",
|
"sha256": "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338",
|
||||||
"dest": "cargo/vendor/toml_edit-0.20.7"
|
"dest": "cargo/vendor/toml_edit-0.20.2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "inline",
|
"type": "inline",
|
||||||
"contents": "{\"package\": \"70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81\", \"files\": {}}",
|
"contents": "{\"package\": \"396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338\", \"files\": {}}",
|
||||||
"dest": "cargo/vendor/toml_edit-0.20.7",
|
"dest": "cargo/vendor/toml_edit-0.20.2",
|
||||||
"dest-filename": ".cargo-checksum.json"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "archive",
|
|
||||||
"archive-type": "tar-gzip",
|
|
||||||
"url": "https://static.crates.io/crates/toml_edit/toml_edit-0.21.0.crate",
|
|
||||||
"sha256": "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03",
|
|
||||||
"dest": "cargo/vendor/toml_edit-0.21.0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "inline",
|
|
||||||
"contents": "{\"package\": \"d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03\", \"files\": {}}",
|
|
||||||
"dest": "cargo/vendor/toml_edit-0.21.0",
|
|
||||||
"dest-filename": ".cargo-checksum.json"
|
"dest-filename": ".cargo-checksum.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1575,14 +1562,14 @@
|
||||||
{
|
{
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"archive-type": "tar-gzip",
|
"archive-type": "tar-gzip",
|
||||||
"url": "https://static.crates.io/crates/winnow/winnow-0.5.19.crate",
|
"url": "https://static.crates.io/crates/winnow/winnow-0.5.26.crate",
|
||||||
"sha256": "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b",
|
"sha256": "b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff",
|
||||||
"dest": "cargo/vendor/winnow-0.5.19"
|
"dest": "cargo/vendor/winnow-0.5.26"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "inline",
|
"type": "inline",
|
||||||
"contents": "{\"package\": \"829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b\", \"files\": {}}",
|
"contents": "{\"package\": \"b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff\", \"files\": {}}",
|
||||||
"dest": "cargo/vendor/winnow-0.5.19",
|
"dest": "cargo/vendor/winnow-0.5.26",
|
||||||
"dest-filename": ".cargo-checksum.json"
|
"dest-filename": ".cargo-checksum.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,6 +37,10 @@ impl BluetoothBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// handle bonded -> this means saved but not connected
|
||||||
|
// handle rssi below x -> don't show device
|
||||||
|
|
||||||
fn setup_callbacks(
|
fn setup_callbacks(
|
||||||
listeners: Arc<Listeners>,
|
listeners: Arc<Listeners>,
|
||||||
bluetooth_box: Arc<BluetoothBox>,
|
bluetooth_box: Arc<BluetoothBox>,
|
||||||
|
@ -110,6 +114,7 @@ fn setup_callbacks(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn populate_conntected_bluetooth_devices(bluetooth_box: Arc<BluetoothBox>) {
|
pub fn populate_conntected_bluetooth_devices(bluetooth_box: Arc<BluetoothBox>) {
|
||||||
|
// TODO handle saved devices -> they also exist
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let ref_box = bluetooth_box.clone();
|
let ref_box = bluetooth_box.clone();
|
||||||
let devices = get_connected_devices();
|
let devices = get_connected_devices();
|
||||||
|
@ -177,10 +182,10 @@ pub fn populate_conntected_bluetooth_devices(bluetooth_box: Arc<BluetoothBox>) {
|
||||||
for device in devices {
|
for device in devices {
|
||||||
let path = device.path.clone();
|
let path = device.path.clone();
|
||||||
let connected = device.connected;
|
let connected = device.connected;
|
||||||
let bluetooth_entry = BluetoothEntry::new(&device);
|
let bluetooth_entry = BluetoothEntry::new(device);
|
||||||
imp.available_devices
|
imp.available_devices
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.insert(path, (bluetooth_entry.clone(), device));
|
.insert(path, bluetooth_entry.clone());
|
||||||
if connected {
|
if connected {
|
||||||
imp.reset_bluetooth_connected_devices.add(&*bluetooth_entry);
|
imp.reset_bluetooth_connected_devices.add(&*bluetooth_entry);
|
||||||
} else {
|
} else {
|
||||||
|
@ -195,10 +200,8 @@ pub fn populate_conntected_bluetooth_devices(bluetooth_box: Arc<BluetoothBox>) {
|
||||||
pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<BluetoothBox>) {
|
pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<BluetoothBox>) {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
if listeners.bluetooth_listener.load(Ordering::SeqCst) {
|
if listeners.bluetooth_listener.load(Ordering::SeqCst) {
|
||||||
println!("bluetooth listener was active");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
println!("starting bluetooth listener");
|
|
||||||
|
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
|
@ -230,17 +233,15 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
|
||||||
|
|
||||||
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");
|
|
||||||
glib::spawn_future(async move {
|
glib::spawn_future(async move {
|
||||||
glib::idle_add_once(move || {
|
glib::idle_add_once(move || {
|
||||||
println!("{}", ir.bluetooth_device.icon);
|
|
||||||
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 connected = ir.bluetooth_device.connected;
|
||||||
let bluetooth_entry = BluetoothEntry::new(&ir.bluetooth_device);
|
let bluetooth_entry = BluetoothEntry::new(ir.bluetooth_device);
|
||||||
imp.available_devices
|
imp.available_devices
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.insert(path, (bluetooth_entry.clone(), ir.bluetooth_device));
|
.insert(path, bluetooth_entry.clone());
|
||||||
if connected {
|
if connected {
|
||||||
imp.reset_bluetooth_connected_devices.add(&*bluetooth_entry);
|
imp.reset_bluetooth_connected_devices.add(&*bluetooth_entry);
|
||||||
} else {
|
} else {
|
||||||
|
@ -251,70 +252,73 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on bluetooth device add");
|
println!("fail on bluetooth device add event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = conn.add_match(device_removed, move |ir: BluetoothDeviceRemoved, _, _| {
|
let res = conn.add_match(device_removed, move |ir: BluetoothDeviceRemoved, _, _| {
|
||||||
let bluetooth_box = device_removed_box.clone();
|
let bluetooth_box = device_removed_box.clone();
|
||||||
println!("removed");
|
|
||||||
glib::spawn_future(async move {
|
glib::spawn_future(async move {
|
||||||
glib::idle_add_once(move || {
|
glib::idle_add_once(move || {
|
||||||
let imp = bluetooth_box.imp();
|
let imp = bluetooth_box.imp();
|
||||||
let map = imp.available_devices.borrow_mut();
|
let mut map = imp.available_devices.borrow_mut();
|
||||||
if let Some(list_entry) = map.get(&ir.bluetooth_device) {
|
if let Some(list_entry) = map.remove(&ir.bluetooth_device) {
|
||||||
imp.reset_bluetooth_connected_devices.remove(&*list_entry.0);
|
if list_entry.imp().bluetooth_device.borrow().connected {
|
||||||
|
imp.reset_bluetooth_connected_devices.remove(&*list_entry);
|
||||||
|
} else {
|
||||||
|
imp.reset_bluetooth_available_devices.remove(&*list_entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on bluetooth device remove");
|
println!("fail on bluetooth device remove event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = conn.add_match(device_changed, move |ir: BluetoothDeviceChanged, _, _| {
|
let res = conn.add_match(device_changed, move |ir: BluetoothDeviceChanged, _, _| {
|
||||||
let bluetooth_box = device_changed_box.clone();
|
let bluetooth_box = device_changed_box.clone();
|
||||||
println!("changed");
|
|
||||||
glib::spawn_future(async move {
|
glib::spawn_future(async move {
|
||||||
glib::idle_add_once(move || {
|
glib::idle_add_once(move || {
|
||||||
let imp = bluetooth_box.imp();
|
let imp = bluetooth_box.imp();
|
||||||
let map = imp.available_devices.borrow_mut();
|
let mut map = imp.available_devices.borrow_mut();
|
||||||
if let Some(list_entry) = map.get(&ir.bluetooth_device.path) {
|
if let Some(list_entry) = map.get_mut(&ir.bluetooth_device.path) {
|
||||||
if list_entry.1.connected != ir.bluetooth_device.connected {
|
let mut existing_bluetooth_device =
|
||||||
|
list_entry.imp().bluetooth_device.borrow_mut();
|
||||||
|
if existing_bluetooth_device.connected != ir.bluetooth_device.connected {
|
||||||
if ir.bluetooth_device.connected {
|
if ir.bluetooth_device.connected {
|
||||||
imp.reset_bluetooth_connected_devices.add(&*list_entry.0);
|
imp.reset_bluetooth_connected_devices.add(&**list_entry);
|
||||||
imp.reset_bluetooth_available_devices.remove(&*list_entry.0);
|
imp.reset_bluetooth_available_devices.remove(&**list_entry);
|
||||||
} else {
|
} else {
|
||||||
imp.reset_bluetooth_available_devices.add(&*list_entry.0);
|
imp.reset_bluetooth_available_devices.add(&**list_entry);
|
||||||
imp.reset_bluetooth_connected_devices.remove(&*list_entry.0);
|
imp.reset_bluetooth_connected_devices.remove(&**list_entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if list_entry.1.paired != ir.bluetooth_device.paired {
|
if existing_bluetooth_device.bonded != ir.bluetooth_device.bonded {
|
||||||
if ir.bluetooth_device.paired {
|
if ir.bluetooth_device.bonded {
|
||||||
list_entry
|
list_entry
|
||||||
.0
|
|
||||||
.imp()
|
.imp()
|
||||||
.remove_device_button
|
.remove_device_button
|
||||||
.borrow()
|
.borrow()
|
||||||
.set_sensitive(true);
|
.set_sensitive(true);
|
||||||
} else {
|
} else {
|
||||||
list_entry
|
list_entry
|
||||||
.0
|
|
||||||
.imp()
|
.imp()
|
||||||
.remove_device_button
|
.remove_device_button
|
||||||
.borrow()
|
.borrow()
|
||||||
.set_sensitive(false);
|
.set_sensitive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*existing_bluetooth_device = ir.bluetooth_device;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on bluetooth device remove");
|
println!("fail on bluetooth device remove event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,25 +329,23 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
|
||||||
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) {
|
||||||
println!("stopping bluetooth listener");
|
let _: Result<(), Error> =
|
||||||
|
proxy.method_call("org.Xetibo.ReSetBluetooth", "StopBluetoothListener", ());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if listener_active && time.elapsed().unwrap() > Duration::from_millis(25000) {
|
if listener_active && time.elapsed().unwrap() > Duration::from_millis(10000) {
|
||||||
listener_active = false;
|
listener_active = false;
|
||||||
let instance_ref = loop_box.clone();
|
let instance_ref = loop_box.clone();
|
||||||
glib::spawn_future(async move {
|
glib::spawn_future(async move {
|
||||||
glib::idle_add_once(move || {
|
glib::idle_add_once(move || {
|
||||||
let imp = instance_ref.imp();
|
instance_ref
|
||||||
let mut entries = imp.available_devices.borrow_mut();
|
.imp()
|
||||||
for entry in entries.iter() {
|
.reset_bluetooth_refresh_button
|
||||||
imp.reset_bluetooth_available_devices.remove(&*entry.1 .0);
|
.set_sensitive(true);
|
||||||
}
|
|
||||||
entries.clear();
|
|
||||||
imp.reset_bluetooth_refresh_button.set_sensitive(true);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
let _: Result<(), Error> =
|
let _: Result<(), Error> =
|
||||||
proxy.method_call("org.Xetibo.ReSetBluetooth", "StopBluetoothListener", ());
|
proxy.method_call("org.Xetibo.ReSetBluetooth", "StopBluetoothScan", ());
|
||||||
}
|
}
|
||||||
if !listener_active && listeners.bluetooth_scan_requested.load(Ordering::SeqCst) {
|
if !listener_active && listeners.bluetooth_scan_requested.load(Ordering::SeqCst) {
|
||||||
listeners
|
listeners
|
||||||
|
|
|
@ -3,7 +3,7 @@ use dbus::Path;
|
||||||
use gtk::subclass::prelude::*;
|
use gtk::subclass::prelude::*;
|
||||||
use gtk::{glib, Button, CompositeTemplate, Switch};
|
use gtk::{glib, Button, CompositeTemplate, Switch};
|
||||||
use gtk::{prelude::*, StringList};
|
use gtk::{prelude::*, StringList};
|
||||||
use re_set_lib::bluetooth::bluetooth_structures::{BluetoothAdapter, BluetoothDevice};
|
use re_set_lib::bluetooth::bluetooth_structures::BluetoothAdapter;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
|
@ -12,8 +12,7 @@ use crate::components::base::list_entry::ListEntry;
|
||||||
use crate::components::bluetooth::bluetooth_box;
|
use crate::components::bluetooth::bluetooth_box;
|
||||||
use crate::components::bluetooth::bluetooth_entry::BluetoothEntry;
|
use crate::components::bluetooth::bluetooth_entry::BluetoothEntry;
|
||||||
|
|
||||||
type BluetoothMap =
|
type BluetoothMap = RefCell<HashMap<Path<'static>, Arc<BluetoothEntry>>>;
|
||||||
RefCell<HashMap<Path<'static>, (Arc<BluetoothEntry>, BluetoothDevice)>>;
|
|
||||||
|
|
||||||
#[derive(Default, CompositeTemplate)]
|
#[derive(Default, CompositeTemplate)]
|
||||||
#[template(resource = "/org/Xetibo/ReSet/resetBluetooth.ui")]
|
#[template(resource = "/org/Xetibo/ReSet/resetBluetooth.ui")]
|
||||||
|
|
|
@ -23,10 +23,11 @@ unsafe impl Send for BluetoothEntry {}
|
||||||
unsafe impl Sync for BluetoothEntry {}
|
unsafe impl Sync for BluetoothEntry {}
|
||||||
|
|
||||||
impl BluetoothEntry {
|
impl BluetoothEntry {
|
||||||
pub fn new(device: &BluetoothDevice) -> Arc<Self> {
|
pub fn new(device: BluetoothDevice) -> Arc<Self> {
|
||||||
let entry: Arc<BluetoothEntry> = Arc::new(Object::builder().build());
|
let entry: Arc<BluetoothEntry> = Arc::new(Object::builder().build());
|
||||||
let entry_imp = entry.imp();
|
let entry_imp = entry.imp();
|
||||||
let entry_ref = entry.clone();
|
let entry_ref = entry.clone();
|
||||||
|
let entry_ref_remove = entry.clone();
|
||||||
entry.set_title(&device.alias);
|
entry.set_title(&device.alias);
|
||||||
entry.set_subtitle(&device.address);
|
entry.set_subtitle(&device.address);
|
||||||
entry.set_activatable(true);
|
entry.set_activatable(true);
|
||||||
|
@ -37,53 +38,44 @@ impl BluetoothEntry {
|
||||||
.valign(Align::Center)
|
.valign(Align::Center)
|
||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
entry_imp.connecting_label.replace(
|
entry_imp
|
||||||
Label::builder()
|
.connecting_label
|
||||||
.label("")
|
.replace(Label::builder().label("").build());
|
||||||
.build(),
|
|
||||||
);
|
|
||||||
entry.add_suffix(entry_imp.remove_device_button.borrow().deref());
|
entry.add_suffix(entry_imp.remove_device_button.borrow().deref());
|
||||||
if device.icon.is_empty() {
|
if device.icon.is_empty() {
|
||||||
entry.add_prefix(&Image::from_icon_name("dialog-question-symbolic"));
|
entry.add_prefix(&Image::from_icon_name("dialog-question-symbolic"));
|
||||||
} else {
|
} else {
|
||||||
entry.add_prefix(&Image::from_icon_name(&device.icon));
|
entry.add_prefix(&Image::from_icon_name(&device.icon));
|
||||||
}
|
}
|
||||||
if device.connected || device.paired {
|
if device.connected || device.bonded {
|
||||||
entry_imp.remove_device_button.borrow().set_sensitive(true);
|
entry_imp.remove_device_button.borrow().set_sensitive(true);
|
||||||
} else {
|
} else {
|
||||||
entry_imp.remove_device_button.borrow().set_sensitive(false);
|
entry_imp.remove_device_button.borrow().set_sensitive(false);
|
||||||
}
|
}
|
||||||
let path = Arc::new(device.path.clone());
|
|
||||||
|
entry_imp.bluetooth_device.replace(device);
|
||||||
entry_imp
|
entry_imp
|
||||||
.remove_device_button
|
.remove_device_button
|
||||||
.borrow()
|
.borrow()
|
||||||
.connect_clicked(move |_| {
|
.connect_clicked(move |_| {
|
||||||
remove_device_pairing((*path).clone());
|
let imp = entry_ref_remove.imp();
|
||||||
|
remove_device_pairing(imp.bluetooth_device.borrow().path.clone());
|
||||||
});
|
});
|
||||||
let gesture = GestureClick::new();
|
let gesture = GestureClick::new();
|
||||||
let connected = device.connected;
|
|
||||||
// let paired = device.paired;
|
|
||||||
// paired is not what we think
|
// paired is not what we think
|
||||||
// TODO implement paired
|
// TODO implement paired
|
||||||
let path = device.path.clone();
|
|
||||||
gesture.connect_released(move |_, _, _, _| {
|
gesture.connect_released(move |_, _, _, _| {
|
||||||
if connected {
|
let imp = entry_ref.imp();
|
||||||
|
let borrow = imp.bluetooth_device.borrow();
|
||||||
|
if borrow.connected {
|
||||||
let imp = entry_ref.imp();
|
let imp = entry_ref.imp();
|
||||||
imp.remove_device_button.borrow().set_sensitive(false);
|
imp.remove_device_button.borrow().set_sensitive(false);
|
||||||
entry_ref
|
imp.connecting_label.borrow().set_text("Disconnecting...");
|
||||||
.imp()
|
disconnect_from_device(entry_ref.clone(), borrow.path.clone());
|
||||||
.connecting_label
|
|
||||||
.borrow()
|
|
||||||
.set_text("Disconnecting...");
|
|
||||||
disconnect_from_device(entry_ref.clone(), path.clone());
|
|
||||||
} else {
|
} else {
|
||||||
entry_ref.set_sensitive(false);
|
entry_ref.set_sensitive(false);
|
||||||
entry_ref
|
imp.connecting_label.borrow().set_text("Connecting...");
|
||||||
.imp()
|
connect_to_device(entry_ref.clone(), borrow.path.clone());
|
||||||
.connecting_label
|
|
||||||
.borrow()
|
|
||||||
.set_text("Connecting...");
|
|
||||||
connect_to_device(entry_ref.clone(), path.clone());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
entry.add_controller(gesture);
|
entry.add_controller(gesture);
|
||||||
|
|
|
@ -4,6 +4,7 @@ use adw::subclass::preferences_row::PreferencesRowImpl;
|
||||||
use adw::ActionRow;
|
use adw::ActionRow;
|
||||||
use gtk::subclass::prelude::*;
|
use gtk::subclass::prelude::*;
|
||||||
use gtk::{glib, Button, CompositeTemplate, Label};
|
use gtk::{glib, Button, CompositeTemplate, Label};
|
||||||
|
use re_set_lib::bluetooth::bluetooth_structures::BluetoothDevice;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
#[derive(Default, CompositeTemplate)]
|
#[derive(Default, CompositeTemplate)]
|
||||||
|
@ -12,6 +13,7 @@ pub struct BluetoothEntry {
|
||||||
pub remove_device_button: RefCell<Button>,
|
pub remove_device_button: RefCell<Button>,
|
||||||
pub connecting_label: RefCell<Label>,
|
pub connecting_label: RefCell<Label>,
|
||||||
pub device_name: RefCell<String>,
|
pub device_name: RefCell<String>,
|
||||||
|
pub bluetooth_device: RefCell<BluetoothDevice>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
|
|
|
@ -399,7 +399,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on source add");
|
println!("fail on source add event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on source remove");
|
println!("fail on source remove event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on source remove");
|
println!("fail on source change event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on stream add");
|
println!("fail on output stream add event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on stream change");
|
println!("fail on output stream change event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on stream remove");
|
println!("fail on output stream remove event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -405,7 +405,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on sink add");
|
println!("fail on sink add event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on sink remove");
|
println!("fail on sink remove event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,7 +498,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on sink change");
|
println!("fail on sink change event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on stream add");
|
println!("fail on input stream add event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,7 +575,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on stream change");
|
println!("fail on input stream change event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on stream remove");
|
println!("fail on input stream remove event");
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ fn setup_callbacks(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) -> Arc<Wif
|
||||||
imp.reset_saved_networks
|
imp.reset_saved_networks
|
||||||
.set_action_target_value(Some(&Variant::from("saved")));
|
.set_action_target_value(Some(&Variant::from("saved")));
|
||||||
|
|
||||||
println!("{wifi_status}");
|
|
||||||
imp.reset_wifi_switch.set_active(wifi_status);
|
imp.reset_wifi_switch.set_active(wifi_status);
|
||||||
imp.reset_wifi_switch.set_state(wifi_status);
|
imp.reset_wifi_switch.set_state(wifi_status);
|
||||||
|
|
||||||
|
@ -258,7 +257,6 @@ pub fn get_stored_connections() -> Vec<(Path<'static>, Vec<u8>)> {
|
||||||
);
|
);
|
||||||
let res: ResultMap = proxy.method_call("org.Xetibo.ReSetWireless", "ListStoredConnections", ());
|
let res: ResultMap = proxy.method_call("org.Xetibo.ReSetWireless", "ListStoredConnections", ());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("we got error...");
|
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
let (connections,) = res.unwrap();
|
let (connections,) = res.unwrap();
|
||||||
|
@ -311,7 +309,6 @@ pub fn start_event_listener(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) {
|
||||||
)
|
)
|
||||||
.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, _, _| {
|
||||||
println!("received added event");
|
|
||||||
let wifi_box = added_ref.clone();
|
let wifi_box = added_ref.clone();
|
||||||
glib::spawn_future(async move {
|
glib::spawn_future(async move {
|
||||||
glib::idle_add_once(move || {
|
glib::idle_add_once(move || {
|
||||||
|
@ -334,11 +331,10 @@ pub fn start_event_listener(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) {
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on add");
|
println!("fail on access point add event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let res = conn.add_match(access_point_removed, move |ir: AccessPointRemoved, _, _| {
|
let res = conn.add_match(access_point_removed, move |ir: AccessPointRemoved, _, _| {
|
||||||
println!("received removed event");
|
|
||||||
let wifi_box = removed_ref.clone();
|
let wifi_box = removed_ref.clone();
|
||||||
glib::spawn_future(async move {
|
glib::spawn_future(async move {
|
||||||
glib::idle_add_once(move || {
|
glib::idle_add_once(move || {
|
||||||
|
@ -358,12 +354,10 @@ pub fn start_event_listener(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) {
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on remove");
|
println!("fail on access point remove event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let res = conn.add_match(access_point_changed, move |ir: AccessPointChanged, _, _| {
|
let res = conn.add_match(access_point_changed, move |ir: AccessPointChanged, _, _| {
|
||||||
println!("received changed event");
|
|
||||||
dbg!(ir.access_point.clone());
|
|
||||||
let wifi_box = changed_ref.clone();
|
let wifi_box = changed_ref.clone();
|
||||||
glib::spawn_future(async move {
|
glib::spawn_future(async move {
|
||||||
glib::idle_add_local_once(move || {
|
glib::idle_add_local_once(move || {
|
||||||
|
@ -413,11 +407,10 @@ pub fn start_event_listener(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) {
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on change");
|
println!("fail on access point change event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let res = conn.add_match(device_changed, move |ir: WifiDeviceChanged, _, _| {
|
let res = conn.add_match(device_changed, move |ir: WifiDeviceChanged, _, _| {
|
||||||
println!("received wifidevice changed event");
|
|
||||||
let wifi_box = wifi_changed_ref.clone();
|
let wifi_box = wifi_changed_ref.clone();
|
||||||
glib::spawn_future(async move {
|
glib::spawn_future(async move {
|
||||||
glib::idle_add_once(move || {
|
glib::idle_add_once(move || {
|
||||||
|
@ -439,14 +432,13 @@ pub fn start_event_listener(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) {
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on add");
|
println!("fail on wifi device change event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
println!("starting thread listener");
|
|
||||||
loop {
|
loop {
|
||||||
let _ = conn.process(Duration::from_millis(1000));
|
let _ = conn.process(Duration::from_millis(1000));
|
||||||
if !listeners.wifi_listener.load(Ordering::SeqCst) {
|
if !listeners.wifi_listener.load(Ordering::SeqCst) {
|
||||||
println!("stopping thread listener");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,6 @@ impl WifiEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn click_disconnect(entry: Arc<WifiEntry>) {
|
pub fn click_disconnect(entry: Arc<WifiEntry>) {
|
||||||
println!("called disconnect");
|
|
||||||
let entry_ref = entry.clone();
|
let entry_ref = entry.clone();
|
||||||
entry.set_activatable(false);
|
entry.set_activatable(false);
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
|
@ -139,12 +138,10 @@ pub fn click_stored_network(entry: Arc<WifiEntry>) {
|
||||||
entry.set_activatable(true);
|
entry.set_activatable(true);
|
||||||
let imp = entry_ref.imp();
|
let imp = entry_ref.imp();
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("wtf?");
|
|
||||||
imp.connected.replace(false);
|
imp.connected.replace(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if res.unwrap() == (false,) {
|
if res.unwrap() == (false,) {
|
||||||
println!("false on connecting");
|
|
||||||
imp.connected.replace(false);
|
imp.connected.replace(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +196,6 @@ pub fn click_new_network(entry: Arc<WifiEntry>) {
|
||||||
imp.connected.replace(false);
|
imp.connected.replace(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
println!("worked?");
|
|
||||||
let imp = entry_ref.imp();
|
let imp = entry_ref.imp();
|
||||||
imp.reset_wifi_popup.popdown();
|
imp.reset_wifi_popup.popdown();
|
||||||
imp.reset_wifi_edit_button.set_sensitive(true);
|
imp.reset_wifi_edit_button.set_sensitive(true);
|
||||||
|
|
Loading…
Reference in a new issue