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

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),
}