update iced

This commit is contained in:
Ashley Wulber 2024-10-30 22:51:08 -04:00 committed by Ashley Wulber
parent 11faa567f3
commit 5b5cd77e7c
45 changed files with 2360 additions and 1537 deletions

View file

@ -1,5 +1,8 @@
use super::{NetworkManagerEvent, NetworkManagerState};
use cosmic::iced::{self, subscription};
use cosmic::{
iced::{self, Subscription},
iced_futures::stream,
};
use cosmic_dbus_networkmanager::nm::NetworkManager;
use futures::{SinkExt, StreamExt};
use std::{fmt::Debug, hash::Hash};
@ -10,15 +13,18 @@ pub fn active_conns_subscription<I: 'static + Hash + Copy + Send + Sync + Debug>
conn: Connection,
) -> iced::Subscription<NetworkManagerEvent> {
let initial = State::Continue(conn);
subscription::channel(id, 50, move |mut output| {
let mut state = initial;
Subscription::run_with_id(
id,
stream::channel(50, move |mut output| {
let mut state = initial;
async move {
loop {
state = start_listening(state, &mut output).await;
async move {
loop {
state = start_listening(state, &mut output).await;
}
}
}
})
}),
)
}
#[derive(Debug, Clone)]

View file

@ -1,5 +1,5 @@
use super::{NetworkManagerEvent, NetworkManagerState};
use cosmic::iced::{self, subscription};
use cosmic::iced::{self, stream, Subscription};
use cosmic_dbus_networkmanager::nm::NetworkManager;
use futures::{SinkExt, StreamExt};
use std::{fmt::Debug, hash::Hash};
@ -11,15 +11,18 @@ pub fn devices_subscription<I: 'static + Hash + Copy + Send + Sync + Debug>(
conn: Connection,
) -> iced::Subscription<NetworkManagerEvent> {
let initial = State::Continue(conn);
subscription::channel((id, has_popup), 50, move |mut output| {
let mut state = initial.clone();
Subscription::run_with_id(
(id, has_popup),
stream::channel(50, move |mut output| {
let mut state = initial.clone();
async move {
loop {
state = start_listening(state, has_popup, &mut output).await;
async move {
loop {
state = start_listening(state, has_popup, &mut output).await;
}
}
}
})
}),
)
}
#[derive(Debug, Clone)]

View file

@ -6,7 +6,10 @@ pub mod wireless_enabled;
use std::{collections::HashMap, fmt::Debug, time::Duration};
use cosmic::iced::{self, subscription};
use cosmic::{
iced::{self, Subscription},
iced_futures::stream,
};
use cosmic_dbus_networkmanager::{
active_connection::ActiveConnection,
device::SpecificDevice,
@ -42,13 +45,16 @@ pub enum State {
pub fn network_manager_subscription<I: Copy + Debug + std::hash::Hash + 'static>(
id: I,
) -> iced::Subscription<NetworkManagerEvent> {
subscription::channel(id, 50, |mut output| async move {
let mut state = State::Ready;
Subscription::run_with_id(
id,
stream::channel(50, |mut output| async move {
let mut state = State::Ready;
loop {
state = start_listening(state, &mut output).await;
}
})
loop {
state = start_listening(state, &mut output).await;
}
}),
)
}
async fn start_listening(

View file

@ -1,5 +1,8 @@
use super::{NetworkManagerEvent, NetworkManagerState};
use cosmic::iced::{self, subscription};
use cosmic::{
iced::{self, Subscription},
iced_futures::stream,
};
use cosmic_dbus_networkmanager::nm::NetworkManager;
use futures::{SinkExt, StreamExt};
use std::{fmt::Debug, hash::Hash};
@ -10,15 +13,18 @@ pub fn wireless_enabled_subscription<I: 'static + Hash + Copy + Send + Sync + De
conn: Connection,
) -> iced::Subscription<NetworkManagerEvent> {
let initial = State::Continue(conn);
subscription::channel(id, 50, move |mut output| {
let mut state = initial;
Subscription::run_with_id(
id,
stream::channel(50, move |mut output| {
let mut state = initial;
async move {
loop {
state = start_listening(state, &mut output).await;
async move {
loop {
state = start_listening(state, &mut output).await;
}
}
}
})
}),
)
}
#[derive(Debug, Clone)]