chore: add SPDX license identifiers
This commit is contained in:
parent
b9308af4b7
commit
8527257ddd
96 changed files with 275 additions and 39 deletions
|
|
@ -1,7 +1,12 @@
|
|||
// Copyright 2024 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use cosmic::cosmic_config::{self, cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry};
|
||||
use cosmic_comp_config::XkbConfig;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub const CONFIG_VERSION: u64 = 1;
|
||||
|
||||
#[derive(Clone, CosmicConfigEntry, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
pub struct Config {}
|
||||
impl Default for Config {
|
||||
|
|
@ -9,6 +14,7 @@ impl Default for Config {
|
|||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, CosmicConfigEntry, Debug, Deserialize, PartialEq, Serialize, Default)]
|
||||
pub struct CosmicCompConfig {
|
||||
pub xkb_config: XkbConfig,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright 2024 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::window::Window;
|
||||
use config::{Config, CONFIG_VERSION};
|
||||
use cosmic::cosmic_config;
|
||||
|
|
@ -23,31 +26,32 @@ pub fn run() -> cosmic::iced::Result {
|
|||
let config = match Config::get_entry(&config_handler) {
|
||||
Ok(ok) => ok,
|
||||
Err((errs, config)) => {
|
||||
eprintln!("errors loading config: {:?}", errs);
|
||||
tracing::error!("errors loading config: {:?}", errs);
|
||||
config
|
||||
}
|
||||
};
|
||||
(Some(config_handler), config)
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("failed to create config handler: {}", err);
|
||||
tracing::error!("failed to create config handler: {}", err);
|
||||
(None, Config::default())
|
||||
}
|
||||
};
|
||||
|
||||
let (comp_config_handler, comp_config) =
|
||||
match cosmic_config::Config::new("com.system76.CosmicComp", CosmicCompConfig::VERSION) {
|
||||
Ok(config_handler) => {
|
||||
let config = match CosmicCompConfig::get_entry(&config_handler) {
|
||||
Ok(ok) => ok,
|
||||
Err((errs, config)) => {
|
||||
eprintln!("errors loading config: {:?}", errs);
|
||||
tracing::error!("errors loading config: {:?}", errs);
|
||||
config
|
||||
}
|
||||
};
|
||||
(Some(config_handler), config)
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("failed to create config handler: {}", err);
|
||||
tracing::error!("failed to create config handler: {}", err);
|
||||
(None, CosmicCompConfig::default())
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
// Copyright 2024 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use i18n_embed::{
|
||||
fluent::{fluent_language_loader, FluentLanguageLoader},
|
||||
DefaultLocalizer, LanguageLoader, Localizer,
|
||||
};
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use rust_embed::RustEmbed;
|
||||
|
||||
#[derive(RustEmbed)]
|
||||
#[folder = "i18n/"]
|
||||
struct Localizations;
|
||||
|
||||
pub static LANGUAGE_LOADER: Lazy<FluentLanguageLoader> = Lazy::new(|| {
|
||||
let loader: FluentLanguageLoader = fluent_language_loader!();
|
||||
loader
|
||||
|
|
@ -14,6 +20,7 @@ pub static LANGUAGE_LOADER: Lazy<FluentLanguageLoader> = Lazy::new(|| {
|
|||
.expect("Error while loading fallback language");
|
||||
loader
|
||||
});
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! fl {
|
||||
($message_id:literal) => {{
|
||||
|
|
@ -23,14 +30,16 @@ macro_rules! fl {
|
|||
i18n_embed_fl::fl!($crate::localize::LANGUAGE_LOADER, $message_id, $($args), *)
|
||||
}};
|
||||
}
|
||||
|
||||
// Get the `Localizer` to be used for localizing this library.
|
||||
pub fn localizer() -> Box<dyn Localizer> {
|
||||
Box::from(DefaultLocalizer::new(&*LANGUAGE_LOADER, &Localizations))
|
||||
}
|
||||
|
||||
pub fn localize() {
|
||||
let localizer = localizer();
|
||||
let requested_languages = i18n_embed::DesktopLanguageRequester::requested_languages();
|
||||
if let Err(error) = localizer.select(&requested_languages) {
|
||||
eprintln!("Error while loading language for App List {}", error);
|
||||
tracing::error!("Error while loading language for App List {}", error);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright 2024 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
fn main() -> cosmic::iced::Result {
|
||||
tracing_subscriber::fmt::init();
|
||||
let _ = tracing_log::LogTracer::init();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// Copyright 2024 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::config::{Config, CONFIG_VERSION};
|
||||
#[allow(unused_imports)]
|
||||
use crate::fl;
|
||||
|
|
@ -16,6 +19,7 @@ use cosmic::prelude::*;
|
|||
use cosmic::widget;
|
||||
use cosmic_comp_config::CosmicCompConfig;
|
||||
use xkb_data::KeyboardLayouts;
|
||||
|
||||
pub const ID: &str = "com.system76.CosmicAppletInputSources";
|
||||
|
||||
pub struct Window {
|
||||
|
|
@ -29,6 +33,7 @@ pub struct Window {
|
|||
layouts: KeyboardLayouts,
|
||||
active_layouts: Vec<ActiveLayout>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Message {
|
||||
Config(Config),
|
||||
|
|
@ -38,6 +43,7 @@ pub enum Message {
|
|||
SetActiveLayout(ActiveLayout),
|
||||
KeyboardSettings,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Flags {
|
||||
pub config_handler: Option<cosmic_config::Config>,
|
||||
|
|
@ -46,6 +52,7 @@ pub struct Flags {
|
|||
pub comp_config_handler: Option<cosmic_config::Config>,
|
||||
pub layouts: KeyboardLayouts,
|
||||
}
|
||||
|
||||
impl cosmic::Application for Window {
|
||||
type Executor = cosmic::SingleThreadExecutor;
|
||||
type Flags = Flags;
|
||||
|
|
@ -145,7 +152,7 @@ impl cosmic::Application for Window {
|
|||
if let Err(err) =
|
||||
comp_config_handler.set("xkb_config", &self.comp_config.xkb_config)
|
||||
{
|
||||
eprint!("Failed to set config 'xkb_config' {err}");
|
||||
tracing::error!("Failed to set config 'xkb_config' {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -204,9 +211,10 @@ impl cosmic::Application for Window {
|
|||
)
|
||||
.map(|update| {
|
||||
if !update.errors.is_empty() {
|
||||
eprintln!(
|
||||
tracing::error!(
|
||||
"errors loading config {:?}: {:?}",
|
||||
update.keys, update.errors
|
||||
update.keys,
|
||||
update.errors
|
||||
);
|
||||
}
|
||||
Message::Config(update.config)
|
||||
|
|
@ -216,9 +224,10 @@ impl cosmic::Application for Window {
|
|||
.watch_config("com.system76.CosmicComp")
|
||||
.map(|update| {
|
||||
if !update.errors.is_empty() {
|
||||
eprintln!(
|
||||
tracing::error!(
|
||||
"errors loading config {:?}: {:?}",
|
||||
update.keys, update.errors
|
||||
update.keys,
|
||||
update.errors
|
||||
);
|
||||
}
|
||||
Message::CompConfig(update.config)
|
||||
|
|
@ -278,6 +287,7 @@ impl Window {
|
|||
active_layouts
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub struct ActiveLayout {
|
||||
layout: String,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue