diff --git a/Cargo.lock b/Cargo.lock index b985347..e466a42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -766,7 +766,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "atomicwrites", "cosmic-config-derive 0.1.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", @@ -789,7 +789,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "quote", "syn 1.0.109", @@ -896,7 +896,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "anyhow", "cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", @@ -1024,6 +1024,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" +[[package]] +name = "cursor-icon" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740bb192a8e2d1350119916954f4409ee7f62f149b536911eeb78ba5a20526bf" + [[package]] name = "d3d12" version = "0.6.0" @@ -2094,8 +2100,9 @@ dependencies = [ [[package]] name = "iced" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ + "iced_accessibility", "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", "iced_futures 0.6.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", "iced_renderer", @@ -2109,7 +2116,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "accesskit", "accesskit_unix", @@ -2130,7 +2137,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "bitflags 1.3.2", "iced_accessibility", @@ -2157,7 +2164,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.6.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "futures", "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", @@ -2170,7 +2177,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.8.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2187,7 +2194,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2199,7 +2206,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "iced_accessibility", "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", @@ -2211,7 +2218,7 @@ dependencies = [ [[package]] name = "iced_sctk" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "enum-repr", "float-cmp", @@ -2232,7 +2239,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.8.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", "once_cell", @@ -2242,7 +2249,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "bytemuck", "cosmic-text", @@ -2260,7 +2267,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2282,13 +2289,14 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "iced_renderer", "iced_runtime", "iced_style", "num-traits", "ouroboros 0.13.0", + "smithay-client-toolkit 0.17.0", "thiserror", "unicode-segmentation", ] @@ -2296,7 +2304,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.9.1" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "iced_graphics", "iced_runtime", @@ -2476,9 +2484,9 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi 0.3.1", "libc", @@ -2600,7 +2608,7 @@ checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd" +source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#a0c72491dce1388a515acfa9b388ccf41ef0d574" dependencies = [ "apply", "cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", @@ -2611,12 +2619,13 @@ dependencies = [ "iced", "iced_core 0.9.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)", "iced_runtime", + "iced_sctk", "iced_style", "iced_widget", - "iced_winit", "lazy_static", "palette", "slotmap", + "smithay-client-toolkit 0.17.0", "tokio", ] @@ -4106,10 +4115,11 @@ dependencies = [ [[package]] name = "smithay-client-toolkit" version = "0.17.0" -source = "git+https://github.com/Smithay/client-toolkit?rev=389a4f2#389a4f21872a99a3ba346cc3dabd55c4079ec191" +source = "git+https://github.com/pop-os/client-toolkit?tag=themed-pointer#fd15dd954bc5f0c78d079aeda7b11194a682bbff" dependencies = [ "bitflags 1.3.2", "calloop", + "cursor-icon", "dlib", "lazy_static", "log", @@ -4682,9 +4692,9 @@ checksum = "2281c8c1d221438e373249e065ca4989c4c36952c211ff21a0ee91c44a3869e7" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unicode-linebreak" diff --git a/Cargo.toml b/Cargo.toml index 6f7b635..adf9032 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,4 @@ git = "https://github.com/pop-os/libcosmic" # rev = "b85c504d72ee1c0d360c56042996474932df97cb" branch = "cosmic-advanced-text" default-features = false -features = ["debug", "winit", "tokio"] +features = ["debug", "wayland", "tokio"] diff --git a/app/src/app.rs b/app/src/app.rs index 410a144..8cf95a6 100644 --- a/app/src/app.rs +++ b/app/src/app.rs @@ -6,11 +6,20 @@ use apply::Apply; use cosmic_settings_page::{self as page, section}; use cosmic::{ - iced::widget::{self, column, container, horizontal_space, row}, - iced::{self, subscription, window, Application, Command, Length, Subscription}, - iced_runtime::window::{close, drag, minimize, toggle_maximize}, + iced::{ + self, + event::wayland::{self, WindowEvent, WindowState}, + event::PlatformSpecific, + subscription, window, Application, Color, Command, Length, Subscription, + }, + iced::{ + widget::{self, column, container, horizontal_space, row}, + window::Mode, + }, + iced_sctk::commands::window::{set_mode_window, start_drag_window}, + iced_style::application, keyboard_nav, - theme::Theme, + theme::{self, Theme}, widget::{ header_bar, nav_bar, nav_bar_toggle, scrollable, search, segmented_button, settings, IconSource, @@ -27,6 +36,8 @@ use crate::{ widget::{page_title, parent_page_button, search_header, sub_page_button}, }; +use std::process; + #[allow(clippy::struct_excessive_bools)] #[allow(clippy::module_name_repetitions)] pub struct SettingsApp { @@ -43,6 +54,7 @@ pub struct SettingsApp { pub search: search::Model, pub search_selections: Vec<(page::Entity, section::Entity)>, pub show_maximize: bool, + pub sharp_corners: bool, pub show_minimize: bool, pub theme: Theme, pub title: String, @@ -65,6 +77,7 @@ pub enum Message { ToggleNavBar, ToggleNavBarCondensed, WindowResize(u32, u32), + WindowState(WindowState), } impl Application for SettingsApp { @@ -77,6 +90,7 @@ impl Application for SettingsApp { let mut config_path = config::PathManager::new(); let mut app = SettingsApp { + sharp_corners: false, active_page: page::Entity::default(), config: config_path.config("main", Config::deserialize), config_path, @@ -142,6 +156,22 @@ impl Application for SettingsApp { iced::Event::Window(_window_id, window::Event::Resized { width, height }) => { Some(Message::WindowResize(width, height)) } + iced::Event::PlatformSpecific(PlatformSpecific::Wayland(wayland::Event::Window( + WindowEvent::State(s), + .., + ))) => Some(Message::WindowState(s)), + iced::Event::PlatformSpecific(PlatformSpecific::Wayland(wayland::Event::Output( + wayland::OutputEvent::Created(Some(info)), + o, + ))) if info.name.is_some() => Some(Message::PageMessage(crate::pages::Message::Panel( + panel::Message::OutputAdded(info.name.unwrap(), o), + ))), + iced::Event::PlatformSpecific(PlatformSpecific::Wayland(wayland::Event::Output( + wayland::OutputEvent::Removed, + o, + ))) => Some(Message::PageMessage(crate::pages::Message::Panel( + panel::Message::OutputRemoved(o), + ))), _ => None, }); @@ -174,10 +204,20 @@ impl Application for SettingsApp { } }, Message::Page(page) => return self.activate_page(page), - Message::Drag => return drag(), - Message::Close => return close(), - Message::Minimize => return minimize(true), - Message::Maximize => return toggle_maximize(), + Message::Drag => return start_drag_window(window::Id(0)), + Message::Close => { + process::exit(0); + } + Message::Minimize => return set_mode_window(window::Id(0), Mode::Hidden), + Message::Maximize => { + if self.sharp_corners { + self.sharp_corners = false; + return set_mode_window(window::Id(0), Mode::Windowed); + } + + self.sharp_corners = true; + return set_mode_window(window::Id(0), Mode::Fullscreen); + } Message::NavBar(key) => { if let Some(page) = self.nav_bar.data::(key).copied() { return self.activate_page(page); @@ -225,12 +265,16 @@ impl Application for SettingsApp { } } }, + Message::WindowState(state) => { + dbg!(&state); + self.sharp_corners = matches!(state, WindowState::Activated); + } } ret } #[allow(clippy::too_many_lines)] - fn view(&self) -> Element { + fn view(&self, _id: window::Id) -> Element { let (nav_bar_message, nav_bar_toggled) = if self.is_condensed { ( Message::ToggleNavBarCondensed, @@ -302,6 +346,7 @@ impl Application for SettingsApp { .padding([0, 8, 8, 8]) .width(Length::Fill) .height(Length::Fill) + .style(theme::Container::Background) .into(); column(vec![header, content]).into() @@ -314,6 +359,25 @@ impl Application for SettingsApp { fn scale_factor(&self) -> f64 { self.scaling_factor as f64 } + + fn close_requested(&self, id: window::Id) -> Self::Message { + if id == window::Id(0) { + Message::Close + } else { + Message::None + } + } + + fn style(&self) -> ::Style { + if self.sharp_corners { + cosmic::theme::Application::default() + } else { + cosmic::theme::Application::Custom(Box::new(|theme| application::Appearance { + background_color: Color::TRANSPARENT, + text_color: theme.cosmic().on_bg_color().into(), + })) + } + } } impl SettingsApp { diff --git a/app/src/main.rs b/app/src/main.rs index e079057..39cd94b 100644 --- a/app/src/main.rs +++ b/app/src/main.rs @@ -20,7 +20,10 @@ pub mod pages; use env_logger::Env; -use cosmic::iced::Application; +use cosmic::{ + iced::{wayland::actions::window::SctkWindowSettings, Application, Limits}, + iced_sctk::settings::InitialSurface, +}; use i18n_embed::DesktopLanguageRequester; /// # Errors @@ -47,7 +50,11 @@ pub fn main() -> color_eyre::Result<()> { cosmic::settings::set_default_icon_theme("Pop"); let mut settings = cosmic::settings(); - settings.window.min_size = Some((600, 300)); + settings.initial_surface = InitialSurface::XdgWindow(SctkWindowSettings { + size_limits: Limits::NONE.min_width(600.0).min_height(300.0), + ..Default::default() + }); + SettingsApp::run(settings)?; Ok(()) diff --git a/app/src/pages/desktop/panel/mod.rs b/app/src/pages/desktop/panel/mod.rs index ceef319..4e45356 100644 --- a/app/src/pages/desktop/panel/mod.rs +++ b/app/src/pages/desktop/panel/mod.rs @@ -2,6 +2,7 @@ use cosmic::{ iced::widget::{button, container, horizontal_space, pick_list, row}, iced::Length, iced_widget::slider, + sctk::reexports::client::{backend::ObjectId, protocol::wl_output::WlOutput, Proxy}, theme, widget::{icon, list, settings, text, toggler}, Element, @@ -12,7 +13,7 @@ use cosmic_config::CosmicConfigEntry; use cosmic_panel_config::{AutoHide, CosmicPanelConfig, CosmicPanelOuput, PanelAnchor, PanelSize}; use cosmic_settings_page::{self as page, section, Section}; use slotmap::SlotMap; -use std::borrow::Cow; +use std::{borrow::Cow, collections::HashMap}; mod applets; @@ -21,6 +22,7 @@ pub struct Page { panel_config: Option, // TODO move these into panel config appearance: Appearance, + pub outputs: HashMap, } impl Default for Page { @@ -38,6 +40,7 @@ impl Default for Page { config_helper, panel_config, appearance: Appearance::Dark, + outputs: HashMap::new(), } } } @@ -82,7 +85,10 @@ pub fn behavior_and_position() -> Section { ]) .view::(|_binder, page, section| { let descriptions = §ion.descriptions; - let panel_config = page.panel_config.as_ref().unwrap(); + let panel_config = match page.panel_config.as_ref() { + Some(panel_config) => panel_config, + None => return Element::from(text(fl!("unknown"))), + }; settings::view_section(§ion.title) .add(settings::item( &descriptions[0], @@ -103,7 +109,23 @@ pub fn behavior_and_position() -> Section { |a| Message::PanelAnchor(a.0), ), )) - .add(settings::item(&descriptions[2], text("todo"))) + .add(settings::item( + &descriptions[2], + pick_list( + Cow::from( + Some(fl!("all")) + .into_iter() + .chain(page.outputs.values().map(|(name, _)| name.clone())) + .collect::>(), + ), + match &panel_config.output { + CosmicPanelOuput::All => Some(fl!("all")), + CosmicPanelOuput::Active => None, + CosmicPanelOuput::Name(ref name) => Some(name.clone()), + }, + Message::Output, + ), + )) .apply(Element::from) .map(crate::pages::Message::Panel) }) @@ -119,9 +141,12 @@ pub fn style() -> Section { fl!("panel-style", "size"), fl!("panel-style", "background-opacity"), ]) - .view::(|binder, page, section| { + .view::(|_binder, page, section| { let descriptions = §ion.descriptions; - let panel_config = page.panel_config.as_ref().unwrap(); + let panel_config = match page.panel_config.as_ref() { + Some(panel_config) => panel_config, + None => return Element::from(text(fl!("unknown"))), + }; settings::view_section(§ion.title) .add(settings::item( &descriptions[0], @@ -145,41 +170,55 @@ pub fn style() -> Section { )) .add(settings::item( &descriptions[3], - slider( - 0..=4, - match panel_config.size { - PanelSize::XS => 0, - PanelSize::S => 1, - PanelSize::M => 2, - PanelSize::L => 3, - PanelSize::XL => 4, - }, - |v| { - if v == 0 { - Message::PanelSize(PanelSize::XS) - } else if v == 1 { - Message::PanelSize(PanelSize::S) - } else if v == 2 { - Message::PanelSize(PanelSize::M) - } else if v == 3 { - Message::PanelSize(PanelSize::L) - } else { - Message::PanelSize(PanelSize::XL) - } - }, - ), + // TODO custom discrete slider variant + row![ + text(fl!("small")), + slider( + 0..=4, + match panel_config.size { + PanelSize::XS => 0, + PanelSize::S => 1, + PanelSize::M => 2, + PanelSize::L => 3, + PanelSize::XL => 4, + }, + |v| { + if v == 0 { + Message::PanelSize(PanelSize::XS) + } else if v == 1 { + Message::PanelSize(PanelSize::S) + } else if v == 2 { + Message::PanelSize(PanelSize::M) + } else if v == 3 { + Message::PanelSize(PanelSize::L) + } else { + Message::PanelSize(PanelSize::XL) + } + }, + ), + text(fl!("large")) + ] + .spacing(12), )) .add(settings::item( &descriptions[4], - slider( - 0..=100, - (match panel_config.background { - cosmic_panel_config::CosmicPanelBackground::ThemeDefault(Some(a)) - | cosmic_panel_config::CosmicPanelBackground::Color([_, _, _, a]) => a, - _ => 0.0, - } * 100.0) as i32, - |v| Message::Opacity(v as f32 / 100.0), - ), + row![ + text(fl!("number", HashMap::from_iter(vec![("number", 0)]))), + slider( + 0..=100, + (match panel_config.background { + cosmic_panel_config::CosmicPanelBackground::ThemeDefault(Some( + a, + )) + | cosmic_panel_config::CosmicPanelBackground::Color([_, _, _, a]) => + a, + _ => 0.0, + } * 100.0) as i32, + |v| Message::Opacity(v as f32 / 100.0), + ), + text(fl!("number", HashMap::from_iter(vec![("number", 100)]))), + ] + .spacing(12), )) .apply(Element::from) .map(crate::pages::Message::Panel) @@ -216,6 +255,8 @@ pub fn configuration() -> Section { Element::from(settings) }) } + +#[allow(clippy::module_name_repetitions)] pub fn panel_dock_links() -> Section { Section::default() .title(fl!("desktop-panels-and-applets")) @@ -270,6 +311,7 @@ pub fn panel_dock_links() -> Section { }) } +#[allow(clippy::module_name_repetitions)] pub fn add_panel() -> Section { Section::default() .title(fl!("panel-missing")) @@ -277,12 +319,8 @@ pub fn add_panel() -> Section { fl!("panel-missing", "desc"), fl!("panel-missing", "fix"), ]) - .view::(|binder, _page, section| { - let desktop = binder - .page::() - .expect("desktop page not found"); - - let descriptions = §ion.descriptions; + .view::(|_binder, _page, section| { + // _descriptions = §ion.descriptions; settings::view_section(§ion.title) .apply(Element::from) .map(crate::pages::Message::Desktop) @@ -325,13 +363,15 @@ pub enum Message { // panel messages AutoHidePanel(bool), PanelAnchor(PanelAnchor), - Output(CosmicPanelOuput), + Output(String), AnchorGap(bool), PanelSize(PanelSize), Appearance(Appearance), ExtendToEdge(bool), Opacity(f32), Applets, + OutputAdded(String, WlOutput), + OutputRemoved(WlOutput), } impl Page { @@ -347,7 +387,7 @@ impl Page { handle_size: 4, }); - let _ = panel_config.write_entry(helper); + _ = panel_config.write_entry(helper); } Message::PanelAnchor(anchor) => { let helper = self.config_helper.as_ref().unwrap(); @@ -355,16 +395,26 @@ impl Page { panel_config.anchor = anchor; - let _ = panel_config.write_entry(helper); + _ = panel_config.write_entry(helper); + } + Message::Output(name) => { + let helper = self.config_helper.as_ref().unwrap(); + let panel_config = self.panel_config.as_mut().unwrap(); + + panel_config.output = match name { + s if s == fl!("all") => CosmicPanelOuput::All, + _ => CosmicPanelOuput::Name(name), + }; + + _ = panel_config.write_entry(helper); } - Message::Output(_) => todo!(), Message::AnchorGap(enabled) => { let helper = self.config_helper.as_ref().unwrap(); let panel_config = self.panel_config.as_mut().unwrap(); panel_config.anchor_gap = enabled; - let _ = panel_config.write_entry(helper); + _ = panel_config.write_entry(helper); } Message::PanelSize(size) => { let helper = self.config_helper.as_ref().unwrap(); @@ -372,7 +422,7 @@ impl Page { panel_config.size = size; - let _ = panel_config.write_entry(helper); + _ = panel_config.write_entry(helper); } Message::Appearance(_) => { //TODO update panel config to support these kinds of configs @@ -383,7 +433,7 @@ impl Page { panel_config.expand_to_edges = enabled; - let _ = panel_config.write_entry(helper); + _ = panel_config.write_entry(helper); } Message::Opacity(opacity) => { let helper = self.config_helper.as_ref().unwrap(); @@ -398,9 +448,16 @@ impl Page { } } - let _ = panel_config.write_entry(helper); + _ = panel_config.write_entry(helper); } Message::Applets => todo!(), + + Message::OutputAdded(name, output) => { + self.outputs.insert(output.id(), (name, output)); + } + Message::OutputRemoved(output) => { + self.outputs.remove(&output.id()); + } } } } diff --git a/i18n/en/cosmic_settings.ftl b/i18n/en/cosmic_settings.ftl index 2568be9..c0dabe3 100644 --- a/i18n/en/cosmic_settings.ftl +++ b/i18n/en/cosmic_settings.ftl @@ -2,6 +2,8 @@ app = COSMIC Settings unknown = Unknown +number = { $number } + ## Desktop desktop = Desktop @@ -73,6 +75,9 @@ panel-style = Style .appearance = Appearance .size = Size .background-opacity = Background opacity + +small = Small +large = Large panel-applets = Configuration .desc = Configure panel applets. @@ -82,6 +87,9 @@ panel-missing = Panel Configuration is Missing .fix = Reset to default applets = Applets + +all = All + ## Desktop: Wallpaper wallpaper = Wallpaper