From 71395b0c75bbffe1853e8f4e0189acec4c0787b1 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 25 May 2023 18:47:14 -0400 Subject: [PATCH] feat: update iced with fix and refactor applet env vars --- Cargo.toml | 6 ++++-- iced | 2 +- src/applet/mod.rs | 15 +++++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index eb3579ce..a8cb3b4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ wayland = ["iced/wayland", "iced_sctk", "sctk",] wgpu = ["iced/wgpu", "iced_wgpu"] tokio = ["dep:tokio", "iced/tokio"] winit = ["iced/winit", "iced_winit"] -applet = ["cosmic-panel-config", "wayland"] +applet = ["cosmic-panel-config", "wayland", "ron", "serde"] winit_tiny_skia = ["winit", "tiny_skia"] winit_wgpu = ["winit", "wgpu"] @@ -25,11 +25,13 @@ derive_setters = "0.1.5" lazy_static = "1.4.0" palette = "0.6.1" tokio = { version = "1.24.2", optional = true } -cosmic-panel-config = {git = "https://github.com/pop-os/cosmic-panel", optional = true } +cosmic-panel-config = {git = "https://github.com/pop-os/cosmic-panel", branch = "bg_jammy", optional = true } sctk = { package = "smithay-client-toolkit", git = "https://github.com/pop-os/client-toolkit", optional = true, tag = "themed-pointer"} slotmap = "1.0.6" fraction = "0.13.0" cosmic-config = { path = "cosmic-config" } +ron = { version = "0.8", optional = true } +serde = { version = "1.0", optional = true } [target.'cfg(unix)'.dependencies] freedesktop-icons = "0.2.2" diff --git a/iced b/iced index 2aee3738..d29dd8d7 160000 --- a/iced +++ b/iced @@ -1 +1 @@ -Subproject commit 2aee37387f6ada651f6517c79f6cb3f408d5fabc +Subproject commit d29dd8d7855c568a528e67ee43dad29654053cac diff --git a/src/applet/mod.rs b/src/applet/mod.rs index cb35bb02..585695d4 100644 --- a/src/applet/mod.rs +++ b/src/applet/mod.rs @@ -1,4 +1,4 @@ -use cosmic_panel_config::{PanelAnchor, PanelSize}; +use cosmic_panel_config::{CosmicPanelBackground, PanelAnchor, PanelSize}; use iced::{ alignment::{Horizontal, Vertical}, wayland::InitialSurface, @@ -37,6 +37,8 @@ pub fn applet_button_theme() -> Button { pub struct CosmicAppletHelper { pub size: Size, pub anchor: PanelAnchor, + pub background: CosmicPanelBackground, + pub output_name: String, } #[derive(Clone, Debug)] @@ -52,13 +54,18 @@ impl Default for CosmicAppletHelper { size: Size::PanelSize( std::env::var("COSMIC_PANEL_SIZE") .ok() - .and_then(|size| size.parse::().ok()) + .and_then(|size| ron::from_str(size.as_str()).ok()) .unwrap_or(PanelSize::S), ), anchor: std::env::var("COSMIC_PANEL_ANCHOR") .ok() - .and_then(|size| size.parse::().ok()) + .and_then(|size| ron::from_str(size.as_str()).ok()) .unwrap_or(PanelAnchor::Top), + background: std::env::var("COSMIC_PANEL_BACKGROUND") + .ok() + .and_then(|size| ron::from_str(size.as_str()).ok()) + .unwrap_or(CosmicPanelBackground::ThemeDefault), + output_name: std::env::var("COSMIC_PANEL_OUTPUT").unwrap_or_default(), } } } @@ -102,7 +109,7 @@ impl CosmicAppletHelper { .max_height(height as f32 + APPLET_PADDING as f32 * 2.0) .min_width(width as f32 + APPLET_PADDING as f32 * 2.0) .max_width(width as f32 + APPLET_PADDING as f32 * 2.0), - + resizable: None, ..Default::default() }), ..crate::settings_with_flags(flags)