chore: updates after iced-rebase
This commit is contained in:
parent
bd0d180482
commit
71d9d6d5bb
41 changed files with 1786 additions and 2396 deletions
|
|
@ -3,12 +3,15 @@
|
|||
|
||||
use cosmic::{
|
||||
Element, Task, app,
|
||||
applet::cosmic_panel_config::PanelAnchor,
|
||||
applet::token::subscription::{TokenRequest, TokenUpdate, activation_token_subscription},
|
||||
applet::{
|
||||
cosmic_panel_config::PanelAnchor,
|
||||
token::subscription::{TokenRequest, TokenUpdate, activation_token_subscription},
|
||||
},
|
||||
cctk::sctk::reexports::calloop,
|
||||
iced::{
|
||||
self, Length, Subscription,
|
||||
platform_specific::shell::commands::popup::{destroy_popup, get_popup},
|
||||
theme::Style,
|
||||
window,
|
||||
},
|
||||
surface,
|
||||
|
|
@ -146,7 +149,7 @@ impl cosmic::Application for App {
|
|||
&mut self.core
|
||||
}
|
||||
|
||||
fn style(&self) -> Option<cosmic::iced_runtime::Appearance> {
|
||||
fn style(&self) -> Option<iced::theme::Style> {
|
||||
Some(cosmic::applet::style())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ fn layout_view(layout: &Layout, expanded: Option<i32>) -> cosmic::Element<'_, Ms
|
|||
if !i.visible() {
|
||||
None
|
||||
} else if i.type_() == Some("separator") {
|
||||
Some(iced::widget::horizontal_rule(2).into())
|
||||
Some(iced::widget::rule::horizontal(2).into())
|
||||
} else if let Some(label) = i.label() {
|
||||
// Strip _ when not doubled
|
||||
// TODO: interpret as "access key"? And label with underline.
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
// Copyright 2023 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use std::hash::Hash;
|
||||
|
||||
use cosmic::iced::{self, Subscription};
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::path::PathBuf;
|
||||
use zbus::zvariant::{self, OwnedValue};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -76,22 +77,40 @@ impl StatusNotifierItem {
|
|||
let Some(menu_proxy) = self.menu_proxy.clone() else {
|
||||
return Subscription::none();
|
||||
};
|
||||
Subscription::run_with_id(
|
||||
format!("status-notifier-item-layout-{}", &self.name),
|
||||
async move {
|
||||
let initial = futures::stream::once(get_layout(menu_proxy.clone()));
|
||||
|
||||
let layout_updated = menu_proxy.receive_layout_updated().await.unwrap();
|
||||
let props_updated = menu_proxy.receive_items_properties_updated().await.unwrap();
|
||||
|
||||
// Merge both streams - any update triggers a layout refetch
|
||||
let updates =
|
||||
futures::stream_select!(layout_updated.map(|_| ()), props_updated.map(|_| ()))
|
||||
.then(move |()| get_layout(menu_proxy.clone()));
|
||||
|
||||
initial.chain(updates)
|
||||
struct Wrapper {
|
||||
menu_proxy: DBusMenuProxy<'static>,
|
||||
name: String,
|
||||
}
|
||||
impl Hash for Wrapper {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.name.hash(state);
|
||||
}
|
||||
.flatten_stream(),
|
||||
}
|
||||
Subscription::run_with(
|
||||
Wrapper {
|
||||
menu_proxy,
|
||||
name: format!("status-notifier-item-layout-{}", &self.name),
|
||||
},
|
||||
|Wrapper { menu_proxy, .. }| {
|
||||
let menu_proxy = menu_proxy.clone();
|
||||
async move {
|
||||
let initial = futures::stream::once(get_layout(menu_proxy.clone()));
|
||||
|
||||
let layout_updated = menu_proxy.receive_layout_updated().await.unwrap();
|
||||
let props_updated =
|
||||
menu_proxy.receive_items_properties_updated().await.unwrap();
|
||||
|
||||
// Merge both streams - any update triggers a layout refetch
|
||||
let updates = futures::stream_select!(
|
||||
layout_updated.map(|_| ()),
|
||||
props_updated.map(|_| ())
|
||||
)
|
||||
.then(move |()| get_layout(menu_proxy.clone()));
|
||||
|
||||
initial.chain(updates)
|
||||
}
|
||||
.flatten_stream()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -108,15 +127,30 @@ impl StatusNotifierItem {
|
|||
}
|
||||
|
||||
let item_proxy = self.item_proxy.clone();
|
||||
Subscription::run_with_id(
|
||||
format!("status-notifier-item-icon-{}", &self.name),
|
||||
async move {
|
||||
let new_icon_stream = item_proxy.receive_new_icon().await.unwrap();
|
||||
futures::stream::once(async {})
|
||||
.chain(new_icon_stream.map(|_| ()))
|
||||
.then(move |()| icon_events(item_proxy.clone()))
|
||||
struct Wrapper {
|
||||
item_proxy: StatusNotifierItemProxy<'static>,
|
||||
name: String,
|
||||
}
|
||||
impl Hash for Wrapper {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.name.hash(state);
|
||||
}
|
||||
.flatten_stream(),
|
||||
}
|
||||
Subscription::run_with(
|
||||
Wrapper {
|
||||
item_proxy,
|
||||
name: format!("status-notifier-item-icon-{}", &self.name),
|
||||
},
|
||||
|Wrapper { item_proxy, .. }| {
|
||||
let item_proxy = item_proxy.clone();
|
||||
async move {
|
||||
let new_icon_stream = item_proxy.receive_new_icon().await.unwrap();
|
||||
futures::stream::once(async {})
|
||||
.chain(new_icon_stream.map(|_| ()))
|
||||
.then(move |()| icon_events(item_proxy.clone()))
|
||||
}
|
||||
.flatten_stream()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
// TODO: Both this and server proxy could emit same events, have way to generate stream from either?
|
||||
|
||||
use std::any::TypeId;
|
||||
|
||||
use cosmic::iced::{self, Subscription};
|
||||
use futures::{StreamExt, stream};
|
||||
|
||||
|
|
@ -26,8 +28,8 @@ enum State {
|
|||
}
|
||||
|
||||
pub fn subscription() -> iced::Subscription<Event> {
|
||||
Subscription::run_with_id(
|
||||
"status-notifier-watcher",
|
||||
pub struct MyID;
|
||||
Subscription::run_with(TypeId::of::<MyID>(), |_| {
|
||||
stream::unfold(State::NotConnected, |state| async move {
|
||||
match state {
|
||||
State::NotConnected => match connect().await {
|
||||
|
|
@ -42,8 +44,8 @@ pub fn subscription() -> iced::Subscription<Event> {
|
|||
.map(|event| (event, State::Connected(stream))),
|
||||
State::Failed => None,
|
||||
}
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async fn connect() -> zbus::Result<(zbus::Connection, client::EventStream)> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue