Skip to content

Commit

Permalink
feat: add Region & Language page
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick authored Nov 11, 2024
1 parent 42a3061 commit 8a20cbc
Show file tree
Hide file tree
Showing 19 changed files with 1,211 additions and 189 deletions.
323 changes: 189 additions & 134 deletions Cargo.lock

Large diffs are not rendered by default.

35 changes: 25 additions & 10 deletions cosmic-settings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ license = "GPL-3.0-only"
[dependencies]
anyhow = "1.0"
as-result = "0.2.1"
ashpd = { version = "0.9", default-features = false, features = ["tokio"], optional = true }
ashpd = { version = "0.9", default-features = false, features = [
"tokio",
], optional = true }
async-channel = "2.3.1"
chrono = "0.4.38"
clap = { version = "4.5.17", features = ["derive"] }
Expand Down Expand Up @@ -39,6 +41,7 @@ indexmap = "2.5.0"
itertools = "0.13.0"
itoa = "1.0.11"
libcosmic.workspace = true
locale1 = { git = "https://github.com/pop-os/dbus-settings-bindings", optional = true }
notify = "6.1.1"
once_cell = "1.19.0"
regex = "1.10.6"
Expand All @@ -63,6 +66,7 @@ xkb-data = "0.2.1"
zbus = { version = "4.4.0", features = ["tokio"], optional = true }
ustr = "1.0.0"
fontdb = "0.16.2"
fixed_decimal = "0.5.6"

[dependencies.cosmic-settings-subscriptions]
git = "https://github.com/pop-os/cosmic-settings-subscriptions"
Expand All @@ -78,14 +82,14 @@ features = ["experimental", "compiled_data", "icu_datetime_experimental"]
version = "0.15.0"
features = ["fluent-system", "desktop-requester"]

# Contains region-handling logic for Linux
[dependencies.lichen-system]
git = "https://github.com/serpent-os/lichen"
package = "system"
optional = true

[features]
default = [
"a11y",
"dbus-config",
"linux",
"single-instance",
"wgpu",
]
default = ["a11y", "dbus-config", "linux", "single-instance", "wgpu"]

