mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 03:47:23 +01:00
Use LazyLock instead of lazy_static
This commit is contained in:
parent
3904b62c2c
commit
41c2a9c1fc
3 changed files with 13 additions and 16 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1880,7 +1880,6 @@ dependencies = [
|
||||||
"glib",
|
"glib",
|
||||||
"gstreamer-play",
|
"gstreamer-play",
|
||||||
"gtk4",
|
"gtk4",
|
||||||
"lazy_static",
|
|
||||||
"libadwaita",
|
"libadwaita",
|
||||||
"log",
|
"log",
|
||||||
"mpris-server",
|
"mpris-server",
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ gettext-rs = { version = "0.7", features = ["gettext-system"] }
|
||||||
glib = { version = "0.20", features = ["v2_84"] }
|
glib = { version = "0.20", features = ["v2_84"] }
|
||||||
gstreamer-play = "0.23"
|
gstreamer-play = "0.23"
|
||||||
gtk = { package = "gtk4", version = "0.9", features = ["v4_18", "blueprint"] }
|
gtk = { package = "gtk4", version = "0.9", features = ["v4_18", "blueprint"] }
|
||||||
lazy_static = "1"
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mpris-server = "0.8"
|
mpris-server = "0.8"
|
||||||
once_cell = "1"
|
once_cell = "1"
|
||||||
|
|
|
||||||
11
src/util.rs
11
src/util.rs
|
|
@ -2,15 +2,15 @@ pub mod activatable_row;
|
||||||
pub mod drag_widget;
|
pub mod drag_widget;
|
||||||
pub mod error_dialog;
|
pub mod error_dialog;
|
||||||
|
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use gettextrs::gettext;
|
use gettextrs::gettext;
|
||||||
use gtk::glib::{self, clone};
|
use gtk::glib::{self, clone};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
|
|
||||||
use error_dialog::ErrorDialog;
|
use error_dialog::ErrorDialog;
|
||||||
|
|
||||||
lazy_static! {
|
/// The user's language code.
|
||||||
/// The user's language code.
|
pub static LANG: LazyLock<String> = LazyLock::new(|| {
|
||||||
pub static ref LANG: String = {
|
|
||||||
let lang = match glib::language_names().first() {
|
let lang = match glib::language_names().first() {
|
||||||
Some(language_name) => match language_name.split('_').next() {
|
Some(language_name) => match language_name.split('_').next() {
|
||||||
Some(lang) => lang.to_string(),
|
Some(lang) => lang.to_string(),
|
||||||
|
|
@ -21,8 +21,7 @@ lazy_static! {
|
||||||
|
|
||||||
log::info!("Intialized user language to '{lang}'.");
|
log::info!("Intialized user language to '{lang}'.");
|
||||||
lang
|
lang
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
/// Create and show an error toast. This will also log the error to the console.
|
/// Create and show an error toast. This will also log the error to the console.
|
||||||
pub fn error_toast(msgid: &str, err: anyhow::Error, toast_overlay: &adw::ToastOverlay) {
|
pub fn error_toast(msgid: &str, err: anyhow::Error, toast_overlay: &adw::ToastOverlay) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue