From 521ee7026a9700739d875f63444406d68a2a968e Mon Sep 17 00:00:00 2001 From: Eduardo Flores Date: Wed, 6 Nov 2024 10:04:15 +0000 Subject: [PATCH] improv: update about page --- Cargo.lock | 228 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 5 +- build.rs | 17 ---- src/app.rs | 181 +++++++++++++++++++----------------------- 4 files changed, 195 insertions(+), 236 deletions(-) delete mode 100644 build.rs diff --git a/Cargo.lock b/Cargo.lock index 9ccc19c..413536e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1080,11 +1080,11 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "atomicwrites", "cosmic-config-derive", - "dirs", + "dirs 5.0.1", "iced_futures", "known-folders", "notify", @@ -1099,7 +1099,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "quote", "syn 1.0.109", @@ -1130,7 +1130,7 @@ dependencies = [ "chrono", "cosmic-ext-config-templates", "cosmic-panel-config", - "dirs", + "dirs 5.0.1", "env_logger 0.11.5", "i18n-embed", "i18n-embed-fl", @@ -1145,7 +1145,6 @@ dependencies = [ "rust-embed", "serde", "tokio", - "vergen", ] [[package]] @@ -1189,12 +1188,12 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "almost", "cosmic-config", "csscolorparser", - "dirs", + "dirs 5.0.1", "lazy_static", "palette", "ron", @@ -1364,15 +1363,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" -[[package]] -name = "deranged" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" -dependencies = [ - "powerfmt", -] - [[package]] name = "derivative" version = "2.2.0" @@ -1406,13 +1396,33 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dirs" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" +dependencies = [ + "dirs-sys 0.3.7", +] + [[package]] name = "dirs" version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ - "dirs-sys", + "dirs-sys 0.4.1", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", ] [[package]] @@ -1966,13 +1976,26 @@ dependencies = [ "num", ] +[[package]] +name = "freedesktop-desktop-entry" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c201444ddafb5506fe85265b48421664ff4617e3b7090ef99e42a0070c1aead0" +dependencies = [ + "dirs 3.0.2", + "gettext-rs", + "memchr", + "thiserror", + "xdg", +] + [[package]] name = "freedesktop-icons" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8ef34245e0540c9a3ce7a28340b98d2c12b75da0d446da4e8224923fcaa0c16" dependencies = [ - "dirs", + "dirs 5.0.1", "once_cell", "rust-ini", "thiserror", @@ -2137,6 +2160,26 @@ dependencies = [ "wasi", ] +[[package]] +name = "gettext-rs" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44e92f7dc08430aca7ed55de161253a22276dfd69c5526e5c5e95d1f7cf338a" +dependencies = [ + "gettext-sys", + "locale_config", +] + +[[package]] +name = "gettext-sys" +version = "0.22.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb45773f5b8945f12aecd04558f545964f943dacda1b1155b3d738f5469ef661" +dependencies = [ + "cc", + "temp-dir", +] + [[package]] name = "gif" version = "0.13.1" @@ -2564,7 +2607,7 @@ dependencies = [ [[package]] name = "iced" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "dnd", "iced_accessibility", @@ -2582,7 +2625,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "accesskit", "accesskit_winit", @@ -2591,7 +2634,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "bitflags 2.6.0", "bytes", @@ -2614,7 +2657,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "futures", "iced_core", @@ -2640,7 +2683,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "bitflags 2.6.0", "bytemuck", @@ -2662,7 +2705,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2674,7 +2717,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "bytes", "dnd", @@ -2688,7 +2731,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "bytemuck", "cosmic-text", @@ -2704,7 +2747,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "as-raw-xcb-connection", "bitflags 2.6.0", @@ -2735,7 +2778,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "dnd", "iced_renderer", @@ -2752,7 +2795,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "dnd", "iced_futures", @@ -3088,14 +3131,14 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#bd28ae658161852e51c7746218cd9dd619698998" +source = "git+https://github.com/pop-os/libcosmic.git#8d4afb90da26d1a4526c4146c43856f7bff008b3" dependencies = [ "apply", "ashpd 0.9.1", @@ -3105,6 +3148,7 @@ dependencies = [ "css-color", "derive_setters", "fraction", + "freedesktop-desktop-entry", "freedesktop-icons", "iced", "iced_core", @@ -3116,9 +3160,14 @@ dependencies = [ "iced_widget", "iced_winit", "lazy_static", + "libc", + "mime 0.3.17", + "open", "palette", "rfd", + "rustix 0.38.34", "serde", + "shlex", "slotmap", "taffy", "thiserror", @@ -3380,6 +3429,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "wasi", + "windows-sys 0.52.0", +] + [[package]] name = "mutate_once" version = "0.1.1" @@ -3502,7 +3563,7 @@ dependencies = [ "kqueue", "libc", "log", - "mio", + "mio 0.8.11", "walkdir", "windows-sys 0.48.0", ] @@ -3540,12 +3601,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-conv" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" - [[package]] name = "num-integer" version = "0.1.46" @@ -3618,15 +3673,6 @@ dependencies = [ "syn 2.0.85", ] -[[package]] -name = "num_threads" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" -dependencies = [ - "libc", -] - [[package]] name = "objc" version = "0.2.7" @@ -3876,9 +3922,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "open" -version = "5.1.2" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "449f0ff855d85ddbf1edd5b646d65249ead3f5e422aaa86b7d2d0b049b103e32" +checksum = "61a877bf6abd716642a53ef1b89fb498923a4afca5c754f9050b4d081c05c4b3" dependencies = [ "is-wsl", "libc", @@ -4242,12 +4288,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -4778,12 +4818,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "rustversion" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" - [[package]] name = "rustybuzz" version = "0.14.1" @@ -4975,6 +5009,12 @@ dependencies = [ "digest", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -5293,6 +5333,12 @@ dependencies = [ "slotmap", ] +[[package]] +name = "temp-dir" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc1ee6eef34f12f765cb94725905c6312b6610ab2b0940889cfe58dae7bc3c72" + [[package]] name = "tempfile" version = "3.10.1" @@ -5345,39 +5391,6 @@ dependencies = [ "weezl", ] -[[package]] -name = "time" -version = "0.3.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" -dependencies = [ - "deranged", - "itoa", - "libc", - "num-conv", - "num_threads", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - -[[package]] -name = "time-macros" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" -dependencies = [ - "num-conv", - "time-core", -] - [[package]] name = "tiny-keccak" version = "2.0.2" @@ -5452,28 +5465,27 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", "libc", - "mio", - "num_cpus", + "mio 1.0.2", "pin-project-lite", "signal-hook-registry", "socket2 0.5.7", "tokio-macros", "tracing", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -5862,18 +5874,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vergen" -version = "8.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2990d9ea5967266ea0ccf413a4aa5c42a93dbcfda9cb49a97de6931726b12566" -dependencies = [ - "anyhow", - "cfg-if", - "rustversion", - "time", -] - [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index e301c79..080355d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ chrono = { version = "0.4.38", features = ["serde"] } [dependencies.libcosmic] git = "https://github.com/pop-os/libcosmic.git" default-features = false -features = ["multi-window", "tokio", "winit", "wgpu"] +features = ["multi-window", "tokio", "winit", "wgpu", "desktop"] [dependencies.cosmic-ext-config-templates] git = "https://github.com/ryanabx/cosmic-ext-config-templates" @@ -42,8 +42,5 @@ features = ["derive"] version = "1.35.1" features = ["macros", "fs", "rt"] -[build-dependencies] -vergen = { version = "8", features = ["git", "gitcl"] } - [patch."https://github.com/smithay/client-toolkit.git"] sctk = { package = "smithay-client-toolkit", version = "=0.19.2" } diff --git a/build.rs b/build.rs deleted file mode 100644 index be10241..0000000 --- a/build.rs +++ /dev/null @@ -1,17 +0,0 @@ -fn main() -> Result<(), Box> { - // Rebuild if i18n files change - println!("cargo:rerun-if-changed=i18n"); - - // Emit version information (if not cached by just vendor) - let mut vergen = vergen::EmitBuilder::builder(); - println!("cargo:rerun-if-env-changed=VERGEN_GIT_COMMIT_DATE"); - if std::env::var_os("VERGEN_GIT_COMMIT_DATE").is_none() { - vergen.git_commit_date(); - } - println!("cargo:rerun-if-env-changed=VERGEN_GIT_SHA"); - if std::env::var_os("VERGEN_GIT_SHA").is_none() { - vergen.git_sha(false); - } - vergen.fail_on_error().emit()?; - Ok(()) -} diff --git a/src/app.rs b/src/app.rs index bb647d9..71a1d3c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -4,7 +4,7 @@ use std::{ }; use cosmic::{ - app::{self, Core}, + app::{self, about::About, Core}, cosmic_config::{self, Update}, cosmic_theme::{self, ThemeMode}, iced::{ @@ -40,6 +40,7 @@ pub mod style; pub struct TweakTool { core: Core, nav_model: segmented_button::SingleSelectModel, + about: About, dialog_pages: VecDeque, dialog_text_input: widget::Id, key_binds: HashMap, @@ -83,13 +84,13 @@ pub enum Message { SaveNewColorScheme(String), ToggleContextPage(ContextPage), ToggleDialogPage(DialogPage), - LaunchUrl(String), AppTheme(usize), FetchAvailableColorSchemes(ColorSchemeProvider, usize), SetAvailableColorSchemes(Vec), Key(Modifiers, Key), Modifiers(Modifiers), SystemThemeModeChange, + Cosmic(cosmic::app::cosmic::Message), } #[derive(Debug, Clone, Eq, PartialEq)] @@ -146,6 +147,77 @@ impl Application for TweakTool { &mut self.core } + fn init(core: Core, flags: Self::Flags) -> (Self, Task>) { + log::info!("Starting Cosmic Tweak Tool..."); + + let mut nav_model = segmented_button::SingleSelectModel::default(); + for &nav_page in Page::all() { + let id = nav_model + .insert() + .icon(nav_page.icon()) + .text(nav_page.title()) + .data::(nav_page) + .id(); + + if nav_page == Page::default() { + nav_model.activate(id); + } + } + + let about = About::default() + .set_application_icon(Self::APP_ID) + .set_developer_name("Eduardo Flores") + .set_license_type("GPL-3.0") + .set_version("0.1.2") + .set_support_url("https://github.com/cosmic-utils/tweaks/issues") + .set_repository_url("https://github.com/cosmic-utils/tweaks") + .set_developers([("Eduardo Flores".into(), "edfloreshz@proton.me".into())]); + + let mut app = TweakTool { + core, + nav_model, + about, + dialog_pages: VecDeque::new(), + dialog_text_input: widget::Id::unique(), + key_binds: key_binds(), + modifiers: Modifiers::empty(), + color_schemes: ColorSchemes::default(), + layouts: Layouts::default(), + snapshots: Snapshots::default(), + context_page: ContextPage::About, + app_themes: vec![fl!("match-desktop"), fl!("dark"), fl!("light")], + config_handler: flags.config_handler, + config: flags.config, + available: vec![], + status: Status::Idle, + limit: 15, + offset: 0, + }; + + let mut tasks = vec![ + app.update(Message::FetchAvailableColorSchemes( + ColorSchemeProvider::CosmicThemes, + app.limit, + )), + app.update(Message::Snapshots( + pages::snapshots::Message::CreateSnapshot( + "Application opened".into(), + SnapshotKind::System, + ), + )), + ]; + + if let Some(id) = app.core.main_window_id() { + tasks.push(app.set_window_title(fl!("app-title"), id)); + } + + (app, Task::batch(tasks)) + } + + fn about(&self) -> Option<&app::about::About> { + Some(&self.about) + } + fn header_start(&self) -> Vec> { let menu_bar = menu::bar(vec![menu::Tree::with_children( menu::root(fl!("view")), @@ -161,10 +233,6 @@ impl Application for TweakTool { vec![menu_bar.into()] } - fn header_center(&self) -> Vec> { - vec![widget::text::text(fl!("app-title")).into()] - } - fn nav_model(&self) -> Option<&widget::nav_bar::Model> { Some(&self.nav_model) } @@ -194,7 +262,7 @@ impl Application for TweakTool { } Some(match self.context_page { - ContextPage::About => self.about(), + ContextPage::About => self.about_view()?.map(Message::Cosmic), ContextPage::Settings => self.settings(), }) } @@ -285,63 +353,6 @@ impl Application for TweakTool { Some(dialog.into()) } - fn init(core: Core, flags: Self::Flags) -> (Self, Task>) { - log::info!("Starting Cosmic Tweak Tool..."); - - let mut nav_model = segmented_button::SingleSelectModel::default(); - for &nav_page in Page::all() { - let id = nav_model - .insert() - .icon(nav_page.icon()) - .text(nav_page.title()) - .data::(nav_page) - .id(); - - if nav_page == Page::default() { - nav_model.activate(id); - } - } - - let mut app = TweakTool { - nav_model, - core, - dialog_pages: VecDeque::new(), - dialog_text_input: widget::Id::unique(), - key_binds: key_binds(), - modifiers: Modifiers::empty(), - color_schemes: ColorSchemes::default(), - layouts: Layouts::default(), - snapshots: Snapshots::default(), - context_page: ContextPage::About, - app_themes: vec![fl!("match-desktop"), fl!("dark"), fl!("light")], - config_handler: flags.config_handler, - config: flags.config, - available: vec![], - status: Status::Idle, - limit: 15, - offset: 0, - }; - - let mut tasks = vec![ - app.update(Message::FetchAvailableColorSchemes( - ColorSchemeProvider::CosmicThemes, - app.limit, - )), - app.update(Message::Snapshots( - pages::snapshots::Message::CreateSnapshot( - "Application opened".into(), - SnapshotKind::System, - ), - )), - ]; - - if let Some(id) = app.core.main_window_id() { - tasks.push(app.set_window_title(fl!("app-title"), id)); - } - - (app, Task::batch(tasks)) - } - fn view(&self) -> Element { let spacing = cosmic::theme::active().cosmic().spacing; let entity = self.nav_model.active(); @@ -397,6 +408,11 @@ impl Application for TweakTool { let mut commands = vec![]; match message { + Message::Cosmic(message) => { + commands.push(cosmic::app::command::message(cosmic::app::message::cosmic( + message, + ))); + } Message::FetchAvailableColorSchemes(provider, limit) => { if self.offset == 0 { self.status = Status::Loading; @@ -445,12 +461,6 @@ impl Application for TweakTool { config_set!(app_theme, app_theme); return self.update_config(); } - Message::LaunchUrl(url) => match open::that_detached(&url) { - Ok(()) => {} - Err(err) => { - log::warn!("failed to open {:?}: {}", url, err); - } - }, Message::ToggleContextPage(page) => { if self.context_page == page { self.core.window.show_context = !self.core.window.show_context; @@ -602,37 +612,6 @@ impl TweakTool { app::command::set_theme(self.config.app_theme.theme()) } - fn about(&self) -> Element { - let spacing = cosmic::theme::active().cosmic().spacing; - let repository = "https://github.com/cosmic-utils/tweaks"; - let hash = env!("VERGEN_GIT_SHA"); - let short_hash: String = hash.chars().take(7).collect(); - let date = env!("VERGEN_GIT_COMMIT_DATE"); - widget::column::with_children(vec![ - widget::svg(widget::svg::Handle::from_memory( - &include_bytes!("../res/icons/hicolor/scalable/apps/icon.svg")[..], - )) - .into(), - widget::text::title3(fl!("app-title")).into(), - widget::button::link(repository) - .on_press(Message::LaunchUrl(repository.to_string())) - .padding(spacing.space_none) - .into(), - widget::button::link(fl!( - "git-description", - hash = short_hash.as_str(), - date = date - )) - .on_press(Message::LaunchUrl(format!("{repository}/commits/{hash}"))) - .padding(spacing.space_none) - .into(), - ]) - .align_x(Alignment::Center) - .spacing(spacing.space_xxs) - .width(Length::Fill) - .into() - } - fn settings(&self) -> Element { let app_theme_selected = match self.config.app_theme { AppTheme::Dark => 1,