diff --git a/src/components/bluetooth/bluetoothBox.rs b/src/components/bluetooth/bluetoothBox.rs index 17a483e..c20bc0a 100644 --- a/src/components/bluetooth/bluetoothBox.rs +++ b/src/components/bluetooth/bluetoothBox.rs @@ -5,13 +5,15 @@ use std::time::{Duration, SystemTime}; use adw::glib; use adw::glib::Object; +use adw::prelude::ListModelExtManual; use adw::subclass::prelude::ObjectSubclassIsExt; use dbus::blocking::Connection; use dbus::message::SignalArgs; use dbus::{Error, Path}; -use gtk::gio; +use glib::Cast; +use gtk::{gio, Widget}; use gtk::glib::Variant; -use gtk::prelude::{ActionableExt, ListBoxRowExt, WidgetExt}; +use gtk::prelude::{ActionableExt, BoxExt, ListBoxRowExt, WidgetExt}; use ReSet_Lib::bluetooth::bluetooth::BluetoothDevice; use ReSet_Lib::signals::{BluetoothDeviceAdded, BluetoothDeviceChanged, BluetoothDeviceRemoved}; @@ -216,7 +218,13 @@ pub fn start_bluetooth_listener(listeners: Arc, bluetooth_box: Arc() { + if let Ok(entry) = x { // todo test this + if let Some(item) = entry.downcast_ref::() { + imp.resetBluetoothAvailableDevices.remove(item); + } + } + }; }); }); println!("stopping bluetooth listener"); diff --git a/src/components/bluetooth/bluetoothBoxImpl.rs b/src/components/bluetooth/bluetoothBoxImpl.rs index 287cad1..721b227 100644 --- a/src/components/bluetooth/bluetoothBoxImpl.rs +++ b/src/components/bluetooth/bluetoothBoxImpl.rs @@ -2,7 +2,7 @@ use adw::ActionRow; use dbus::Path; use gtk::prelude::*; use gtk::subclass::prelude::*; -use gtk::{glib, CompositeTemplate, ListBox, Switch}; +use gtk::{glib, CompositeTemplate, ListBox, Switch, Button}; use std::cell::RefCell; use std::collections::HashMap; use std::sync::Arc; @@ -22,9 +22,11 @@ pub struct BluetoothBox { #[template_child] pub resetBluetoothSwitch: TemplateChild, #[template_child] - pub resetBluetoothAvailableDevices: TemplateChild, + pub resetBluetoothAvailableDevices: TemplateChild, #[template_child] - pub resetBluetoothConnectedDevices: TemplateChild, + pub resetBluetoothRefreshButton: TemplateChild