wip: update libcosmic (#93)

* wip: update libcosmic

* fix: damge issue resolved by updating iced

* fix: high cpu usage by time applet and app-list

* refactor subscriptions to produce fewer events

* refactor network applet to use less cpu

* fix: text size

* refactor: i18n for audio applet

* refactor: power applet i18n setup

* fix (battery): always send profile update

* fix (battery): set toggler width to layout correctly

* fix (app-list): backoff for restarts of toplevel subscription

* fix (network): alignment

* feat: ask for comfirmation before applying power applet actions

* wip: integrate cosmic-config

* update zbus

* feat: update to use latest libcosmic

* update iced

* udpate deps

* update deps

* refactor: move applet helpers to this repo, outside of libcosmic.

this should help alleviate some dependency hell

* chore update deps

* update deps

* cleanup
This commit is contained in:
Ashley Wulber 2023-06-01 12:23:12 -04:00 committed by GitHub
parent 8b46cc209f
commit 9ebd9b511a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 2841 additions and 1681 deletions

View file

@ -19,7 +19,7 @@
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
use cosmic::iced;
use cosmic::iced_native::subscription;
use cosmic::iced::subscription;
use std::fmt::Debug;
use std::hash::Hash;
use tokio::sync::mpsc::UnboundedReceiver;
@ -114,7 +114,9 @@ pub async fn set_power_profile(daemon: PowerDaemonProxy<'_>, power: Power) -> Re
pub fn power_profile_subscription<I: 'static + Hash + Copy + Send + Sync + Debug>(
id: I,
) -> iced::Subscription<(I, PowerProfileUpdate)> {
subscription::unfold(id, State::Ready, move |state| start_listening(id, state))
subscription::unfold(id, State::Ready, move |state| {
start_listening_loop(id, state)
})
}
#[derive(Debug)]
@ -124,6 +126,19 @@ pub enum State {
Finished,
}
async fn start_listening_loop<I: Copy + Debug>(
id: I,
mut state: State,
) -> ((I, PowerProfileUpdate), State) {
loop {
let (update, new_state) = start_listening(id, state).await;
state = new_state;
if let Some(update) = update {
return (update, state);
}
}
}
async fn start_listening<I: Copy>(id: I, state: State) -> (Option<(I, PowerProfileUpdate)>, State) {
match state {
State::Ready => {
@ -189,14 +204,11 @@ async fn start_listening<I: Copy>(id: I, state: State) -> (Option<(I, PowerProfi
}
}
Some(PowerProfileRequest::Set(profile)) => {
if set_power_profile(power_proxy, profile).await.is_ok() {
(
Some((id, PowerProfileUpdate::Update { profile })),
State::Waiting(conn, rx),
)
} else {
(None, State::Waiting(conn, rx))
}
let _ = set_power_profile(power_proxy, profile).await;
(
Some((id, PowerProfileUpdate::Update { profile })),
State::Waiting(conn, rx),
)
}
None => (None, State::Finished),
}