# Default features for Linux
linux = [
Expand All @@ -95,6 +99,7 @@ linux = [
"page-input",
"page-networking",
"page-power",
"page-region",
"page-sound",
"page-window-management",
"page-workspaces",
Expand All @@ -106,9 +111,19 @@ linux = [
page-about = ["dep:cosmic-settings-system", "dep:hostname1-zbus", "dep:zbus"]
page-bluetooth = ["dep:bluez-zbus", "dep:zbus"]
page-date = ["dep:timedate-zbus", "dep:zbus"]
page-input = ["dep:cosmic-comp-config", "dep:cosmic-settings-config", "dep:udev"]
page-networking = ["ashpd", "dep:cosmic-dbus-networkmanager", "dep:cosmic-settings-subscriptions", "dep:zbus"]
page-input = [
"dep:cosmic-comp-config",
"dep:cosmic-settings-config",
"dep:udev",
]
page-networking = [
"ashpd",
"dep:cosmic-dbus-networkmanager",
"dep:cosmic-settings-subscriptions",
"dep:zbus",
]
page-power = ["dep:upower_dbus", "dep:zbus"]
page-region = ["dep:lichen-system", "dep:locale1"]
page-sound = ["dep:cosmic-settings-subscriptions"]
page-window-management = ["dep:cosmic-settings-config"]
page-workspaces = ["dep:cosmic-comp-config"]
Expand Down
8 changes: 8 additions & 0 deletions cosmic-settings/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl SettingsApp {
PageCommands::Panel => self.pages.page_id::<desktop::panel::Page>(),
#[cfg(feature = "page-power")]
PageCommands::Power => self.pages.page_id::<power::Page>(),
#[cfg(feature = "page-region")]
PageCommands::RegionLanguage => self.pages.page_id::<time::region::Page>(),
#[cfg(feature = "page-sound")]
PageCommands::Sound => self.pages.page_id::<sound::Page>(),
Expand Down Expand Up @@ -480,6 +481,13 @@ impl cosmic::Application for SettingsApp {
}
}

#[cfg(feature = "page-region")]
crate::pages::Message::Region(message) => {
if let Some(page) = self.pages.page_mut::<time::region::Page>() {
return page.update(message).map(Into::into);
}
}

#[cfg(feature = "page-sound")]
crate::pages::Message::Sound(message) => {
if let Some(page) = self.pages.page_mut::<sound::Page>() {
Expand Down
3 changes: 2 additions & 1 deletion cosmic-settings/src/pages/bluetooth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ impl page::Page<crate::pages::Message> for Page {
let cancel_button =
widget::button::standard(fl!("cancel")).on_press(Message::PinCancel);

let dialog = widget::dialog(fl!("bluetooth-confirm-pin"))
let dialog = widget::dialog()
.title(fl!("bluetooth-confirm-pin"))
.control(control)
.primary_action(confirm_button)
.secondary_action(cancel_button)
Expand Down
2 changes: 1 addition & 1 deletion cosmic-settings/src/pages/desktop/appearance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use cosmic::widget::{
button, color_picker::ColorPickerUpdate, container, flex_row, horizontal_space, radio, row,
scrollable, settings, spin_button, text, ColorPickerModel,
};
use cosmic::{Apply, Element, Task};
use cosmic::{widget, Apply, Element, Task};
#[cfg(feature = "wayland")]
use cosmic_panel_config::CosmicPanelConfig;
use cosmic_settings_page::Section;
Expand Down
22 changes: 11 additions & 11 deletions cosmic-settings/src/pages/desktop/panel/applets_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,17 @@ impl Page {
);
}

column::with_children(vec![
text_input::search_input(fl!("search-applets"), &self.search)
.on_input(move |s| msg_map(Message::Search(s)))
.on_paste(move |s| msg_map(Message::Search(s)))
.width(Length::Fixed(312.0))
.into(),
list_column.into(),
])
.align_x(Alignment::Center)
.spacing(space_xxs)
.into()
let search = text_input::search_input(fl!("search-applets"), &self.search)
.on_input(move |s| msg_map(Message::Search(s)))
.on_paste(move |s| msg_map(Message::Search(s)))
.width(Length::Fixed(312.0));

column::with_capacity(2)
.push(search)
.push(list_column)
.align_x(Alignment::Center)
.spacing(space_xxs)
.into()
}

#[allow(clippy::too_many_lines)]
Expand Down
3 changes: 2 additions & 1 deletion cosmic-settings/src/pages/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ impl page::Page<crate::pages::Message> for Page {
/// Task.
fn dialog(&self) -> Option<Element<pages::Message>> {
self.dialog?;
let element = widget::dialog(fl!("dialog", "title"))
let element = widget::dialog()
.title(fl!("dialog", "title"))
.body(fl!("dialog", "change-prompt", time = self.dialog_countdown))
.primary_action(
widget::button::suggested(fl!("dialog", "keep-changes"))
Expand Down
2 changes: 1 addition & 1 deletion cosmic-settings/src/pages/input/keyboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fn input_source(
) -> cosmic::Element<Message> {
let expanded = expanded_source_popover.is_some_and(|expanded_id| expanded_id == id);

settings::flex_item(description, popover_button(id, expanded)).into()
settings::item(description, popover_button(id, expanded)).into()
}

fn special_char_radio_row<'a>(
Expand Down
5 changes: 3 additions & 2 deletions cosmic-settings/src/pages/input/keyboard/shortcuts/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ impl Model {
let secondary_action = button::standard(fl!("cancel"))
.on_press(ShortcutMessage::CancelReplace);

let dialog = widget::dialog(fl!("replace-shortcut-dialog"))
let dialog = widget::dialog()
.title(fl!("replace-shortcut-dialog"))
.icon(icon::from_name("dialog-warning").size(64))
.body(fl!(
"replace-shortcut-dialog",
Expand Down Expand Up @@ -521,7 +522,7 @@ fn context_drawer(
.into();

let flex_control =
settings::flex_item_row(vec![input, delete_button]).align_items(Alignment::Center);
settings::item_row(vec![input, delete_button]).align_y(Alignment::Center);

section.add(flex_control)
},
Expand Down
3 changes: 2 additions & 1 deletion cosmic-settings/src/pages/input/keyboard/shortcuts/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ impl page::Page<crate::pages::Message> for Page {

let secondary_action = button::standard(fl!("cancel")).on_press(Message::ReplaceCancel);

let dialog = widget::dialog(fl!("replace-shortcut-dialog"))
let dialog = widget::dialog()
.title(fl!("replace-shortcut-dialog"))
.icon(icon::from_name("dialog-warning").size(64))
.body(fl!(
"replace-shortcut-dialog",
Expand Down
2 changes: 2 additions & 0 deletions cosmic-settings/src/pages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ pub enum Message {
PanelApplet(desktop::panel::applets_inner::Message),
#[cfg(feature = "page-power")]
Power(power::Message),
#[cfg(feature = "page-region")]
Region(time::region::Message),
#[cfg(feature = "page-sound")]
Sound(sound::Message),
#[cfg(feature = "page-input")]
Expand Down
12 changes: 8 additions & 4 deletions cosmic-settings/src/pages/networking/vpn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ impl page::Page<crate::pages::Message> for Page {
let primary_action =
widget::button::standard(fl!("ok")).on_press(Message::CancelDialog);

widget::dialog(fl!("vpn-error"))
widget::dialog()
.title(fl!("vpn-error"))
.icon(icon::from_name("dialog-error-symbolic").size(64))
.body(error_kind.localized())
.control(reason)
Expand Down Expand Up @@ -268,7 +269,8 @@ impl page::Page<crate::pages::Message> for Page {
let secondary_action =
widget::button::standard(fl!("cancel")).on_press(Message::CancelDialog);

widget::dialog(fl!("auth-dialog"))
widget::dialog()
.title(fl!("auth-dialog"))
.icon(icon::from_name("network-vpn-symbolic").size(64))
.body(fl!("auth-dialog", "vpn-description"))
.control(controls)
Expand All @@ -289,7 +291,8 @@ impl page::Page<crate::pages::Message> for Page {
let secondary_action =
widget::button::standard(fl!("cancel")).on_press(Message::CancelDialog);

widget::dialog(fl!("wireguard-dialog"))
widget::dialog()
.title(fl!("wireguard-dialog"))
.icon(icon::from_name("network-vpn-symbolic").size(64))
.body(fl!("wireguard-dialog", "description"))
.control(input)
Expand All @@ -306,7 +309,8 @@ impl page::Page<crate::pages::Message> for Page {
let secondary_action =
widget::button::standard(fl!("cancel")).on_press(Message::CancelDialog);

widget::dialog(fl!("remove-connection-dialog"))
widget::dialog()
.title(fl!("remove-connection-dialog"))
.icon(icon::from_name("dialog-information").size(64))
.body(fl!("remove-connection-dialog", "vpn-description"))
.primary_action(primary_action)
Expand Down
6 changes: 4 additions & 2 deletions cosmic-settings/src/pages/networking/wifi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ impl page::Page<crate::pages::Message> for Page {
let secondary_action =
widget::button::standard(fl!("cancel")).on_press(Message::CancelDialog);

widget::dialog(fl!("auth-dialog"))
widget::dialog()
.title(fl!("auth-dialog"))
.icon(icon::from_name("preferences-wireless-symbolic").size(64))
.body(fl!("auth-dialog", "wifi-description"))
.control(password)
Expand All @@ -175,7 +176,8 @@ impl page::Page<crate::pages::Message> for Page {
let secondary_action =
widget::button::standard(fl!("cancel")).on_press(Message::CancelDialog);

widget::dialog(fl!("forget-dialog"))
widget::dialog()
.title(fl!("forget-dialog"))
.icon(icon::from_name("dialog-information").size(64))
.body(fl!("forget-dialog", "description"))
.primary_action(primary_action)
Expand Down
3 changes: 2 additions & 1 deletion cosmic-settings/src/pages/networking/wired.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ impl page::Page<crate::pages::Message> for Page {
let secondary_action =
widget::button::standard(fl!("cancel")).on_press(Message::CancelDialog);

widget::dialog(fl!("remove-connection-dialog"))
widget::dialog()
.title(fl!("remove-connection-dialog"))
.icon(icon::from_name("dialog-information").size(64))
.body(fl!("remove-connection-dialog", "wired-description"))
.primary_action(primary_action)
Expand Down
7 changes: 6 additions & 1 deletion cosmic-settings/src/pages/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ impl page::AutoBind<crate::pages::Message> for Page {
{
page = page.sub_page::<date::Page>();
}
page = page.sub_page::<region::Page>();

#[cfg(feature = "page-region")]
{
page = page.sub_page::<region::Page>();
}

page
}
}
Loading

0 comments on commit 8a20cbc

Please sign in to comment.