wip: add subsection button for dock and panel

This commit is contained in:
Ashley Wulber 2023-05-23 14:05:32 -04:00 committed by Michael Aaron Murphy
parent 1379363e0b
commit ce15eebdb8
No known key found for this signature in database
GPG key ID: B2732D4240C9212C
14 changed files with 531 additions and 133 deletions

496
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -25,6 +25,8 @@ rust-embed = "6.6.1"
slotmap = "1.0.6"
tokio = "1.27.0"
downcast-rs = "1.2.0"
log = "0.4"
env_logger = "0.10"
[dependencies.i18n-embed]
version = "0.13.8"

View file

@ -213,6 +213,9 @@ impl Application for SettingsApp {
crate::pages::Message::External { .. } => {
todo!("external plugins not supported yet");
}
crate::pages::Message::Page(page) => {
return self.activate_page(page);
}
},
}
ret
@ -273,10 +276,10 @@ impl Application for SettingsApp {
horizontal_space(Length::Fill),
(if self.search.is_active() {
self.search_view()
} else if let Some(sub_pages) = self.pages.sub_pages(self.active_page) {
self.sub_page_view(sub_pages)
} else if let Some(content) = self.pages.content(self.active_page) {
self.page_view(content)
} else if let Some(sub_pages) = self.pages.sub_pages(self.active_page) {
self.sub_page_view(sub_pages)
} else {
panic!("page without sub-pages or content");
})
@ -297,7 +300,7 @@ impl Application for SettingsApp {
}
fn theme(&self) -> Theme {
self.theme
self.theme.clone()
}
fn scale_factor(&self) -> f64 {

View file

@ -18,6 +18,8 @@ pub mod widget;
pub mod pages;
use env_logger::Env;
use cosmic::iced::Application;
use i18n_embed::DesktopLanguageRequester;
@ -25,6 +27,11 @@ use i18n_embed::DesktopLanguageRequester;
///
/// Returns error if iced fails to run the application.
pub fn main() -> color_eyre::Result<()> {
let env = Env::default()
.filter_or("MY_LOG_LEVEL", "info")
.write_style_or("MY_LOG_STYLE", "always");
env_logger::init_from_env(env);
color_eyre::install()?;
if std::env::var("RUST_SPANTRACE").is_err() {

View file

@ -5,6 +5,7 @@ pub mod appearance;
pub mod dock;
pub mod notifications;
pub mod options;
pub mod panel;
pub mod wallpaper;
pub mod workspaces;
@ -33,7 +34,6 @@ impl page::AutoBind<crate::pages::Message> for Page {
page.sub_page::<options::Page>()
.sub_page::<wallpaper::Page>()
.sub_page::<appearance::Page>()
.sub_page::<dock::Page>()
.sub_page::<workspaces::Page>()
.sub_page::<notifications::Page>()
}

View file

@ -4,9 +4,10 @@
use super::Message;
use apply::Apply;
use cosmic::{
iced::widget::horizontal_space,
iced::widget::{button, container, horizontal_space, row},
iced::Length,
widget::{settings, toggler},
theme,
widget::{icon, list, settings, toggler},
Element,
};
@ -28,17 +29,23 @@ impl page::Page<crate::pages::Message> for Page {
sections.insert(hot_corner()),
sections.insert(top_panel()),
sections.insert(window_controls()),
sections.insert(panel_dock_links()),
])
}
fn info(&self) -> page::Info {
page::Info::new("desktop-options", "video-display-symbolic")
.title(fl!("desktop-options"))
.description(fl!("desktop-options", "desc"))
page::Info::new("desktop-panel-options", "video-display-symbolic")
.title(fl!("desktop-panel-options"))
.description(fl!("desktop-panel-options", "desc"))
}
}
impl page::AutoBind<crate::pages::Message> for Page {}
impl page::AutoBind<crate::pages::Message> for Page {
fn sub_pages(page: page::Insert<crate::pages::Message>) -> page::Insert<crate::pages::Message> {
page.sub_page::<super::panel::Page>()
.sub_page::<super::dock::Page>()
}
}
pub fn hot_corner() -> Section<crate::pages::Message> {
Section::default()
@ -159,3 +166,57 @@ pub fn window_controls() -> Section<crate::pages::Message> {
.map(crate::pages::Message::Desktop)
})
}
pub fn panel_dock_links() -> Section<crate::pages::Message> {
Section::default()
.title(fl!("desktop-panels-and-applets"))
.view::<Page>(|binder, _page, section| {
// TODO probably a way of getting the entity and its info
let mut settings = settings::view_section(&section.title);
settings = if let Some((panel_entity, panel_info)) =
binder.info.iter().find(|(_, v)| v.id == "panel")
{
settings.add(
settings::item::builder(panel_info.title.clone())
.description(panel_info.description.clone())
.control(row!(
horizontal_space(Length::Fill),
icon("go-next-symbolic", 20).style(theme::Svg::Symbolic)
))
.spacing(16)
.apply(container)
.style(theme::Container::custom(list::column::style))
.apply(button)
.padding(0)
.style(theme::Button::Transparent)
.on_press(crate::pages::Message::Page(panel_entity)),
)
} else {
settings
};
settings = if let Some((dock_entity, dock_info)) =
binder.info.iter().find(|(_, v)| v.id == "dock")
{
settings.add(
settings::item::builder(dock_info.title.clone())
.description(dock_info.description.clone())
.control(row!(
horizontal_space(Length::Fill),
icon("go-next-symbolic", 20).style(theme::Svg::Symbolic)
))
.spacing(16)
.apply(container)
.style(theme::Container::custom(list::column::style))
.apply(button)
.padding(0)
.style(theme::Button::Transparent)
.on_press(crate::pages::Message::Page(dock_entity)),
)
} else {
settings
};
Element::from(settings)
})
}

