From 3d75343958de7f6011597cd11d35f215c006e849 Mon Sep 17 00:00:00 2001 From: git-f0x <150025636+git-f0x@users.noreply.github.com> Date: Fri, 2 Aug 2024 21:18:11 +0200 Subject: [PATCH] improv: rearrange pages to match design --- cosmic-settings/src/app.rs | 14 ++-- cosmic-settings/src/main.rs | 8 +- cosmic-settings/src/pages/desktop/mod.rs | 8 +- .../src/pages/desktop/panel/mod.rs | 2 +- .../{options.rs => window_management.rs} | 78 +++---------------- cosmic-settings/src/pages/mod.rs | 2 +- i18n/en/cosmic_settings.ftl | 27 ++++--- 7 files changed, 47 insertions(+), 92 deletions(-) rename cosmic-settings/src/pages/desktop/{options.rs => window_management.rs} (64%) diff --git a/cosmic-settings/src/app.rs b/cosmic-settings/src/app.rs index 27eb7ff..8c8041f 100644 --- a/cosmic-settings/src/app.rs +++ b/cosmic-settings/src/app.rs @@ -61,7 +61,8 @@ impl SettingsApp { PageCommands::Appearance => self.pages.page_id::(), PageCommands::Bluetooth => None, PageCommands::DateTime => self.pages.page_id::(), - PageCommands::DesktopPanel => self.pages.page_id::(), + PageCommands::Panel => self.pages.page_id::(), + PageCommands::Dock => self.pages.page_id::(), PageCommands::Displays => self.pages.page_id::(), PageCommands::Firmware => self.pages.page_id::(), PageCommands::Keyboard => self.pages.page_id::(), @@ -74,6 +75,9 @@ impl SettingsApp { PageCommands::Touchpad => self.pages.page_id::(), PageCommands::Users => self.pages.page_id::(), PageCommands::Wallpaper => self.pages.page_id::(), + PageCommands::WindowManagement => { + self.pages.page_id::() + } PageCommands::Workspaces => self.pages.page_id::(), } } @@ -311,16 +315,16 @@ impl cosmic::Application for SettingsApp { page::update!(self.pages, message, desktop::Page); } - crate::pages::Message::DesktopOptions(message) => { - page::update!(self.pages, message, desktop::options::Page); - } - crate::pages::Message::DesktopWallpaper(message) => { if let Some(page) = self.pages.page_mut::() { return page.update(message).map(Into::into); } } + crate::pages::Message::WindowManagement(message) => { + page::update!(self.pages, message, desktop::window_management::Page); + } + crate::pages::Message::DesktopWorkspaces(message) => { page::update!(self.pages, message, desktop::workspaces::Page); } diff --git a/cosmic-settings/src/main.rs b/cosmic-settings/src/main.rs index 89c3f1c..8a1e5d3 100644 --- a/cosmic-settings/src/main.rs +++ b/cosmic-settings/src/main.rs @@ -46,8 +46,10 @@ pub enum PageCommands { Bluetooth, /// DateTime settings page DateTime, - /// Desktop and panel settings page - DesktopPanel, + /// Panel settings page + Panel, + /// Dock settings page + Dock, /// Displays settings page Displays, /// Firmware settings page @@ -72,6 +74,8 @@ pub enum PageCommands { Users, /// Wallpaper settings page Wallpaper, + /// Window management page + WindowManagement, /// Workspaces settings page Workspaces, } diff --git a/cosmic-settings/src/pages/desktop/mod.rs b/cosmic-settings/src/pages/desktop/mod.rs index 7335fe7..cda6e1c 100644 --- a/cosmic-settings/src/pages/desktop/mod.rs +++ b/cosmic-settings/src/pages/desktop/mod.rs @@ -3,9 +3,9 @@ pub mod appearance; pub mod dock; -pub mod options; pub mod panel; pub mod wallpaper; +pub mod window_management; pub mod workspaces; use cosmic::{config::CosmicTk, cosmic_config::CosmicConfigEntry}; @@ -46,9 +46,11 @@ impl page::Page for Page { impl page::AutoBind for Page { fn sub_pages(page: page::Insert) -> page::Insert { - page.sub_page::() - .sub_page::() + page.sub_page::() .sub_page::() + .sub_page::() + .sub_page::() + .sub_page::() .sub_page::() } } diff --git a/cosmic-settings/src/pages/desktop/panel/mod.rs b/cosmic-settings/src/pages/desktop/panel/mod.rs index 5dadb8a..2ad64b5 100644 --- a/cosmic-settings/src/pages/desktop/panel/mod.rs +++ b/cosmic-settings/src/pages/desktop/panel/mod.rs @@ -127,7 +127,7 @@ impl page::Page for Page { } fn info(&self) -> page::Info { - page::Info::new("panel", "preferences-dock-symbolic") + page::Info::new("panel", "preferences-panel-symbolic") .title(fl!("panel")) .description(fl!("panel", "desc")) } diff --git a/cosmic-settings/src/pages/desktop/options.rs b/cosmic-settings/src/pages/desktop/window_management.rs similarity index 64% rename from cosmic-settings/src/pages/desktop/options.rs rename to cosmic-settings/src/pages/desktop/window_management.rs index f17bc22..c4781c0 100644 --- a/cosmic-settings/src/pages/desktop/options.rs +++ b/cosmic-settings/src/pages/desktop/window_management.rs @@ -2,9 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-only use cosmic::{ - iced::Length, - theme, - widget::{self, button, container, horizontal_space, icon, row, settings, toggler}, + widget::{self, settings, toggler}, Apply, Element, }; @@ -65,23 +63,20 @@ impl page::Page for Page { Some(vec![ sections.insert(super_key_action()), sections.insert(window_controls()), - sections.insert(panel_dock_links()), ]) } fn info(&self) -> page::Info { - page::Info::new("desktop-panel-options", "video-display-symbolic") - .title(fl!("desktop-panel-options")) - .description(fl!("desktop-panel-options", "desc")) + page::Info::new( + "window-management", + "preferences-window-management-symbolic", + ) + .title(fl!("window-management")) + .description(fl!("window-management", "desc")) } } -impl page::AutoBind for Page { - fn sub_pages(page: page::Insert) -> page::Insert { - page.sub_page::() - .sub_page::() - } -} +impl page::AutoBind for Page {} pub fn super_key_action() -> Section { let mut descriptions = Slab::new(); @@ -105,7 +100,7 @@ pub fn super_key_action() -> Section { )), ) .apply(Element::from) - .map(crate::pages::Message::DesktopOptions) + .map(crate::pages::Message::WindowManagement) }) } @@ -146,61 +141,6 @@ pub fn window_controls() -> Section { }) } -pub fn panel_dock_links() -> Section { - Section::default() - .title(fl!("desktop-panels-and-applets")) - .view::(move |binder, _page, section| { - // TODO probably a way of getting the entity and its info - let mut settings = settings::view_section(§ion.title); - - if let Some((panel_entity, panel_info)) = - binder.info.iter().find(|(_, v)| v.id == "panel") - { - let control = row::with_children(vec![ - horizontal_space(Length::Fill).into(), - icon::from_name("go-next-symbolic").size(16).into(), - ]); - - settings = settings.add( - settings::item::builder(panel_info.title.clone()) - .description(panel_info.description.clone()) - .control(control) - .spacing(16) - .apply(container) - .style(theme::Container::List) - .apply(button) - .style(theme::Button::Transparent) - .on_press(crate::pages::Message::Page(panel_entity)), - ); - } - - settings = if let Some((dock_entity, dock_info)) = - binder.info.iter().find(|(_, v)| v.id == "dock") - { - let control = row::with_children(vec![ - horizontal_space(Length::Fill).into(), - icon::from_name("go-next-symbolic").size(16).into(), - ]); - - settings.add( - settings::item::builder(dock_info.title.clone()) - .description(dock_info.description.clone()) - .control(control) - .spacing(16) - .apply(container) - .style(theme::Container::List) - .apply(button) - .style(theme::Button::Transparent) - .on_press(crate::pages::Message::Page(dock_entity)), - ) - } else { - settings - }; - - Element::from(settings) - }) -} - fn super_key_active_config() -> Option { let super_binding = Binding::new(shortcuts::Modifiers::new().logo(), None); diff --git a/cosmic-settings/src/pages/mod.rs b/cosmic-settings/src/pages/mod.rs index 88d5c5d..8ad3170 100644 --- a/cosmic-settings/src/pages/mod.rs +++ b/cosmic-settings/src/pages/mod.rs @@ -19,8 +19,8 @@ pub enum Message { CustomShortcuts(input::keyboard::shortcuts::custom::Message), DateAndTime(time::date::Message), Desktop(desktop::Message), - DesktopOptions(desktop::options::Message), DesktopWallpaper(desktop::wallpaper::Message), + WindowManagement(desktop::window_management::Message), DesktopWorkspaces(desktop::workspaces::Message), Displays(display::Message), Dock(desktop::dock::Message), diff --git a/i18n/en/cosmic_settings.ftl b/i18n/en/cosmic_settings.ftl index c5960b8..d2a6ac0 100644 --- a/i18n/en/cosmic_settings.ftl +++ b/i18n/en/cosmic_settings.ftl @@ -142,19 +142,10 @@ dock = Dock hot-corner = Hot Corner .top-left-corner = Enable top-left hot corner for Workspaces -super-key = Super key - .launcher = Open Launcher - .workspaces = Open Workspaces - .applications = Open Applications - top-panel = Top Panel .workspaces = Show Workspaces Button .applications = Show Applications Button -window-controls = Window Controls - .minimize = Show Minimize Button - .maximize = Show Maximize Button - ## Desktop: Panel panel = Panel @@ -233,6 +224,20 @@ x-hours = { $number -> *[other] { $number } hours } +## Desktop: Window management + +window-management = Window management + .desc = Super key action, window control options, and additional window tiling options. + +super-key = Super key + .launcher = Open Launcher + .workspaces = Open Workspaces + .applications = Open Applications + +window-controls = Window Controls + .minimize = Show minimize button + .maximize = Show maximize button + ## Desktop: Workspaces workspaces = Workspaces @@ -565,10 +570,10 @@ switch-to-prev-workspace = Switch to prev workspace open-application-library = Open Application Library open-workspaces-view = Open Workspaces Overview -## Power +## Power power = Power - .desc = Manage power settings + .desc = Manage power settings power-mode = Power Mode .performance = High performance