Skip to content

Commit 74ec4ca

Browse files
committed
pages: Add Accessibility/Magnifier page
1 parent 7696ce6 commit 74ec4ca

13 files changed

+773
-1
lines changed

Cargo.lock

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cosmic-settings/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ cosmic-config.workspace = true
2121
cosmic-dbus-networkmanager = { git = "https://github.com/pop-os/dbus-settings-bindings", optional = true }
2222
cosmic-idle-config.workspace = true
2323
cosmic-panel-config = { workspace = true, optional = true }
24+
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", optional = true }
2425
cosmic-randr-shell.workspace = true
2526
cosmic-randr = { workspace = true, optional = true }
2627
cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon", optional = true }
@@ -55,6 +56,7 @@ once_cell = "1.20.3"
5556
regex = "1.11.1"
5657
ron = "0.8"
5758
rust-embed = "8.5.0"
59+
sctk = { workspace = true, optional = true }
5860
secure-string = "0.3.0"
5961
serde = { version = "1.0.217", features = ["derive"] }
6062
slab = "0.4.9"
@@ -110,6 +112,7 @@ gettext = ["dep:gettext-rs"]
110112

111113
# Default features for Linux
112114
linux = [
115+
"page-accessibility",
113116
"page-about",
114117
"page-bluetooth",
115118
"page-date",
@@ -127,6 +130,7 @@ linux = [
127130
]
128131

129132
# Pages
133+
page-accessibility = ["dep:cosmic-protocols", "dep:sctk"]
130134
page-about = ["dep:cosmic-settings-system", "dep:hostname1-zbus", "dep:zbus"]
131135
page-bluetooth = ["dep:bluez-zbus", "dep:zbus", "dep:cosmic-settings-subscriptions"]
132136
page-date = ["dep:timedate-zbus", "dep:zbus"]

cosmic-settings/src/app.rs

+22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// SPDX-License-Identifier: GPL-3.0-only
33

44
use crate::config::Config;
5+
#[cfg(feature = "page-accessibility")]
6+
use crate::pages::accessibility;
57
#[cfg(feature = "page-bluetooth")]
68
use crate::pages::bluetooth;
79
use crate::pages::desktop::{self, appearance};
@@ -74,6 +76,12 @@ pub struct SettingsApp {
7476
impl SettingsApp {
7577
fn subtask_to_page(&self, cmd: &PageCommands) -> Option<Entity> {
7678
match cmd {
79+
#[cfg(feature = "page-accessibility")]
80+
PageCommands::Accessibility => self.pages.page_id::<accessibility::Page>(),
81+
#[cfg(feature = "page-accessibility")]
82+
PageCommands::AccessibilityMagnifier => {
83+
self.pages.page_id::<accessibility::magnifier::Page>()
84+
}
7785
#[cfg(feature = "page-about")]
7886
PageCommands::About => self.pages.page_id::<system::about::Page>(),
7987
PageCommands::Appearance => self.pages.page_id::<desktop::appearance::Page>(),
@@ -194,6 +202,8 @@ impl cosmic::Application for SettingsApp {
194202
app.insert_page::<networking::Page>();
195203
#[cfg(feature = "page-bluetooth")]
196204
app.insert_page::<bluetooth::Page>();
205+
#[cfg(feature = "page-accessibility")]
206+
app.insert_page::<accessibility::Page>();
197207
let desktop_id = app.insert_page::<desktop::Page>().id();
198208
app.insert_page::<display::Page>();
199209
#[cfg(feature = "page-sound")]
@@ -368,6 +378,18 @@ impl cosmic::Application for SettingsApp {
368378
}
369379

370380
Message::PageMessage(message) => match message {
381+
#[cfg(feature = "page-accessibility")]
382+
crate::pages::Message::Accessibility(message) => {
383+
if let Some(page) = self.pages.page_mut::<accessibility::Page>() {
384+
return page.update(message).map(Into::into);
385+
}
386+
}
387+
#[cfg(feature = "page-accessibility")]
388+
crate::pages::Message::AccessibilityMagnifier(message) => {
389+
if let Some(page) = self.pages.page_mut::<accessibility::magnifier::Page>() {
390+
return page.update(self.active_page, message).map(Into::into);
391+
}
392+
}
371393
#[cfg(feature = "page-about")]
372394
crate::pages::Message::About(message) => {
373395
page::update!(self.pages, message, system::about::Page);

cosmic-settings/src/main.rs

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ pub struct Args {
3838

3939
#[derive(Subcommand, Debug, Serialize, Deserialize, Clone)]
4040
pub enum PageCommands {
41+
/// Accessibility settings page
42+
#[cfg(feature = "page-accessibility")]
43+
Accessibility,
44+
/// Accessibility Magnifier settings page
45+
#[cfg(feature = "page-accessibility")]
46+
AccessibilityMagnifier,
4147
/// About settings page
4248
#[cfg(feature = "page-about")]
4349
About,

0 commit comments

Comments
 (0)