View file

@ -0,0 +1,33 @@
use cosmic::{
iced::widget::horizontal_space,
iced::Length,
widget::{settings, toggler},
Element,
};
use super::Message;
use apply::Apply;
use cosmic_settings_page::Section;
use cosmic_settings_page::{self as page, section};
use slotmap::SlotMap;
#[derive(Default)]
pub struct Page;
impl page::Page<crate::pages::Message> for Page {
#[allow(clippy::too_many_lines)]
fn content(
&self,
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
) -> Option<page::Content> {
Some(vec![sections.insert(Section::default())])
}
fn info(&self) -> page::Info {
page::Info::new("panel", "preferences-pop-desktop-dock-symbolic")
.title(fl!("panel"))
.description(fl!("panel", "desc"))
}
}
impl page::AutoBind<crate::pages::Message> for Page {}

View file

@ -1,6 +1,8 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only
use cosmic_settings_page::Entity;
pub mod desktop;
pub mod networking;
pub mod sound;
@ -13,4 +15,5 @@ pub enum Message {
DateAndTime(time::date::Message),
Desktop(desktop::Message),
External { id: String, message: Vec<u8> },
Page(Entity),
}

View file

@ -106,6 +106,25 @@ pub fn sub_page_button(entity: page::Entity, page: &page::Info) -> Element<page:
.into()
}
#[must_use]
pub fn sub_page_section(entity: page::Entity, page: &page::Info) -> Element<page::Entity> {
settings::item::builder(page.title.as_str())
.description(page.description.as_str())
.control(row!(
horizontal_space(Length::Fill),
icon("go-next-symbolic", 20).style(theme::Svg::Symbolic)
))
.spacing(16)
.apply(container)
.padding([20, 24])
.style(theme::Container::custom(list::column::style))
.apply(button)
.padding(0)
.style(theme::Button::Transparent)
.on_press(entity)
.into()
}
#[must_use]
pub fn unimplemented_page<Message: 'static>() -> Element<'static, Message> {
settings::view_section("")

View file

@ -13,8 +13,8 @@ appearance = Appearance
## Desktop: Dock & Panel
dock = Dock & Top Panel
.desc = Customize size, positions, and more for Dock and Top Panel.
dock = Dock
.desc = Panel with pinned applications.
## Desktop: Notifications
@ -24,7 +24,7 @@ notifications = Notifications
## Desktop: Options
desktop-options = Desktop Options
desktop-panel-options = Desktop and Panel
.desc = Super Key action, hot corners, window control options.
super-key-action = Super Key Action
@ -43,6 +43,12 @@ window-controls = Window Controls
.minimize = Show Minimize Button
.maximize = Show Maximize Button
desktop-panels-and-applets = Desktop Panels and Applets
panel = Panel
.desc = Top bar with desktop controls and menus.
dock = Dock
.desc = Panel with pinned applications.
## Desktop: Wallpaper
wallpaper = Wallpaper

View file

@ -24,7 +24,7 @@ notifications = Notifications
## Desktop: Options
desktop-options = Options Bureau
desktop-panel-options = Options Bureau
.desc = Action de la Touche Super, coins actifs, options du contrôle des fenêtres.
super-key-action = Action Touche Super

View file

@ -24,7 +24,7 @@ notifications = Notificações
## Desktop: Options
desktop-options = Opções do ambiente de trabalho
desktop-panel-options = Opções do ambiente de trabalho
.desc = Ação da tecla Super, cantos ativos, opções de controlo de janelas.
super-key-action = Ação da tecla Super

View file

@ -24,7 +24,7 @@ notifications = Notificações
## Desktop: Options
desktop-options = Opções do Desktop
desktop-panel-options = Opções do Desktop
.desc = Ação da Tecla Super, cantos quentes, opções de controle de janela.
super-key-action = Ação da Tecla Super

View file

@ -24,7 +24,7 @@ notifications = Notifikationer
## Desktop: Options
desktop-options = Skrivbordsalternativ
desktop-panel-options = Skrivbordsalternativ
.desc = Supertangent funktion, heta hörn, och fönsterkontroll alternativ.
super-key-action = Supertangentfunktion