wip: hook up panel messages
This commit is contained in:
parent
ce15eebdb8
commit
e7996f69dd
6 changed files with 189 additions and 9 deletions
76
Cargo.lock
generated
76
Cargo.lock
generated
|
|
@ -758,7 +758,19 @@ dependencies = [
|
|||
"cosmic-config-derive",
|
||||
"dirs 5.0.1",
|
||||
"iced_futures",
|
||||
"notify",
|
||||
"notify 6.0.0",
|
||||
"ron",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cosmic-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic#98ec1bbd487cf5412c0e94ef9ae7694c9b72edbd"
|
||||
dependencies = [
|
||||
"atomicwrites",
|
||||
"dirs 4.0.0",
|
||||
"notify 5.2.0",
|
||||
"ron",
|
||||
"serde",
|
||||
]
|
||||
|
|
@ -772,6 +784,20 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cosmic-panel-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/cosmic-panel#f342e53f95aee2a26c8cc6578cfe5c39a1ed99b5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic)",
|
||||
"ron",
|
||||
"serde",
|
||||
"tracing",
|
||||
"wayland-protocols-wlr",
|
||||
"xdg-shell-wrapper-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cosmic-settings"
|
||||
version = "0.1.0"
|
||||
|
|
@ -780,6 +806,7 @@ dependencies = [
|
|||
"async-channel",
|
||||
"bytecheck",
|
||||
"color-eyre",
|
||||
"cosmic-panel-config",
|
||||
"cosmic-settings-page",
|
||||
"cosmic-settings-system",
|
||||
"cosmic-settings-time",
|
||||
|
|
@ -860,7 +887,7 @@ version = "0.1.0"
|
|||
source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cosmic-config",
|
||||
"cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)",
|
||||
"csscolorparser",
|
||||
"directories",
|
||||
"lazy_static",
|
||||
|
|
@ -2540,7 +2567,7 @@ version = "0.1.0"
|
|||
source = "git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text#bf1c474d0846e31c647444ff7bd5ecb7f361efcd"
|
||||
dependencies = [
|
||||
"apply",
|
||||
"cosmic-config",
|
||||
"cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic?branch=cosmic-advanced-text)",
|
||||
"cosmic-theme",
|
||||
"derive_setters",
|
||||
"fraction",
|
||||
|
|
@ -2893,6 +2920,24 @@ dependencies = [
|
|||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "notify"
|
||||
version = "5.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "729f63e1ca555a43fe3efa4f3efdf4801c479da85b432242a7b726f353c88486"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"crossbeam-channel",
|
||||
"filetime",
|
||||
"fsevent-sys",
|
||||
"inotify",
|
||||
"kqueue",
|
||||
"libc",
|
||||
"mio",
|
||||
"walkdir",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "notify"
|
||||
version = "6.0.0"
|
||||
|
|
@ -4956,6 +5001,7 @@ dependencies = [
|
|||
"wayland-backend",
|
||||
"wayland-client 0.30.1",
|
||||
"wayland-scanner 0.30.0",
|
||||
"wayland-server",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4969,6 +5015,7 @@ dependencies = [
|
|||
"wayland-client 0.30.1",
|
||||
"wayland-protocols 0.30.0",
|
||||
"wayland-scanner 0.30.0",
|
||||
"wayland-server",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4993,6 +5040,20 @@ dependencies = [
|
|||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayland-server"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9062def387c1b1d80e366d8243c2b3bd6d9e4f343032a3e5da8d4aa03866cf89"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"downcast-rs",
|
||||
"io-lifetimes",
|
||||
"nix 0.26.2",
|
||||
"wayland-backend",
|
||||
"wayland-scanner 0.30.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayland-sys"
|
||||
version = "0.29.5"
|
||||
|
|
@ -5541,6 +5602,15 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xdg-shell-wrapper-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/xdg-shell-wrapper?rev=a5bf783#a5bf7832fc091a0fcb685cd297bfa3cddcd72974"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"wayland-protocols-wlr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xkbcommon"
|
||||
version = "0.5.0"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ tokio = "1.27.0"
|
|||
downcast-rs = "1.2.0"
|
||||
log = "0.4"
|
||||
env_logger = "0.10"
|
||||
cosmic-panel-config = { git = "https://github.com/pop-os/cosmic-panel" }
|
||||
|
||||
[dependencies.i18n-embed]
|
||||
version = "0.13.8"
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ use cosmic::{
|
|||
|
||||
use crate::{
|
||||
config::{self, Config},
|
||||
pages::{desktop, sound, system, time},
|
||||
pages::{
|
||||
desktop::{self, panel},
|
||||
sound, system, time,
|
||||
},
|
||||
widget::{page_title, parent_page_button, search_header, sub_page_button},
|
||||
};
|
||||
|
||||
|
|
@ -216,6 +219,11 @@ impl Application for SettingsApp {
|
|||
crate::pages::Message::Page(page) => {
|
||||
return self.activate_page(page);
|
||||
}
|
||||
crate::pages::Message::Panel(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<panel::Page>() {
|
||||
page.update(message);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -5,14 +5,16 @@ use cosmic::{
|
|||
Element,
|
||||
};
|
||||
|
||||
use super::Message;
|
||||
use apply::Apply;
|
||||
use cosmic_panel_config::{AutoHide, CosmicPanelConfig, CosmicPanelOuput, PanelAnchor, PanelSize};
|
||||
use cosmic_settings_page::Section;
|
||||
use cosmic_settings_page::{self as page, section};
|
||||
use slotmap::SlotMap;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Page;
|
||||
pub struct Page {
|
||||
panel_config: CosmicPanelConfig,
|
||||
}
|
||||
|
||||
impl page::Page<crate::pages::Message> for Page {
|
||||
#[allow(clippy::too_many_lines)]
|
||||
|
|
@ -20,7 +22,11 @@ impl page::Page<crate::pages::Message> for Page {
|
|||
&self,
|
||||
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
|
||||
) -> Option<page::Content> {
|
||||
Some(vec![sections.insert(Section::default())])
|
||||
Some(vec![
|
||||
sections.insert(behavior_and_position()),
|
||||
sections.insert(style()),
|
||||
sections.insert(configuration()),
|
||||
])
|
||||
}
|
||||
|
||||
fn info(&self) -> page::Info {
|
||||
|
|
@ -31,3 +37,89 @@ impl page::Page<crate::pages::Message> for Page {
|
|||
}
|
||||
|
||||
impl page::AutoBind<crate::pages::Message> for Page {}
|
||||
|
||||
pub fn behavior_and_position() -> Section<crate::pages::Message> {
|
||||
Section::default()
|
||||
.title(fl!("panel-behavior-and-position"))
|
||||
.descriptions(vec![fl!("panel-behavior-and-position", "autohide")])
|
||||
.view::<Page>(|_binder, page, section| {
|
||||
let descriptions = §ion.descriptions;
|
||||
settings::view_section(§ion.title)
|
||||
.add(settings::item(
|
||||
&descriptions[0],
|
||||
toggler(None, page.panel_config.autohide.is_some(), |value| {
|
||||
Message::AutoHidePanel(value)
|
||||
}),
|
||||
))
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::Panel)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn style() -> Section<crate::pages::Message> {
|
||||
Section::default()
|
||||
.title(fl!("hot-corner"))
|
||||
.descriptions(vec![fl!("hot-corner", "top-left-corner")])
|
||||
.view::<Page>(|binder, _page, section| {
|
||||
let desktop = binder
|
||||
.page::<super::Page>()
|
||||
.expect("desktop page not found");
|
||||
|
||||
let descriptions = §ion.descriptions;
|
||||
settings::view_section(§ion.title)
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::Desktop)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn configuration() -> Section<crate::pages::Message> {
|
||||
Section::default()
|
||||
.title(fl!("hot-corner"))
|
||||
.descriptions(vec![fl!("hot-corner", "top-left-corner")])
|
||||
.view::<Page>(|binder, _page, section| {
|
||||
let desktop = binder
|
||||
.page::<super::Page>()
|
||||
.expect("desktop page not found");
|
||||
|
||||
let descriptions = §ion.descriptions;
|
||||
settings::view_section(§ion.title)
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::Desktop)
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Message {
|
||||
// panel messages
|
||||
AutoHidePanel(bool),
|
||||
PanelAnchor(PanelAnchor),
|
||||
Output(CosmicPanelOuput),
|
||||
AnchorGap(bool),
|
||||
PanelSize(PanelSize),
|
||||
Appearance,
|
||||
ExtendToEdge(bool),
|
||||
Opacity(f64),
|
||||
Applets,
|
||||
}
|
||||
|
||||
impl Page {
|
||||
pub fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::AutoHidePanel(enabled) => {
|
||||
self.panel_config.autohide = enabled.then_some(AutoHide {
|
||||
wait_time: 1000,
|
||||
transition_time: 200,
|
||||
handle_size: 4,
|
||||
});
|
||||
}
|
||||
Message::PanelAnchor(_) => todo!(),
|
||||
Message::Output(_) => todo!(),
|
||||
Message::AnchorGap(_) => todo!(),
|
||||
Message::PanelSize(_) => todo!(),
|
||||
Message::Appearance => todo!(),
|
||||
Message::ExtendToEdge(_) => todo!(),
|
||||
Message::Opacity(_) => todo!(),
|
||||
Message::Applets => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ pub enum Message {
|
|||
About(system::about::Message),
|
||||
DateAndTime(time::date::Message),
|
||||
Desktop(desktop::Message),
|
||||
Panel(desktop::panel::Message),
|
||||
External { id: String, message: Vec<u8> },
|
||||
Page(Entity),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,10 +45,18 @@ window-controls = Window Controls
|
|||
|
||||
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: Panel
|
||||
panel = Panel
|
||||
.desc = Top bar with desktop controls and menus.
|
||||
|
||||
panel-behavior-and-position = Behavior and Positions
|
||||
.autohide = Automatically hide panel
|
||||
.position = Position on screen
|
||||
.display = Show on display
|
||||
## Desktop: Wallpaper
|
||||
|
||||
wallpaper = Wallpaper
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue