some things

This commit is contained in:
takotori 2023-12-03 14:11:59 +01:00
parent 593c6b7627
commit a3866294af
9 changed files with 105 additions and 146 deletions

View file

@ -12,7 +12,7 @@ use dbus::message::SignalArgs;
use dbus::{Error, Path};
use glib::{clone, Cast};
use gtk::glib::Variant;
use gtk::prelude::{ActionableExt, ListBoxRowExt, WidgetExt};
use gtk::prelude::{ActionableExt, BoxExt, ListBoxRowExt, WidgetExt};
use gtk::{gio, StringObject};
use ReSet_Lib::bluetooth::bluetooth::{BluetoothAdapter, BluetoothDevice};
use ReSet_Lib::signals::{BluetoothDeviceAdded, BluetoothDeviceChanged, BluetoothDeviceRemoved};
@ -217,7 +217,6 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
let imp = bluetooth_box.imp();
let map = imp.availableDevices.borrow_mut();
if let Some(list_entry) = map.get(&ir.bluetooth_device) {
imp.resetBluetoothAvailableDevices.remove(&*list_entry.1);
imp.resetBluetoothConnectedDevices.remove(&*list_entry.1);
}
});
@ -274,7 +273,13 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
glib::spawn_future(async move {
glib::idle_add_once(move || {
let imp = loop_box.imp();
imp.resetBluetoothAvailableDevices.remove_all();
for x in imp.resetBluetoothAvailableDevices.observe_children().iter::<Object>() {
if let Ok(entry) = x { // todo test this
if let Some(item) = entry.downcast_ref::<Widget>() {
imp.resetBluetoothAvailableDevices.remove(item);
}
}
};
});
});
println!("stopping bluetooth listener");

View file

@ -1,7 +1,7 @@
use adw::{ActionRow, ComboRow};
use dbus::Path;
use gtk::subclass::prelude::*;
use gtk::{glib, CompositeTemplate, ListBox, Switch};
use gtk::{glib, CompositeTemplate, ListBox, Switch, Button};
use gtk::{prelude::*, StringList};
use std::cell::RefCell;
use std::collections::HashMap;
@ -22,11 +22,13 @@ pub struct BluetoothBox {
#[template_child]
pub resetBluetoothSwitch: TemplateChild<Switch>,
#[template_child]
pub resetBluetoothAvailableDevices: TemplateChild<ListBox>,
pub resetBluetoothAvailableDevices: TemplateChild<gtk::Box>,
#[template_child]
pub resetBluetoothRefreshButton: TemplateChild<Button>,
#[template_child]
pub resetBluetoothAdapter: TemplateChild<ComboRow>,
#[template_child]
pub resetBluetoothConnectedDevices: TemplateChild<ListBox>,
pub resetBluetoothConnectedDevices: TemplateChild<gtk::Box>,
#[template_child]
pub resetVisibility: TemplateChild<ActionRow>,
#[template_child]

View file

@ -16,7 +16,7 @@ use dbus::Error;
use dbus::Path;
use glib::{clone, Cast, PropertySet};
use gtk::glib::Variant;
use gtk::prelude::{ActionableExt, WidgetExt};
use gtk::prelude::{ActionableExt, WidgetExt, BoxExt};
use gtk::{gio, StringObject};
use ReSet_Lib::network::network::{AccessPoint, WifiDevice, WifiStrength};
use ReSet_Lib::signals::{AccessPointAdded, WifiDeviceChanged};
@ -373,12 +373,9 @@ pub fn start_event_listener(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) {
if ir.access_point.dbus_path
== imp.resetCurrentWifiDevice.borrow().active_access_point
{
entryImp
.resetWifiConnected
.get()
.set_from_icon_name(Some("network-wireless-connected-symbolic"));
entryImp.resetWifiConnected.set_text("Connected");
} else {
entryImp.resetWifiConnected.get().set_from_icon_name(None);
entryImp.resetWifiConnected.set_text("");
}
{
let mut wifiName = entryImp.wifiName.borrow_mut();

View file

@ -55,9 +55,7 @@ impl WifiEntry {
}
if connected {
entryImp
.resetWifiConnected
.get()
.set_from_icon_name(Some("network-wireless-connected-symbolic"));
.resetWifiConnected.set_text("Connected");
}
{
let mut wifiName = entryImp.wifiName.borrow_mut();
@ -110,7 +108,7 @@ pub fn click_disconnect(entry: Arc<WifiEntry>) {
imp.connected.replace(false);
return;
}
imp.resetWifiConnected.get().set_from_icon_name(None);
imp.resetWifiConnected.set_text("");
imp.connected.replace(false);
glib::spawn_future(async move {
glib::idle_add_once(move || {
@ -152,9 +150,7 @@ pub fn click_stored_network(entry: Arc<WifiEntry>) {
return;
}
let imp = entry_ref.imp();
imp.resetWifiConnected
.get()
.set_from_icon_name(Some("network-wireless-connected-symbolic"));
imp.resetWifiConnected.set_text("Connected");
imp.connected.replace(true);
});
});

View file

@ -21,7 +21,7 @@ pub struct WifiEntry {
#[template_child]
pub resetWifiEditButton: TemplateChild<Button>,
#[template_child]
pub resetWifiConnected: TemplateChild<Image>,
pub resetWifiConnected: TemplateChild<Label>,
#[template_child]
pub resetWifiPopup: TemplateChild<Popup>,
pub wifiName: RefCell<String>,