From e9e7729ba5707de979b0d4ddf9e20a28cfcf2e1b Mon Sep 17 00:00:00 2001 From: dastansam Date: Tue, 23 Jul 2024 23:45:12 +0600 Subject: [PATCH] Add icons build script --- Cargo.lock | 141 ++++++++++++----------------- Cargo.toml | 11 ++- build.rs | 11 +++ icons.toml | 4 + src/frontend/configuration.rs | 8 +- src/frontend/configuration/farm.rs | 3 +- src/frontend/running.rs | 5 +- src/frontend/running/farm.rs | 4 +- src/frontend/running/node.rs | 4 +- src/main.rs | 8 +- 10 files changed, 97 insertions(+), 102 deletions(-) create mode 100644 icons.toml diff --git a/Cargo.lock b/Cargo.lock index 2e5e0bd..5a6426b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1540,23 +1540,22 @@ dependencies = [ [[package]] name = "cairo-rs" -version = "0.18.5" +version = "0.19.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2" +checksum = "b2ac2a4d0e69036cf0062976f6efcba1aaee3e448594e6514bb2ddf87acce562" dependencies = [ "bitflags 2.6.0", "cairo-sys-rs", "glib", "libc", - "once_cell", "thiserror", ] [[package]] name = "cairo-sys-rs" -version = "0.18.2" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51" +checksum = "fd3bb3119664efbd78b5e6c93957447944f16bdbced84c17a9f41c7829b81e64" dependencies = [ "glib-sys", "libc", @@ -3782,22 +3781,21 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.18.5" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec" +checksum = "624eaba126021103c7339b2e179ae4ee8cdab842daab419040710f38ed9f8699" dependencies = [ "gdk-pixbuf-sys", "gio", "glib", "libc", - "once_cell", ] [[package]] name = "gdk-pixbuf-sys" -version = "0.18.0" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7" +checksum = "4efa05a4f83c8cc50eb4d883787b919b85e5f1d8dd10b5a1df53bf5689782379" dependencies = [ "gio-sys", "glib-sys", @@ -3808,9 +3806,9 @@ dependencies = [ [[package]] name = "gdk4" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edb019ad581f8ecf8ea8e4baa6df7c483a95b5a59be3140be6a9c3b0c632af6" +checksum = "db265c9dd42d6a371e09e52deab3a84808427198b86ac792d75fd35c07990a07" dependencies = [ "cairo-rs", "gdk-pixbuf", @@ -3823,9 +3821,9 @@ dependencies = [ [[package]] name = "gdk4-sys" -version = "0.7.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbab43f332a3cf1df9974da690b5bb0e26720ed09a228178ce52175372dcfef0" +checksum = "c9418fb4e8a67074919fe7604429c45aa74eb9df82e7ca529767c6d4e9dc66dd" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -3921,9 +3919,9 @@ checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "gio" -version = "0.18.4" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73" +checksum = "4c49f117d373ffcc98a35d114db5478bc223341cff53e39a5d6feced9e2ddffe" dependencies = [ "futures-channel", "futures-core", @@ -3932,7 +3930,6 @@ dependencies = [ "gio-sys", "glib", "libc", - "once_cell", "pin-project-lite 0.2.14", "smallvec", "thiserror", @@ -3940,22 +3937,22 @@ dependencies = [ [[package]] name = "gio-sys" -version = "0.18.1" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" +checksum = "2cd743ba4714d671ad6b6234e8ab2a13b42304d0e13ab7eba1dcdd78a7d6d4ef" dependencies = [ "glib-sys", "gobject-sys", "libc", "system-deps", - "winapi", + "windows-sys 0.52.0", ] [[package]] name = "glib" -version = "0.18.5" +version = "0.19.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" +checksum = "39650279f135469465018daae0ba53357942a5212137515777d5fdca74984a44" dependencies = [ "bitflags 2.6.0", "futures-channel", @@ -3969,20 +3966,18 @@ dependencies = [ "gobject-sys", "libc", "memchr", - "once_cell", "smallvec", "thiserror", ] [[package]] name = "glib-macros" -version = "0.18.5" +version = "0.19.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" +checksum = "4429b0277a14ae9751350ad9b658b1be0abb5b54faa5bcdf6e74a3372582fad7" dependencies = [ - "heck 0.4.1", - "proc-macro-crate 2.0.0", - "proc-macro-error", + "heck 0.5.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.68", @@ -3990,9 +3985,9 @@ dependencies = [ [[package]] name = "glib-sys" -version = "0.18.1" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" +checksum = "5c2dc18d3a82b0006d470b13304fbbb3e0a9bd4884cf985a60a7ed733ac2c4a5" dependencies = [ "libc", "system-deps", @@ -4006,9 +4001,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "gobject-sys" -version = "0.18.0" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" +checksum = "2e697e252d6e0416fd1d9e169bda51c0f1c926026c39ca21fbe8b1bb5c3b8b9e" dependencies = [ "glib-sys", "libc", @@ -4037,9 +4032,9 @@ dependencies = [ [[package]] name = "graphene-rs" -version = "0.18.1" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2228cda1505613a7a956cca69076892cfbda84fc2b7a62b94a41a272c0c401" +checksum = "f5fb86031d24d9ec0a2a15978fc7a65d545a2549642cf1eb7c3dda358da42bcf" dependencies = [ "glib", "graphene-sys", @@ -4048,9 +4043,9 @@ dependencies = [ [[package]] name = "graphene-sys" -version = "0.18.1" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4144cee8fc8788f2a9b73dc5f1d4e1189d1f95305c4cb7bd9c1af1cfa31f59" +checksum = "2f530e0944bccba4b55065e9c69f4975ad691609191ebac16e13ab8e1f27af05" dependencies = [ "glib-sys", "libc", @@ -4071,9 +4066,9 @@ dependencies = [ [[package]] name = "gsk4" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d958e351d2f210309b32d081c832d7de0aca0b077aa10d88336c6379bd01f7e" +checksum = "7563884bf6939f4468e5d94654945bdd9afcaf8c3ba4c5dd17b5342b747221be" dependencies = [ "cairo-rs", "gdk4", @@ -4086,9 +4081,9 @@ dependencies = [ [[package]] name = "gsk4-sys" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bd9e3effea989f020e8f1ff3fa3b8c63ba93d43b899c11a118868853a56d55" +checksum = "23024bf2636c38bbd1f822f58acc9d1c25b28da896ff0f291a1a232d4272b3dc" dependencies = [ "cairo-sys-rs", "gdk4-sys", @@ -4102,9 +4097,9 @@ dependencies = [ [[package]] name = "gtk4" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeb51aa3e9728575a053e1f43543cd9992ac2477e1b186ad824fd4adfb70842" +checksum = "b04e11319b08af11358ab543105a9e49b0c491faca35e2b8e7e36bfba8b671ab" dependencies = [ "cairo-rs", "field-offset", @@ -4123,23 +4118,21 @@ dependencies = [ [[package]] name = "gtk4-macros" -version = "0.7.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d57ec49cf9b657f69a05bca8027cff0a8dfd0c49e812be026fc7311f2163832f" +checksum = "ec655a7ef88d8ce9592899deb8b2d0fa50bab1e6dd69182deb764e643c522408" dependencies = [ - "anyhow", - "proc-macro-crate 1.1.3", - "proc-macro-error", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.68", ] [[package]] name = "gtk4-sys" -version = "0.7.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54d8c4aa23638ce9faa2caf7e2a27d4a1295af2155c8e8d28c4d4eeca7a65eb8" +checksum = "8c8aa86b7f85ea71d66ea88c1d4bae1cfacf51ca4856274565133838d77e57b5" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -7513,22 +7506,21 @@ dependencies = [ [[package]] name = "pango" -version = "0.18.3" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4" +checksum = "3f0d328648058085cfd6897c9ae4272884098a926f3a833cd50c8c73e6eccecd" dependencies = [ "gio", "glib", "libc", - "once_cell", "pango-sys", ] [[package]] name = "pango-sys" -version = "0.18.0" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5" +checksum = "ff03da4fa086c0b244d4a4587d3e20622a3ecdb21daea9edf66597224c634ba0" dependencies = [ "glib-sys", "gobject-sys", @@ -8041,15 +8033,6 @@ dependencies = [ "toml 0.5.11", ] -[[package]] -name = "proc-macro-crate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" -dependencies = [ - "toml_edit 0.20.7", -] - [[package]] name = "proc-macro-crate" version = "3.1.0" @@ -8753,11 +8736,10 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "relm4" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f8f08cd89e93688c76f1ceae98f1331131b211b898d529bcf41f4ccfcbe698e" +checksum = "e6e0e187b58db367305e8486d3228158251da1c8ba1e18baa9de61894e822649" dependencies = [ - "async-trait", "flume", "fragile", "futures", @@ -8770,9 +8752,9 @@ dependencies = [ [[package]] name = "relm4-components" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6891c5cdb090a76e5eb3ec525dafe0171a751cb54156b6d62e1e43e6d2188db" +checksum = "ffcb6431605810fca4430b3da5d496fcf67d39f32db6a2799bcaac27469154b9" dependencies = [ "once_cell", "relm4", @@ -8781,19 +8763,19 @@ dependencies = [ [[package]] name = "relm4-icons" -version = "0.7.0-alpha.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d2413577ec528e0a4de8d05e7b1f6840e60f2cf14a70b16dfd8d862654c06c" +version = "0.8.3" dependencies = [ "gtk4", "gvdb", + "serde", + "toml 0.8.14", ] [[package]] name = "relm4-macros" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0249463bd27f93f10c883aaa31e7ca254cc2f0c6c8cd60a68e6d052d9dba85" +checksum = "0774e846889823aa5766f5b62cface3189a5b36280e65b2faaa6df0319da1726" dependencies = [ "proc-macro2", "quote", @@ -12759,17 +12741,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_edit" -version = "0.20.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" -dependencies = [ - "indexmap 2.2.6", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.21.1" diff --git a/Cargo.toml b/Cargo.toml index 0105657..ad72dbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ frame-system = { git = "https://github.com/subspace/polkadot-sdk", rev = "0cbfcb fs4 = "0.8.4" futures = "0.3.30" futures-timer = "3.0.3" -gtk = { version = "0.7.3", package = "gtk4" } +gtk = { version = "0.8", package = "gtk4" } hex = "0.4.3" image = { version = "0.25.1", default-features = false, features = ["png"] } mimalloc = "0.1.41" @@ -61,9 +61,9 @@ open = "5.2.0" pallet-balances = { git = "https://github.com/subspace/polkadot-sdk", rev = "0cbfcb0232bbf71ac5b14cc8c99bf043cec420ef", default-features = false } parity-scale-codec = "3.6.12" parking_lot = "0.12.3" -relm4 = "0.7.0-rc.1" -relm4-components = { version = "0.7.0-rc.1", default-features = false } -relm4-icons = { version = "0.7.0-alpha.2", features = ["checkmark", "cross", "grid-filled", "menu-large", "pause", "processor", "puzzle-piece", "size-horizontally", "speedometer2", "speedometer3", "speedometer4", "ssd", "wallet2", "warning"] } +relm4 = "0.8.0" +relm4-components = { version = "0.8.0", default-features = false } +relm4-icons = { path = "../icons" } reqwest = { version = "0.12.4", default-features = false, features = ["json", "rustls-tls"] } sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "0cbfcb0232bbf71ac5b14cc8c99bf043cec420ef", default-features = false } sc-client-db = { git = "https://github.com/subspace/polkadot-sdk", rev = "0cbfcb0232bbf71ac5b14cc8c99bf043cec420ef", default-features = false } @@ -120,6 +120,9 @@ fluent-static-codegen = "0.3.0" [target.'cfg(windows)'.build-dependencies] winres = "0.1.12" +[build-dependencies] +relm4-icons = { path = "../icons", features = ["build-utils"] } + [features] default = ["numa"] numa = [ diff --git a/build.rs b/build.rs index da58113..cd10574 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,5 @@ use fluent_static_codegen::{generate, MessageBundleCodeGenerator}; +use relm4_icons::build_utils::Config; use std::path::Path; use std::{env, fs}; @@ -28,4 +29,14 @@ fn main() { res.set_icon("res\\windows\\space-acres.ico"); res.compile().unwrap(); } + + let manifest_path = std::env::var("CARGO_MANIFEST_DIR").unwrap(); + + let config = Config::load( + &manifest_path, + Some(relm4_icons::constants::SHIPPED_ICONS_PATH.to_string()), + ) + .expect("couldn't load manifest"); + + relm4_icons::build_utils::bundle_icons(config, &manifest_path); } diff --git a/icons.toml b/icons.toml new file mode 100644 index 0000000..f4a7469 --- /dev/null +++ b/icons.toml @@ -0,0 +1,4 @@ +# Icons configuration +app_id = "com.my.app" +base_resource_path = "/com/my/app/" +icons = ["ssd", "size-horizontally", "cross", "checkmark", "wallet2", "warning", "puzzle-piece", "grid", "pause", "menu-large", "processor"] \ No newline at end of file diff --git a/src/frontend/configuration.rs b/src/frontend/configuration.rs index ea5013f..09f81ce 100644 --- a/src/frontend/configuration.rs +++ b/src/frontend/configuration.rs @@ -7,13 +7,13 @@ use crate::frontend::configuration::farm::{ }; use crate::frontend::configuration::utils::is_directory_writable; use crate::frontend::translations::{AsDefaultStr, T}; +use crate::icon_names; use gtk::prelude::*; use relm4::factory::AsyncFactoryVecDeque; use relm4::prelude::*; use relm4_components::open_dialog::{ OpenDialog, OpenDialogMsg, OpenDialogResponse, OpenDialogSettings, }; -use relm4_icons::icon_name; use std::ops::Deref; use std::path::PathBuf; use subspace_farmer::utils::ss58::parse_ss58_reward_address; @@ -102,9 +102,9 @@ where fn icon(&self) -> Option<&'static str> { if self.is_valid { - Some(icon_name::CHECKMARK) + Some(icon_names::CHECKMARK) } else { - Some(icon_name::CROSS) + Some(icon_names::CROSS) } } } @@ -214,7 +214,7 @@ impl AsyncComponent for ConfigurationView { ) .as_str(), ), - set_primary_icon_name: Some(icon_name::SSD), + set_primary_icon_name: Some(&icon_names::SSD), set_primary_icon_activatable: false, set_primary_icon_sensitive: false, #[track = "model.node_path.changed_is_valid()"] diff --git a/src/frontend/configuration/farm.rs b/src/frontend/configuration/farm.rs index aebabd0..a0357f4 100644 --- a/src/frontend/configuration/farm.rs +++ b/src/frontend/configuration/farm.rs @@ -1,5 +1,6 @@ use crate::backend::config::{Farm, MIN_FARM_SIZE}; use crate::frontend::configuration::MaybeValid; +use crate::icon_names; use bytesize::ByteSize; use gtk::prelude::*; use std::fmt; @@ -154,7 +155,7 @@ impl AsyncFactoryComponent for FarmWidget { ) .as_str(), ), - set_primary_icon_name: Some(icon_name::SSD), + set_primary_icon_name: Some(&icon_names::SSD), set_primary_icon_activatable: false, set_primary_icon_sensitive: false, #[track = "self.path.changed_is_valid()"] diff --git a/src/frontend/running.rs b/src/frontend/running.rs index cb32c36..490a6a1 100644 --- a/src/frontend/running.rs +++ b/src/frontend/running.rs @@ -11,6 +11,7 @@ use crate::frontend::translations::{AsDefaultStr, T}; use crate::frontend::widgets::progress_circle::{ ProgressCircle, ProgressCircleInit, ProgressCircleInput, }; +use crate::icon_names; use gtk::prelude::*; use relm4::factory::FactoryHashMap; use relm4::prelude::*; @@ -123,7 +124,7 @@ impl Component for RunningView { connect_clicked => RunningInput::ToggleFarmDetails, set_cursor_from_name: Some("pointer"), set_has_frame: false, - set_icon_name: icon_name::GRID_FILLED, + set_icon_name: icon_names::GRID_FILLED, set_tooltip: &T.running_farmer_button_expand_details(), }, gtk::ToggleButton { @@ -131,7 +132,7 @@ impl Component for RunningView { set_active: model.plotting_paused, set_cursor_from_name: Some("pointer"), set_has_frame: false, - set_icon_name: icon_name::PAUSE, + set_icon_name: icon_names::PAUSE, set_tooltip: &T.running_farmer_button_pause_plotting(), }, }, diff --git a/src/frontend/running/farm.rs b/src/frontend/running/farm.rs index a412313..6ce31b4 100644 --- a/src/frontend/running/farm.rs +++ b/src/frontend/running/farm.rs @@ -1,9 +1,9 @@ use crate::backend::farmer::DiskFarm; use crate::frontend::translations::{AsDefaultStr, T}; +use crate::icon_names; use bytesize::ByteSize; use gtk::prelude::*; use relm4::prelude::*; -use relm4_icons::icon_name; use simple_moving_average::{SingleSumSMA, SMA}; use std::collections::HashMap; use std::path::PathBuf; @@ -175,7 +175,7 @@ impl FactoryComponent for FarmWidget { set_hexpand: true, gtk::Image { - set_icon_name: Some(icon_name::WARNING), + set_icon_name: Some(&icon_names::WARNING), } }, None => { diff --git a/src/frontend/running/node.rs b/src/frontend/running/node.rs index dd1fcaa..b4e38cf 100644 --- a/src/frontend/running/node.rs +++ b/src/frontend/running/node.rs @@ -1,12 +1,12 @@ use crate::backend::node::{ChainInfo, SyncState}; use crate::backend::NodeNotification; use crate::frontend::translations::{AsDefaultStr, T}; +use crate::icon_names; use bytesize::ByteSize; use gtk::prelude::*; use parking_lot::Mutex; use relm4::prelude::*; use relm4::{Sender, ShutdownReceiver}; -use relm4_icons::icon_name; use simple_moving_average::{SingleSumSMA, SMA}; use std::path::PathBuf; use std::sync::Arc; @@ -103,7 +103,7 @@ impl Component for NodeView { .unwrap_or_default(), gtk::Image { - set_icon_name: Some(icon_name::SSD), + set_icon_name: Some(&icon_names::SSD), }, gtk::LevelBar { diff --git a/src/main.rs b/src/main.rs index 9c3cddd..3fe9ec1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,8 +20,9 @@ use file_rotate::suffix::AppendCount; use file_rotate::{ContentLimit, FileRotate}; use futures::channel::mpsc; use relm4::prelude::*; -use relm4::RELM_THREADS; +use relm4::{Sender, ShutdownReceiver, RELM_THREADS}; use std::cell::Cell; +use std::future::Future; use std::io::{Read, Write}; use std::path::{Path, PathBuf}; use std::process::{ExitCode, Termination}; @@ -38,6 +39,9 @@ use tracing_subscriber::EnvFilter; #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +mod icon_names { + include!(concat!(env!("OUT_DIR"), "/icon_names.rs")); +} /// Number of log files to keep const LOG_FILE_LIMIT_COUNT: usize = 5; @@ -224,7 +228,7 @@ impl Cli { }); app.set_global_css(GLOBAL_CSS); - relm4_icons::initialize_icons(); + relm4_icons::initialize_icons!(icon_names::BASE_RESOURCE_PATH, icon_names::APP_ID); // Prefer dark theme in cross-platform way if environment is configured that way if let Some(settings) = gtk::Settings::default() {