feat: add applications page
This commit is contained in:
parent
5f8e9d1327
commit
cc8586e380
15 changed files with 274 additions and 120 deletions
|
|
@ -4,6 +4,7 @@
|
|||
use crate::config::Config;
|
||||
#[cfg(feature = "page-accessibility")]
|
||||
use crate::pages::accessibility;
|
||||
use crate::pages::applications;
|
||||
#[cfg(feature = "page-bluetooth")]
|
||||
use crate::pages::bluetooth;
|
||||
use crate::pages::desktop::{self, appearance};
|
||||
|
|
@ -84,12 +85,13 @@ impl SettingsApp {
|
|||
#[cfg(feature = "page-about")]
|
||||
PageCommands::About => self.pages.page_id::<system::about::Page>(),
|
||||
PageCommands::Appearance => self.pages.page_id::<desktop::appearance::Page>(),
|
||||
PageCommands::Applications => self.pages.page_id::<applications::Page>(),
|
||||
#[cfg(feature = "page-bluetooth")]
|
||||
PageCommands::Bluetooth => self.pages.page_id::<bluetooth::Page>(),
|
||||
#[cfg(feature = "page-date")]
|
||||
PageCommands::DateTime => self.pages.page_id::<time::date::Page>(),
|
||||
#[cfg(feature = "page-default-apps")]
|
||||
PageCommands::DefaultApps => self.pages.page_id::<system::default_apps::Page>(),
|
||||
PageCommands::DefaultApps => self.pages.page_id::<applications::default_apps::Page>(),
|
||||
PageCommands::Desktop => self.pages.page_id::<desktop::Page>(),
|
||||
#[cfg(feature = "page-display")]
|
||||
PageCommands::Displays => self.pages.page_id::<display::Page>(),
|
||||
|
|
@ -100,6 +102,9 @@ impl SettingsApp {
|
|||
PageCommands::Input => self.pages.page_id::<input::Page>(),
|
||||
#[cfg(feature = "page-input")]
|
||||
PageCommands::Keyboard => self.pages.page_id::<input::keyboard::Page>(),
|
||||
PageCommands::LegacyApplications => self
|
||||
.pages
|
||||
.page_id::<applications::legacy_applications::Page>(),
|
||||
#[cfg(feature = "page-input")]
|
||||
PageCommands::Mouse => self.pages.page_id::<input::mouse::Page>(),
|
||||
#[cfg(feature = "page-networking")]
|
||||
|
|
@ -214,6 +219,7 @@ impl cosmic::Application for SettingsApp {
|
|||
app.insert_page::<power::Page>();
|
||||
#[cfg(feature = "page-input")]
|
||||
app.insert_page::<input::Page>();
|
||||
app.insert_page::<applications::Page>();
|
||||
app.insert_page::<time::Page>();
|
||||
app.insert_page::<system::Page>();
|
||||
|
||||
|
|
@ -390,6 +396,10 @@ impl cosmic::Application for SettingsApp {
|
|||
}
|
||||
}
|
||||
|
||||
crate::pages::Message::Applications(message) => {
|
||||
page::update!(self.pages, message, applications::Page);
|
||||
}
|
||||
|
||||
#[cfg(feature = "page-bluetooth")]
|
||||
crate::pages::Message::Bluetooth(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<bluetooth::Page>() {
|
||||
|
|
@ -406,7 +416,7 @@ impl cosmic::Application for SettingsApp {
|
|||
|
||||
#[cfg(feature = "page-default-apps")]
|
||||
crate::pages::Message::DefaultApps(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<system::default_apps::Page>() {
|
||||
if let Some(page) = self.pages.page_mut::<applications::default_apps::Page>() {
|
||||
return page.update(message).map(Into::into);
|
||||
}
|
||||
}
|
||||
|
|
@ -478,6 +488,10 @@ impl cosmic::Application for SettingsApp {
|
|||
}
|
||||
}
|
||||
|
||||
crate::pages::Message::LegacyApplications(message) => {
|
||||
page::update!(self.pages, message, applications::legacy_applications::Page);
|
||||
}
|
||||
|
||||
#[cfg(feature = "page-input")]
|
||||
crate::pages::Message::ManageWindowShortcuts(message) => {
|
||||
if let Some(page) = self
|
||||
|
|
@ -614,7 +628,7 @@ impl cosmic::Application for SettingsApp {
|
|||
}
|
||||
|
||||
crate::pages::Message::StartupApps(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<system::startup_apps::Page>() {
|
||||
if let Some(page) = self.pages.page_mut::<applications::startup_apps::Page>() {
|
||||
return page.update(message).map(Into::into);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ pub enum PageCommands {
|
|||
About,
|
||||
/// Appearance settings page
|
||||
Appearance,
|
||||
/// Applications settings page
|
||||
Applications,
|
||||
/// Bluetooth settings page
|
||||
#[cfg(feature = "page-bluetooth")]
|
||||
Bluetooth,
|
||||
|
|
@ -74,6 +76,8 @@ pub enum PageCommands {
|
|||
/// Keyboard settings page
|
||||
#[cfg(feature = "page-input")]
|
||||
Keyboard,
|
||||
/// Legacy Applications settings page
|
||||
LegacyApplications,
|
||||
/// Mouse settings page
|
||||
#[cfg(feature = "page-input")]
|
||||
Mouse,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use cosmic::{
|
||||
app,
|
||||
cosmic_theme::{CosmicPalette, ThemeBuilder},
|
||||
iced_core::text::Wrapping,
|
||||
theme::{self, CosmicTheme},
|
||||
|
|
|
|||
121
cosmic-settings/src/pages/applications/legacy_applications.rs
Normal file
121
cosmic-settings/src/pages/applications/legacy_applications.rs
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
// Copyright 2023 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use cosmic::{
|
||||
cosmic_config::{self, ConfigGet, ConfigSet},
|
||||
iced::Length,
|
||||
widget::{self, text},
|
||||
Apply, Element,
|
||||
};
|
||||
use cosmic_settings_page::Section;
|
||||
use cosmic_settings_page::{self as page, section};
|
||||
use slab::Slab;
|
||||
use slotmap::SlotMap;
|
||||
use tracing::error;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Message {
|
||||
SetXwaylandDescaling(bool),
|
||||
}
|
||||
|
||||
pub struct Page {
|
||||
comp_config: cosmic_config::Config,
|
||||
comp_config_descale_xwayland: bool,
|
||||
}
|
||||
|
||||
impl Default for Page {
|
||||
fn default() -> Self {
|
||||
let comp_config = cosmic_config::Config::new("com.system76.CosmicComp", 1).unwrap();
|
||||
let comp_config_descale_xwayland =
|
||||
comp_config.get("descale_xwayland").unwrap_or_else(|err| {
|
||||
if err.is_err() {
|
||||
error!(?err, "Failed to read config 'descale_xwayland'");
|
||||
}
|
||||
|
||||
false
|
||||
});
|
||||
Self {
|
||||
comp_config,
|
||||
comp_config_descale_xwayland,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl page::Page<crate::pages::Message> for Page {
|
||||
fn content(
|
||||
&self,
|
||||
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
|
||||
) -> Option<page::Content> {
|
||||
Some(vec![sections.insert(
|
||||
// Xwayland scaling options
|
||||
legacy_application_scaling(),
|
||||
)])
|
||||
}
|
||||
|
||||
fn info(&self) -> page::Info {
|
||||
page::Info::new(
|
||||
"legacy-applications",
|
||||
"preferences-X11-applications-symbolic",
|
||||
)
|
||||
.title(fl!("legacy-applications"))
|
||||
.description(fl!("legacy-applications", "desc"))
|
||||
}
|
||||
}
|
||||
|
||||
impl page::AutoBind<crate::pages::Message> for Page {}
|
||||
|
||||
impl Page {
|
||||
pub fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::SetXwaylandDescaling(descale) => {
|
||||
self.comp_config_descale_xwayland = descale;
|
||||
if let Err(err) = self
|
||||
.comp_config
|
||||
.set("descale_xwayland", self.comp_config_descale_xwayland)
|
||||
{
|
||||
error!(?err, "Failed to set config 'descale_xwayland'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn legacy_application_scaling() -> Section<crate::pages::Message> {
|
||||
let mut descriptions = Slab::new();
|
||||
|
||||
let system = descriptions.insert(fl!("legacy-app-scaling", "scaled-by-system"));
|
||||
let system_desc = descriptions.insert(fl!("legacy-app-scaling", "system-description"));
|
||||
let native = descriptions.insert(fl!("legacy-app-scaling", "scaled-natively"));
|
||||
let native_desc = descriptions.insert(fl!("legacy-app-scaling", "native-description"));
|
||||
|
||||
Section::default()
|
||||
.title(fl!("legacy-app-scaling"))
|
||||
.descriptions(descriptions)
|
||||
.view::<Page>(move |_binder, page, section| {
|
||||
let descriptions = §ion.descriptions;
|
||||
widget::settings::section()
|
||||
.title(§ion.title)
|
||||
.add(widget::settings::item_row(vec![widget::radio(
|
||||
widget::column()
|
||||
.push(text::body(&descriptions[system]))
|
||||
.push(text::caption(&descriptions[system_desc])),
|
||||
false,
|
||||
Some(page.comp_config_descale_xwayland),
|
||||
Message::SetXwaylandDescaling,
|
||||
)
|
||||
.width(Length::Fill)
|
||||
.into()]))
|
||||
.add(widget::settings::item_row(vec![widget::radio(
|
||||
widget::column()
|
||||
.push(text::body(&descriptions[native]))
|
||||
.push(text::caption(&descriptions[native_desc])),
|
||||
true,
|
||||
Some(page.comp_config_descale_xwayland),
|
||||
Message::SetXwaylandDescaling,
|
||||
)
|
||||
.width(Length::Fill)
|
||||
.into()]))
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::LegacyApplications)
|
||||
})
|
||||
}
|
||||
51
cosmic-settings/src/pages/applications/mod.rs
Normal file
51
cosmic-settings/src/pages/applications/mod.rs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright 2023 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#[cfg(feature = "page-default-apps")]
|
||||
pub mod default_apps;
|
||||
|
||||
pub mod startup_apps;
|
||||
|
||||
pub mod legacy_applications;
|
||||
|
||||
use cosmic_settings_page as page;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Page {
|
||||
entity: page::Entity,
|
||||
}
|
||||
|
||||
impl page::Page<crate::pages::Message> for Page {
|
||||
fn set_id(&mut self, entity: page::Entity) {
|
||||
self.entity = entity;
|
||||
}
|
||||
|
||||
fn info(&self) -> page::Info {
|
||||
page::Info::new("applications", "preferences-applications-symbolic")
|
||||
.title(fl!("applications"))
|
||||
}
|
||||
}
|
||||
|
||||
impl page::AutoBind<crate::pages::Message> for Page {
|
||||
fn sub_pages(
|
||||
mut page: page::Insert<crate::pages::Message>,
|
||||
) -> page::Insert<crate::pages::Message> {
|
||||
#[cfg(feature = "page-default-apps")]
|
||||
{
|
||||
page = page.sub_page::<default_apps::Page>();
|
||||
}
|
||||
|
||||
page = page.sub_page::<startup_apps::Page>();
|
||||
|
||||
page = page.sub_page::<legacy_applications::Page>();
|
||||
|
||||
page
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum Message {}
|
||||
|
||||
impl Page {
|
||||
pub fn update(&mut self, _message: Message) {}
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ impl page::AutoBind<crate::pages::Message> for Page {}
|
|||
|
||||
impl page::Page<crate::pages::Message> for Page {
|
||||
fn info(&self) -> Info {
|
||||
page::Info::new("startup-apps", "preferences-default-applications-symbolic")
|
||||
page::Info::new("startup-apps", "system-reboot-symbolic")
|
||||
.title(fl!("startup-apps"))
|
||||
.description(fl!("startup-apps", "desc"))
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ use cosmic::widget::{
|
|||
self, column, container, dropdown, list_column, segmented_button, tab_bar, text, toggler,
|
||||
};
|
||||
use cosmic::{surface, Apply, Element, Task};
|
||||
use cosmic_config::{ConfigGet, ConfigSet};
|
||||
use cosmic_randr_shell::{
|
||||
AdaptiveSyncAvailability, AdaptiveSyncState, List, Output, OutputKey, Transform,
|
||||
};
|
||||
|
|
@ -23,7 +22,6 @@ use slotmap::{Key, SecondaryMap, SlotMap};
|
|||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::{collections::BTreeMap, process::ExitStatus, sync::Arc};
|
||||
use tokio::sync::oneshot;
|
||||
use tracing::error;
|
||||
|
||||
static DPI_SCALES: &[u32] = &[50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300];
|
||||
|
||||
|
|
@ -107,7 +105,6 @@ pub enum Message {
|
|||
/// Available outputs from cosmic-randr.
|
||||
randr: Arc<Result<List, cosmic_randr_shell::Error>>,
|
||||
},
|
||||
SetXwaylandDescaling(bool),
|
||||
Surface(surface::Action),
|
||||
}
|
||||
|
||||
|
|
@ -152,23 +149,11 @@ pub struct Page {
|
|||
/// the instant the setting was changed.
|
||||
dialog_countdown: usize,
|
||||
show_display_options: bool,
|
||||
comp_config: cosmic_config::Config,
|
||||
comp_config_descale_xwayland: bool,
|
||||
adjusted_scale: u32,
|
||||
}
|
||||
|
||||
impl Default for Page {
|
||||
fn default() -> Self {
|
||||
let comp_config = cosmic_config::Config::new("com.system76.CosmicComp", 1).unwrap();
|
||||
let comp_config_descale_xwayland =
|
||||
comp_config.get("descale_xwayland").unwrap_or_else(|err| {
|
||||
if err.is_err() {
|
||||
error!(?err, "Failed to read config 'descale_xwayland'");
|
||||
}
|
||||
|
||||
false
|
||||
});
|
||||
|
||||
Self {
|
||||
refreshing_page: Arc::new(AtomicBool::new(false)),
|
||||
list: List::default(),
|
||||
|
|
@ -187,8 +172,6 @@ impl Default for Page {
|
|||
dialog_countdown: 0,
|
||||
show_display_options: true,
|
||||
adjusted_scale: 0,
|
||||
comp_config,
|
||||
comp_config_descale_xwayland,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -240,8 +223,6 @@ impl page::Page<crate::pages::Message> for Page {
|
|||
sections.insert(display_arrangement()),
|
||||
// Display configuration
|
||||
sections.insert(display_configuration()),
|
||||
// Xwayland scaling options
|
||||
sections.insert(legacy_applications()),
|
||||
])
|
||||
}
|
||||
|
||||
|
|
@ -618,16 +599,6 @@ impl Page {
|
|||
self.refreshing_page.store(false, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
Message::SetXwaylandDescaling(descale) => {
|
||||
self.comp_config_descale_xwayland = descale;
|
||||
if let Err(err) = self
|
||||
.comp_config
|
||||
.set("descale_xwayland", self.comp_config_descale_xwayland)
|
||||
{
|
||||
error!(?err, "Failed to set config 'descale_xwayland'");
|
||||
}
|
||||
}
|
||||
|
||||
Message::Surface(a) => {
|
||||
return cosmic::task::message(crate::app::Message::Surface(a));
|
||||
}
|
||||
|
|
@ -1378,46 +1349,6 @@ pub fn display_configuration() -> Section<crate::pages::Message> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn legacy_applications() -> Section<crate::pages::Message> {
|
||||
let mut descriptions = Slab::new();
|
||||
|
||||
let system = descriptions.insert(fl!("legacy-applications", "scaled-by-system"));
|
||||
let system_desc = descriptions.insert(fl!("legacy-applications", "system-description"));
|
||||
let native = descriptions.insert(fl!("legacy-applications", "scaled-natively"));
|
||||
let native_desc = descriptions.insert(fl!("legacy-applications", "native-description"));
|
||||
|
||||
Section::default()
|
||||
.title(fl!("legacy-applications"))
|
||||
.descriptions(descriptions)
|
||||
.view::<Page>(move |_binder, page, section| {
|
||||
let descriptions = §ion.descriptions;
|
||||
widget::settings::section()
|
||||
.title(§ion.title)
|
||||
.add(widget::settings::item_row(vec![widget::radio(
|
||||
widget::column()
|
||||
.push(text::body(&descriptions[system]))
|
||||
.push(text::caption(&descriptions[system_desc])),
|
||||
false,
|
||||
Some(page.comp_config_descale_xwayland),
|
||||
Message::SetXwaylandDescaling,
|
||||
)
|
||||
.width(Length::Fill)
|
||||
.into()]))
|
||||
.add(widget::settings::item_row(vec![widget::radio(
|
||||
widget::column()
|
||||
.push(text::body(&descriptions[native]))
|
||||
.push(text::caption(&descriptions[native_desc])),
|
||||
true,
|
||||
Some(page.comp_config_descale_xwayland),
|
||||
Message::SetXwaylandDescaling,
|
||||
)
|
||||
.width(Length::Fill)
|
||||
.into()]))
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::Displays)
|
||||
})
|
||||
}
|
||||
|
||||
fn cache_rates(cached_rates: &mut Vec<String>, rates: &[u32]) {
|
||||
cached_rates.clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use cosmic_settings_page::Entity;
|
|||
|
||||
#[cfg(feature = "page-accessibility")]
|
||||
pub mod accessibility;
|
||||
pub mod applications;
|
||||
#[cfg(feature = "page-bluetooth")]
|
||||
pub mod bluetooth;
|
||||
pub mod desktop;
|
||||
|
|
@ -30,6 +31,7 @@ pub enum Message {
|
|||
#[cfg(feature = "page-about")]
|
||||
About(system::about::Message),
|
||||
Appearance(desktop::appearance::Message),
|
||||
Applications(applications::Message),
|
||||
#[cfg(feature = "page-bluetooth")]
|
||||
Bluetooth(bluetooth::Message),
|
||||
#[cfg(feature = "page-input")]
|
||||
|
|
@ -37,7 +39,7 @@ pub enum Message {
|
|||
#[cfg(feature = "page-date")]
|
||||
DateAndTime(time::date::Message),
|
||||
#[cfg(feature = "page-default-apps")]
|
||||
DefaultApps(system::default_apps::Message),
|
||||
DefaultApps(applications::default_apps::Message),
|
||||
Desktop(desktop::Message),
|
||||
DesktopWallpaper(desktop::wallpaper::Message),
|
||||
#[cfg(feature = "page-workspaces")]
|
||||
|
|
@ -58,6 +60,7 @@ pub enum Message {
|
|||
Keyboard(input::keyboard::Message),
|
||||
#[cfg(feature = "page-input")]
|
||||
KeyboardShortcuts(input::keyboard::shortcuts::Message),
|
||||
LegacyApplications(applications::legacy_applications::Message),
|
||||
#[cfg(feature = "page-input")]
|
||||
ManageWindowShortcuts(input::keyboard::shortcuts::ShortcutMessage),
|
||||
#[cfg(feature = "page-input")]
|
||||
|
|
@ -77,7 +80,7 @@ pub enum Message {
|
|||
Region(time::region::Message),
|
||||
#[cfg(feature = "page-sound")]
|
||||
Sound(sound::Message),
|
||||
StartupApps(system::startup_apps::Message),
|
||||
StartupApps(applications::startup_apps::Message),
|
||||
#[cfg(feature = "page-users")]
|
||||
User(system::users::Message),
|
||||
#[cfg(feature = "page-input")]
|
||||
|
|
|
|||
|
|
@ -3,14 +3,11 @@
|
|||
|
||||
#[cfg(feature = "page-about")]
|
||||
pub mod about;
|
||||
#[cfg(feature = "page-default-apps")]
|
||||
pub mod default_apps;
|
||||
|
||||
pub mod firmware;
|
||||
#[cfg(feature = "page-users")]
|
||||
pub mod users;
|
||||
|
||||
pub mod startup_apps;
|
||||
|
||||
use cosmic_settings_page as page;
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -44,13 +41,6 @@ impl page::AutoBind<crate::pages::Message> for Page {
|
|||
|
||||
page = page.sub_page::<firmware::Page>();
|
||||
|
||||
#[cfg(feature = "page-default-apps")]
|
||||
{
|
||||
page = page.sub_page::<default_apps::Page>();
|
||||
}
|
||||
|
||||
page = page.sub_page::<startup_apps::Page>();
|
||||
|
||||
page
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue