mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-17 10:18:32 +02:00
feat: Initial work on bluetooth on and off
This commit is contained in:
parent
4a34144ebc
commit
b2b4ae0661
|
@ -30,30 +30,38 @@ unsafe impl Send for BluetoothBox {}
|
||||||
unsafe impl Sync for BluetoothBox {}
|
unsafe impl Sync for BluetoothBox {}
|
||||||
|
|
||||||
impl BluetoothBox {
|
impl BluetoothBox {
|
||||||
pub fn new() -> Self {
|
pub fn new(listeners: Arc<Listeners>) -> Arc<Self> {
|
||||||
Object::builder().build()
|
let obj: Arc<Self> = Arc::new(Object::builder().build());
|
||||||
|
setupCallbacks(listeners, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setupCallbacks(&self) {
|
pub fn setupCallbacks(&self) {}
|
||||||
let selfImp = self.imp();
|
|
||||||
selfImp.resetVisibility.set_activatable(true);
|
|
||||||
selfImp
|
|
||||||
.resetVisibility
|
|
||||||
.set_action_name(Some("navigation.push"));
|
|
||||||
selfImp
|
|
||||||
.resetVisibility
|
|
||||||
.set_action_target_value(Some(&Variant::from("visibility")));
|
|
||||||
|
|
||||||
selfImp
|
|
||||||
.resetBluetoothMainTab
|
|
||||||
.set_action_name(Some("navigation.pop"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for BluetoothBox {
|
fn setupCallbacks(
|
||||||
fn default() -> Self {
|
listeners: Arc<Listeners>,
|
||||||
Self::new()
|
bluetooth_box: Arc<BluetoothBox>,
|
||||||
}
|
) -> Arc<BluetoothBox> {
|
||||||
|
let imp = bluetooth_box.imp();
|
||||||
|
// let bluetooth_box_ref = bluetooth_box.clone();
|
||||||
|
imp.resetVisibility.set_activatable(true);
|
||||||
|
imp.resetVisibility.set_action_name(Some("navigation.push"));
|
||||||
|
imp.resetVisibility
|
||||||
|
.set_action_target_value(Some(&Variant::from("visibility")));
|
||||||
|
|
||||||
|
imp.resetBluetoothMainTab
|
||||||
|
.set_action_name(Some("navigation.pop"));
|
||||||
|
// TODO add a manual search button here
|
||||||
|
imp.resetBluetoothSwitch.connect_state_set(move |_, state| {
|
||||||
|
// TODO restart bluetooth search here.
|
||||||
|
if !state {
|
||||||
|
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
|
||||||
|
} else {
|
||||||
|
listeners.bluetooth_listener.store(true, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
glib::Propagation::Proceed
|
||||||
|
});
|
||||||
|
bluetooth_box
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn populate_conntected_bluetooth_devices(bluetooth_box: Arc<BluetoothBox>) {
|
pub fn populate_conntected_bluetooth_devices(bluetooth_box: Arc<BluetoothBox>) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub const HANDLE_CONNECTIVITY_CLICK: fn(Arc<Listeners>, FlowBox) =
|
||||||
show_stored_connections(wifiBox.clone());
|
show_stored_connections(wifiBox.clone());
|
||||||
scanForWifi(wifiBox.clone());
|
scanForWifi(wifiBox.clone());
|
||||||
let wifiFrame = wrapInFrame(SettingBox::new(&*wifiBox));
|
let wifiFrame = wrapInFrame(SettingBox::new(&*wifiBox));
|
||||||
let bluetooth_box = Arc::new(BluetoothBox::new());
|
let bluetooth_box = BluetoothBox::new(listeners.clone());
|
||||||
populate_conntected_bluetooth_devices(bluetooth_box.clone());
|
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));
|
||||||
|
@ -51,7 +51,7 @@ pub const HANDLE_BLUETOOTH_CLICK: fn(Arc<Listeners>, FlowBox) =
|
||||||
|listeners: Arc<Listeners>, resetMain: FlowBox| {
|
|listeners: Arc<Listeners>, resetMain: FlowBox| {
|
||||||
listeners.stop_network_listener();
|
listeners.stop_network_listener();
|
||||||
listeners.stop_audio_listener();
|
listeners.stop_audio_listener();
|
||||||
let bluetooth_box = Arc::new(BluetoothBox::new());
|
let bluetooth_box = BluetoothBox::new(listeners.clone());
|
||||||
start_bluetooth_listener(listeners.clone(), bluetooth_box.clone());
|
start_bluetooth_listener(listeners.clone(), bluetooth_box.clone());
|
||||||
populate_conntected_bluetooth_devices(bluetooth_box.clone());
|
populate_conntected_bluetooth_devices(bluetooth_box.clone());
|
||||||
let bluetoothFrame = wrapInFrame(SettingBox::new(&*bluetooth_box));
|
let bluetoothFrame = wrapInFrame(SettingBox::new(&*bluetooth_box));
|
||||||
|
|
Loading…
Reference in a new issue