Work on current networks stuff

This commit is contained in:
Lucy 2022-02-07 11:13:34 -05:00
parent 15b31c8b7f
commit 13c7f2fe4d
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1
2 changed files with 9 additions and 5 deletions

View file

@ -25,7 +25,7 @@ pub fn add_available_wifi(target: &gtk4::Box, separator: Separator) {
rx.attach(
None,
clone!(@strong ap_entries, @weak target, @weak separator, => @default-return Continue(true), move |aps| {
build_aps_list(ap_entries.clone(), target, dbg!(aps));
build_aps_list(ap_entries.clone(), target, aps);
separator.set_visible(!ap_entries.borrow().is_empty());
Continue(true)
}),
@ -44,13 +44,13 @@ fn build_aps_list(
for ap in aps {
view! {
ap_entry = SettingsEntry {
align_child: Align::Start,
set_title: &ap.ssid,
set_child: ap_icon = &Image {
set_icon_name: Some("network-wireless-symbolic"),
}
}
}
ap_entry.align_child(Align::Start); // view! seems to reorder everything in alphabetical order, but align_child must always come after set_child
target.append(&ap_entry);
ap_entries.push(ap_entry);
}

View file

@ -6,7 +6,9 @@ use cosmic_dbus_networkmanager::{
use gtk4::glib::{self, clone, source::PRIORITY_DEFAULT, MainContext, Sender};
use zbus::Connection;
pub fn add_current_networks(target: &gtk4::Box) {}
pub fn add_current_networks(target: &gtk4::Box) {
crate::task::spawn(handle_devices());
}
fn add_vpn(target: &gtk4::Box) {}
@ -18,8 +20,10 @@ async fn handle_devices() -> zbus::Result<()> {
let conn = Connection::system().await?;
let network_manager = NetworkManager::new(&conn).await?;
loop {
// TODO: NetworkManager::active_connections
let active_connections = network_manager.active_connections().await?;
for connection in active_connections {
eprintln!("{}", connection.type_().await?);
}
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
}
Ok(())
}