wip: add subsection button for dock and panel
This commit is contained in:
parent
1379363e0b
commit
ce15eebdb8
14 changed files with 531 additions and 133 deletions
496
Cargo.lock
generated
496
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -25,6 +25,8 @@ rust-embed = "6.6.1"
|
||||||
slotmap = "1.0.6"
|
slotmap = "1.0.6"
|
||||||
tokio = "1.27.0"
|
tokio = "1.27.0"
|
||||||
downcast-rs = "1.2.0"
|
downcast-rs = "1.2.0"
|
||||||
|
log = "0.4"
|
||||||
|
env_logger = "0.10"
|
||||||
|
|
||||||
[dependencies.i18n-embed]
|
[dependencies.i18n-embed]
|
||||||
version = "0.13.8"
|
version = "0.13.8"
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,9 @@ impl Application for SettingsApp {
|
||||||
crate::pages::Message::External { .. } => {
|
crate::pages::Message::External { .. } => {
|
||||||
todo!("external plugins not supported yet");
|
todo!("external plugins not supported yet");
|
||||||
}
|
}
|
||||||
|
crate::pages::Message::Page(page) => {
|
||||||
|
return self.activate_page(page);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
|
|
@ -273,10 +276,10 @@ impl Application for SettingsApp {
|
||||||
horizontal_space(Length::Fill),
|
horizontal_space(Length::Fill),
|
||||||
(if self.search.is_active() {
|
(if self.search.is_active() {
|
||||||
self.search_view()
|
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) {
|
} else if let Some(content) = self.pages.content(self.active_page) {
|
||||||
self.page_view(content)
|
self.page_view(content)
|
||||||
|
} else if let Some(sub_pages) = self.pages.sub_pages(self.active_page) {
|
||||||
|
self.sub_page_view(sub_pages)
|
||||||
} else {
|
} else {
|
||||||
panic!("page without sub-pages or content");
|
panic!("page without sub-pages or content");
|
||||||
})
|
})
|
||||||
|
|
@ -297,7 +300,7 @@ impl Application for SettingsApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn theme(&self) -> Theme {
|
fn theme(&self) -> Theme {
|
||||||
self.theme
|
self.theme.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scale_factor(&self) -> f64 {
|
fn scale_factor(&self) -> f64 {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ pub mod widget;
|
||||||
|
|
||||||
pub mod pages;
|
pub mod pages;
|
||||||
|
|
||||||
|
use env_logger::Env;
|
||||||
|
|
||||||
use cosmic::iced::Application;
|
use cosmic::iced::Application;
|
||||||
use i18n_embed::DesktopLanguageRequester;
|
use i18n_embed::DesktopLanguageRequester;
|
||||||
|
|
||||||
|
|
@ -25,6 +27,11 @@ use i18n_embed::DesktopLanguageRequester;
|
||||||
///
|
///
|
||||||
/// Returns error if iced fails to run the application.
|
/// Returns error if iced fails to run the application.
|
||||||
pub fn main() -> color_eyre::Result<()> {
|
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()?;
|
color_eyre::install()?;
|
||||||
|
|
||||||
if std::env::var("RUST_SPANTRACE").is_err() {
|
if std::env::var("RUST_SPANTRACE").is_err() {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ pub mod appearance;
|
||||||
pub mod dock;
|
pub mod dock;
|
||||||
pub mod notifications;
|
pub mod notifications;
|
||||||
pub mod options;
|
pub mod options;
|
||||||
|
pub mod panel;
|
||||||
pub mod wallpaper;
|
pub mod wallpaper;
|
||||||
pub mod workspaces;
|
pub mod workspaces;
|
||||||
|
|
||||||
|
|
@ -33,7 +34,6 @@ impl page::AutoBind<crate::pages::Message> for Page {
|
||||||
page.sub_page::<options::Page>()
|
page.sub_page::<options::Page>()
|
||||||
.sub_page::<wallpaper::Page>()
|
.sub_page::<wallpaper::Page>()
|
||||||
.sub_page::<appearance::Page>()
|
.sub_page::<appearance::Page>()
|
||||||
.sub_page::<dock::Page>()
|
|
||||||
.sub_page::<workspaces::Page>()
|
.sub_page::<workspaces::Page>()
|
||||||
.sub_page::<notifications::Page>()
|
.sub_page::<notifications::Page>()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,10 @@
|
||||||
use super::Message;
|
use super::Message;
|
||||||
use apply::Apply;
|
use apply::Apply;
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
iced::widget::horizontal_space,
|
iced::widget::{button, container, horizontal_space, row},
|
||||||
iced::Length,
|
iced::Length,
|
||||||
widget::{settings, toggler},
|
theme,
|
||||||
|
widget::{icon, list, settings, toggler},
|
||||||
Element,
|
Element,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -28,17 +29,23 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
sections.insert(hot_corner()),
|
sections.insert(hot_corner()),
|
||||||
sections.insert(top_panel()),
|
sections.insert(top_panel()),
|
||||||
sections.insert(window_controls()),
|
sections.insert(window_controls()),
|
||||||
|
sections.insert(panel_dock_links()),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn info(&self) -> page::Info {
|
fn info(&self) -> page::Info {
|
||||||
page::Info::new("desktop-options", "video-display-symbolic")
|
page::Info::new("desktop-panel-options", "video-display-symbolic")
|
||||||
.title(fl!("desktop-options"))
|
.title(fl!("desktop-panel-options"))
|
||||||
.description(fl!("desktop-options", "desc"))
|
.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> {
|
pub fn hot_corner() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
|
|
@ -159,3 +166,57 @@ pub fn window_controls() -> Section<crate::pages::Message> {
|
||||||
.map(crate::pages::Message::Desktop)
|
.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(§ion.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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
33
app/src/pages/desktop/panel.rs
Normal file
33
app/src/pages/desktop/panel.rs
Normal 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 {}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
// Copyright 2023 System76 <info@system76.com>
|
// Copyright 2023 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
use cosmic_settings_page::Entity;
|
||||||
|
|
||||||
pub mod desktop;
|
pub mod desktop;
|
||||||
pub mod networking;
|
pub mod networking;
|
||||||
pub mod sound;
|
pub mod sound;
|
||||||
|
|
@ -13,4 +15,5 @@ pub enum Message {
|
||||||
DateAndTime(time::date::Message),
|
DateAndTime(time::date::Message),
|
||||||
Desktop(desktop::Message),
|
Desktop(desktop::Message),
|
||||||
External { id: String, message: Vec<u8> },
|
External { id: String, message: Vec<u8> },
|
||||||
|
Page(Entity),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,25 @@ pub fn sub_page_button(entity: page::Entity, page: &page::Info) -> Element<page:
|
||||||
.into()
|
.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]
|
#[must_use]
|
||||||
pub fn unimplemented_page<Message: 'static>() -> Element<'static, Message> {
|
pub fn unimplemented_page<Message: 'static>() -> Element<'static, Message> {
|
||||||
settings::view_section("")
|
settings::view_section("")
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ appearance = Appearance
|
||||||
|
|
||||||
## Desktop: Dock & Panel
|
## Desktop: Dock & Panel
|
||||||
|
|
||||||
dock = Dock & Top Panel
|
dock = Dock
|
||||||
.desc = Customize size, positions, and more for Dock and Top Panel.
|
.desc = Panel with pinned applications.
|
||||||
|
|
||||||
## Desktop: Notifications
|
## Desktop: Notifications
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ notifications = Notifications
|
||||||
|
|
||||||
## Desktop: Options
|
## Desktop: Options
|
||||||
|
|
||||||
desktop-options = Desktop Options
|
desktop-panel-options = Desktop and Panel
|
||||||
.desc = Super Key action, hot corners, window control options.
|
.desc = Super Key action, hot corners, window control options.
|
||||||
|
|
||||||
super-key-action = Super Key Action
|
super-key-action = Super Key Action
|
||||||
|
|
@ -43,6 +43,12 @@ window-controls = Window Controls
|
||||||
.minimize = Show Minimize Button
|
.minimize = Show Minimize Button
|
||||||
.maximize = Show Maximize 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
|
## Desktop: Wallpaper
|
||||||
|
|
||||||
wallpaper = Wallpaper
|
wallpaper = Wallpaper
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ notifications = Notifications
|
||||||
|
|
||||||
## Desktop: Options
|
## 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.
|
.desc = Action de la Touche Super, coins actifs, options du contrôle des fenêtres.
|
||||||
|
|
||||||
super-key-action = Action Touche Super
|
super-key-action = Action Touche Super
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ notifications = Notificações
|
||||||
|
|
||||||
## Desktop: Options
|
## 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.
|
.desc = Ação da tecla Super, cantos ativos, opções de controlo de janelas.
|
||||||
|
|
||||||
super-key-action = Ação da tecla Super
|
super-key-action = Ação da tecla Super
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ notifications = Notificações
|
||||||
|
|
||||||
## Desktop: Options
|
## 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.
|
.desc = Ação da Tecla Super, cantos quentes, opções de controle de janela.
|
||||||
|
|
||||||
super-key-action = Ação da Tecla Super
|
super-key-action = Ação da Tecla Super
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ notifications = Notifikationer
|
||||||
|
|
||||||
## Desktop: Options
|
## Desktop: Options
|
||||||
|
|
||||||
desktop-options = Skrivbordsalternativ
|
desktop-panel-options = Skrivbordsalternativ
|
||||||
.desc = Supertangent funktion, heta hörn, och fönsterkontroll alternativ.
|
.desc = Supertangent funktion, heta hörn, och fönsterkontroll alternativ.
|
||||||
|
|
||||||
super-key-action = Supertangentfunktion
|
super-key-action = Supertangentfunktion
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue