Added "action on typing" setting to workspaces settings page.
Added language information for action on typing for: English, German, Spanish, Swedish
This commit is contained in:
parent
ceed2b9ac1
commit
46090ae210
7 changed files with 107 additions and 3 deletions
|
|
@ -686,6 +686,13 @@ impl cosmic::Application for SettingsApp {
|
||||||
return page.update(message).map(Into::into);
|
return page.update(message).map(Into::into);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "page-workspaces")]
|
||||||
|
crate::pages::Message::Workspaces(message) => {
|
||||||
|
if let Some(page) = self.pages.page_mut::<desktop::workspaces::Page>() {
|
||||||
|
return page.update(message).map(Into::into);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "wayland")]
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,10 @@ use cosmic::{
|
||||||
Apply, Element,
|
Apply, Element,
|
||||||
cosmic_config::{self, ConfigGet, ConfigSet},
|
cosmic_config::{self, ConfigGet, ConfigSet},
|
||||||
iced::Length,
|
iced::Length,
|
||||||
widget::{radio, settings, text},
|
surface,
|
||||||
|
widget::{self, radio, settings, text},
|
||||||
};
|
};
|
||||||
use cosmic_comp_config::workspace::{WorkspaceConfig, WorkspaceLayout, WorkspaceMode};
|
use cosmic_comp_config::workspace::{Action, WorkspaceConfig, WorkspaceLayout, WorkspaceMode};
|
||||||
use cosmic_settings_page::Section;
|
use cosmic_settings_page::Section;
|
||||||
use cosmic_settings_page::{self as page, section};
|
use cosmic_settings_page::{self as page, section};
|
||||||
use slab::Slab;
|
use slab::Slab;
|
||||||
|
|
@ -18,16 +19,20 @@ use tracing::error;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Message {
|
pub enum Message {
|
||||||
|
SetActionOnTyping(usize),
|
||||||
SetWorkspaceMode(WorkspaceMode),
|
SetWorkspaceMode(WorkspaceMode),
|
||||||
SetWorkspaceLayout(WorkspaceLayout),
|
SetWorkspaceLayout(WorkspaceLayout),
|
||||||
SetShowName(bool),
|
SetShowName(bool),
|
||||||
SetShowNumber(bool),
|
SetShowNumber(bool),
|
||||||
|
Surface(surface::Action),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
config: cosmic_config::Config,
|
config: cosmic_config::Config,
|
||||||
comp_config: cosmic_config::Config,
|
comp_config: cosmic_config::Config,
|
||||||
comp_workspace_config: WorkspaceConfig,
|
comp_workspace_config: WorkspaceConfig,
|
||||||
|
action_on_typing_selections: Vec<String>,
|
||||||
|
action_on_typing_active: Option<usize>,
|
||||||
show_workspace_name: bool,
|
show_workspace_name: bool,
|
||||||
show_workspace_number: bool,
|
show_workspace_number: bool,
|
||||||
}
|
}
|
||||||
|
|
@ -43,6 +48,8 @@ impl Default for Page {
|
||||||
WorkspaceConfig::default()
|
WorkspaceConfig::default()
|
||||||
});
|
});
|
||||||
let config = cosmic_config::Config::new("com.system76.CosmicWorkspaces", 1).unwrap();
|
let config = cosmic_config::Config::new("com.system76.CosmicWorkspaces", 1).unwrap();
|
||||||
|
let action_on_typing_active =
|
||||||
|
into_active_selection(&comp_workspace_config.action_on_typing);
|
||||||
let show_workspace_name = config.get("show_workspace_name").unwrap_or_else(|err| {
|
let show_workspace_name = config.get("show_workspace_name").unwrap_or_else(|err| {
|
||||||
if err.is_err() {
|
if err.is_err() {
|
||||||
error!(?err, "Failed to read config 'show_workspace_name'");
|
error!(?err, "Failed to read config 'show_workspace_name'");
|
||||||
|
|
@ -61,6 +68,12 @@ impl Default for Page {
|
||||||
config,
|
config,
|
||||||
comp_config,
|
comp_config,
|
||||||
comp_workspace_config,
|
comp_workspace_config,
|
||||||
|
action_on_typing_selections: vec![
|
||||||
|
fl!("workspaces-overview", "none"),
|
||||||
|
fl!("workspaces-overview", "launcher"),
|
||||||
|
fl!("workspaces-overview", "applications"),
|
||||||
|
],
|
||||||
|
action_on_typing_active,
|
||||||
show_workspace_name,
|
show_workspace_name,
|
||||||
show_workspace_number,
|
show_workspace_number,
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +86,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
|
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
|
||||||
) -> Option<page::Content> {
|
) -> Option<page::Content> {
|
||||||
Some(vec![
|
Some(vec![
|
||||||
|
sections.insert(action_on_typing()),
|
||||||
sections.insert(multi_behavior()),
|
sections.insert(multi_behavior()),
|
||||||
sections.insert(workspace_orientation()),
|
sections.insert(workspace_orientation()),
|
||||||
])
|
])
|
||||||
|
|
@ -97,7 +111,7 @@ impl Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, message: Message) {
|
pub fn update(&mut self, message: Message) -> cosmic::iced::Task<crate::app::Message> {
|
||||||
match message {
|
match message {
|
||||||
Message::SetWorkspaceMode(value) => {
|
Message::SetWorkspaceMode(value) => {
|
||||||
self.comp_workspace_config.workspace_mode = value;
|
self.comp_workspace_config.workspace_mode = value;
|
||||||
|
|
@ -107,6 +121,12 @@ impl Page {
|
||||||
self.comp_workspace_config.workspace_layout = value;
|
self.comp_workspace_config.workspace_layout = value;
|
||||||
self.save_comp_config();
|
self.save_comp_config();
|
||||||
}
|
}
|
||||||
|
Message::SetActionOnTyping(value) => {
|
||||||
|
self.comp_workspace_config.action_on_typing = into_action(value);
|
||||||
|
self.action_on_typing_active =
|
||||||
|
into_active_selection(&self.comp_workspace_config.action_on_typing);
|
||||||
|
self.save_comp_config();
|
||||||
|
}
|
||||||
Message::SetShowName(value) => {
|
Message::SetShowName(value) => {
|
||||||
self.show_workspace_name = value;
|
self.show_workspace_name = value;
|
||||||
if let Err(err) = self.config.set("show_workspace_name", value) {
|
if let Err(err) = self.config.set("show_workspace_name", value) {
|
||||||
|
|
@ -119,10 +139,64 @@ impl Page {
|
||||||
error!(?err, "Failed to set config 'show_workspace_number'");
|
error!(?err, "Failed to set config 'show_workspace_number'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::Surface(a) => {
|
||||||
|
return cosmic::task::message(crate::app::Message::Surface(a));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
cosmic::iced::Task::none()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn into_active_selection(action_on_typing: &Action) -> Option<usize> {
|
||||||
|
match action_on_typing {
|
||||||
|
Action::None => Some(0),
|
||||||
|
Action::OpenLauncher => Some(1),
|
||||||
|
Action::OpenApplications => Some(2),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn into_action(value: usize) -> Action {
|
||||||
|
match value {
|
||||||
|
1 => Action::OpenLauncher,
|
||||||
|
2 => Action::OpenApplications,
|
||||||
|
_ => Action::None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn action_on_typing() -> Section<crate::pages::Message> {
|
||||||
|
let mut descriptions = Slab::new();
|
||||||
|
|
||||||
|
let action_on_typing = descriptions.insert(fl!("workspaces-overview", "action-on-typing"));
|
||||||
|
|
||||||
|
Section::default()
|
||||||
|
.title(fl!("workspaces-overview"))
|
||||||
|
.descriptions(descriptions)
|
||||||
|
.view::<Page>(move |_binder, page, section| {
|
||||||
|
let descriptions = §ion.descriptions;
|
||||||
|
|
||||||
|
settings::section()
|
||||||
|
.title(§ion.title)
|
||||||
|
.add(
|
||||||
|
settings::item::builder(&descriptions[action_on_typing]).control(
|
||||||
|
widget::dropdown::popup_dropdown(
|
||||||
|
&page.action_on_typing_selections,
|
||||||
|
page.action_on_typing_active,
|
||||||
|
Message::SetActionOnTyping,
|
||||||
|
cosmic::iced::window::Id::RESERVED,
|
||||||
|
Message::Surface,
|
||||||
|
|a| {
|
||||||
|
crate::app::Message::PageMessage(crate::pages::Message::Workspaces(
|
||||||
|
a,
|
||||||
|
))
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.apply(Element::from)
|
||||||
|
.map(crate::pages::Message::Workspaces)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn multi_behavior() -> Section<crate::pages::Message> {
|
fn multi_behavior() -> Section<crate::pages::Message> {
|
||||||
let mut descriptions = Slab::new();
|
let mut descriptions = Slab::new();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,8 @@ pub enum Message {
|
||||||
WindowManagement(desktop::window_management::Message),
|
WindowManagement(desktop::window_management::Message),
|
||||||
#[cfg(feature = "page-networking")]
|
#[cfg(feature = "page-networking")]
|
||||||
Wired(networking::wired::Message),
|
Wired(networking::wired::Message),
|
||||||
|
#[cfg(feature = "page-workspaces")]
|
||||||
|
Workspaces(desktop::workspaces::Message),
|
||||||
|
|
||||||
// Common page functionality
|
// Common page functionality
|
||||||
CloseContextDrawer,
|
CloseContextDrawer,
|
||||||
|
|
|
||||||
5
i18n/de/cosmic_settings.ftl
vendored
5
i18n/de/cosmic_settings.ftl
vendored
|
|
@ -335,6 +335,11 @@ focus-navigation = Fokus-Navigation
|
||||||
|
|
||||||
workspaces = Arbeitsflächen
|
workspaces = Arbeitsflächen
|
||||||
.desc = Anzahl, Verhalten und Platzierung der Arbeitsflächen festlegen.
|
.desc = Anzahl, Verhalten und Platzierung der Arbeitsflächen festlegen.
|
||||||
|
workspaces-overview = Arbeitsflächenübersicht
|
||||||
|
.action-on-typing = Reaktion auf Tippen
|
||||||
|
.none = Keine
|
||||||
|
.launcher = Starter öffnen
|
||||||
|
.applications = Anwendungen öffnen
|
||||||
workspaces-behavior = Verhaltern der Arbeitsfläche
|
workspaces-behavior = Verhaltern der Arbeitsfläche
|
||||||
.dynamic = Dynamische Arbeitsflächen
|
.dynamic = Dynamische Arbeitsflächen
|
||||||
.dynamic-desc = Entfernt automatisch leere Arbeitsflächen.
|
.dynamic-desc = Entfernt automatisch leere Arbeitsflächen.
|
||||||
|
|
|
||||||
6
i18n/en/cosmic_settings.ftl
vendored
6
i18n/en/cosmic_settings.ftl
vendored
|
|
@ -383,6 +383,12 @@ focus-navigation = Focus navigation
|
||||||
workspaces = Workspaces
|
workspaces = Workspaces
|
||||||
.desc = Workspace orientation and behavior
|
.desc = Workspace orientation and behavior
|
||||||
|
|
||||||
|
workspaces-overview = Workspaces overview
|
||||||
|
.action-on-typing = Action on typing
|
||||||
|
.none = None
|
||||||
|
.launcher = Open Launcher
|
||||||
|
.applications = Open Applications
|
||||||
|
|
||||||
workspaces-behavior = Workspace behavior
|
workspaces-behavior = Workspace behavior
|
||||||
.dynamic = Dynamic workspaces
|
.dynamic = Dynamic workspaces
|
||||||
.dynamic-desc = Automatically removes empty workspaces.
|
.dynamic-desc = Automatically removes empty workspaces.
|
||||||
|
|
|
||||||
5
i18n/es/cosmic_settings.ftl
vendored
5
i18n/es/cosmic_settings.ftl
vendored
|
|
@ -335,6 +335,11 @@ focus-navigation = Navegación de enfoque
|
||||||
|
|
||||||
workspaces = Espacios de trabajo
|
workspaces = Espacios de trabajo
|
||||||
.desc = Configurar el número de espacios de trabajo, comportamiento y ubicación.
|
.desc = Configurar el número de espacios de trabajo, comportamiento y ubicación.
|
||||||
|
workspaces-overview = Vista general de espacios de trabajo
|
||||||
|
.action-on-typing = Acción al escribir
|
||||||
|
.none = Ninguna
|
||||||
|
.launcher = Abrir lanzador
|
||||||
|
.applications = Abrir aplicaciones
|
||||||
workspaces-behavior = Comportamiento de los espacios de trabajo
|
workspaces-behavior = Comportamiento de los espacios de trabajo
|
||||||
.dynamic = Espacios de trabajo dinámicos
|
.dynamic = Espacios de trabajo dinámicos
|
||||||
.dynamic-desc = Elimina automáticamente los espacios de trabajo vacíos.
|
.dynamic-desc = Elimina automáticamente los espacios de trabajo vacíos.
|
||||||
|
|
|
||||||
5
i18n/sv/cosmic_settings.ftl
vendored
5
i18n/sv/cosmic_settings.ftl
vendored
|
|
@ -266,6 +266,11 @@ x-hours =
|
||||||
|
|
||||||
workspaces = Arbetsytor
|
workspaces = Arbetsytor
|
||||||
.desc = Orientering och beteende för arbetsytor
|
.desc = Orientering och beteende för arbetsytor
|
||||||
|
workspaces-overview = Arbetsyteöversikt
|
||||||
|
.action-on-typing = Åtgärd vid skrivning
|
||||||
|
.none = Ingen
|
||||||
|
.launcher = Öppna programstartare
|
||||||
|
.applications = Öppna applikationer
|
||||||
workspaces-behavior = Beteende för arbetsytor
|
workspaces-behavior = Beteende för arbetsytor
|
||||||
.dynamic = Dynamiska arbetsytor
|
.dynamic = Dynamiska arbetsytor
|
||||||
.dynamic-desc = Tar automatiskt bort tomma arbetsytor.
|
.dynamic-desc = Tar automatiskt bort tomma arbetsytor.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue