From 41c2a9c1fcafc11c6a231742e86dec1fbc910305 Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Fri, 9 May 2025 13:25:14 +0200 Subject: [PATCH 1/6] Use LazyLock instead of lazy_static --- Cargo.lock | 1 - Cargo.toml | 1 - src/util.rs | 27 +++++++++++++-------------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b78e6d8..2c4e493 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1880,7 +1880,6 @@ dependencies = [ "glib", "gstreamer-play", "gtk4", - "lazy_static", "libadwaita", "log", "mpris-server", diff --git a/Cargo.toml b/Cargo.toml index 4f0b267..ac6b612 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ gettext-rs = { version = "0.7", features = ["gettext-system"] } glib = { version = "0.20", features = ["v2_84"] } gstreamer-play = "0.23" gtk = { package = "gtk4", version = "0.9", features = ["v4_18", "blueprint"] } -lazy_static = "1" log = "0.4" mpris-server = "0.8" once_cell = "1" diff --git a/src/util.rs b/src/util.rs index 6358704..ecf9f07 100644 --- a/src/util.rs +++ b/src/util.rs @@ -2,27 +2,26 @@ pub mod activatable_row; pub mod drag_widget; pub mod error_dialog; +use std::sync::LazyLock; + use gettextrs::gettext; use gtk::glib::{self, clone}; -use lazy_static::lazy_static; use error_dialog::ErrorDialog; -lazy_static! { - /// The user's language code. - pub static ref LANG: String = { - let lang = match glib::language_names().first() { - Some(language_name) => match language_name.split('_').next() { - Some(lang) => lang.to_string(), - None => "generic".to_string(), - }, +/// The user's language code. +pub static LANG: LazyLock = LazyLock::new(|| { + let lang = match glib::language_names().first() { + Some(language_name) => match language_name.split('_').next() { + Some(lang) => lang.to_string(), None => "generic".to_string(), - }; - - log::info!("Intialized user language to '{lang}'."); - lang + }, + None => "generic".to_string(), }; -} + + log::info!("Intialized user language to '{lang}'."); + lang +}); /// 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) { From 8903ce7d2c88ddfa08bc1d3491650c00d537387b Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Tue, 13 May 2025 09:29:52 +0200 Subject: [PATCH 2/6] flatpak: Remove bluprint-compiler from devel It is now included in the GNOME SDK. --- flatpak/de.johrpan.Musicus.Devel.json | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/flatpak/de.johrpan.Musicus.Devel.json b/flatpak/de.johrpan.Musicus.Devel.json index 07cabd6..8e77a87 100644 --- a/flatpak/de.johrpan.Musicus.Devel.json +++ b/flatpak/de.johrpan.Musicus.Devel.json @@ -31,17 +31,6 @@ } }, "modules": [ - { - "name": "blueprint-compiler", - "buildsystem": "meson", - "sources": [ - { - "type": "git", - "url": "https://gitlab.gnome.org/jwestman/blueprint-compiler.git", - "tag": "v0.16.0" - } - ] - }, { "name": "musicus", "buildsystem": "meson", From 5917b0ac368abaf10e6be94a266482e390673411 Mon Sep 17 00:00:00 2001 From: lo <115636509+lo2dev@users.noreply.github.com> Date: Fri, 16 May 2025 10:19:50 +0300 Subject: [PATCH 3/6] Make search entry rounded --- data/res/style.css | 8 ++++++++ data/ui/search_page.blp | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/data/res/style.css b/data/res/style.css index 316dcd4..b3ebbf3 100644 --- a/data/res/style.css +++ b/data/res/style.css @@ -6,6 +6,14 @@ font-size: smaller; } +.rounded-entry { + border-radius: 999px; + padding-left: 12px; + padding-right: 12px; + padding-top: 3px; + padding-bottom: 3px; +} + .searchbar .searchtag { background-color: alpha(currentColor, 0.1); border-radius: 100px; diff --git a/data/ui/search_page.blp b/data/ui/search_page.blp index 9c42770..01d7b0d 100644 --- a/data/ui/search_page.blp +++ b/data/ui/search_page.blp @@ -74,10 +74,16 @@ template $MusicusSearchPage: Adw.NavigationPage { } } - Gtk.SearchEntry search_entry { - placeholder-text: _("Enter composers, performers, works…"); - margin-top: 24; - activate => $select() swapped; + Adw.Clamp { + Gtk.SearchEntry search_entry { + placeholder-text: _("Enter composers, performers, works…"); + margin-top: 24; + activate => $select() swapped; + + styles [ + "rounded-entry" + ] + } } Gtk.Stack stack { From 1252ca0a1b261a9b3182cdfbcad97ad6ad45256c Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Fri, 30 May 2025 15:31:25 +0200 Subject: [PATCH 4/6] window: Inhibit system suspend during playback --- po/de.po | 16 ++++++++++------ po/template.pot | 16 ++++++++++------ src/window.rs | 25 ++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/po/de.po b/po/de.po index 57c58a9..f95d221 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-27 17:54+0200\n" +"POT-Creation-Date: 2025-05-30 15:27+0200\n" "PO-Revision-Date: 2025-04-27 18:23+0200\n" "Last-Translator: elias@johrpan.de\n" "Language-Team: German \n" @@ -818,7 +818,7 @@ msgstr "Bibliothek exportieren" msgid "Exporting music library to {}" msgstr "Bibliothek wird nach {} exportiert" -#: src/library_manager.rs:234 src/window.rs:282 +#: src/library_manager.rs:234 src/window.rs:305 msgid "Updating metadata" msgstr "Metadaten werden aktualisiert" @@ -826,19 +826,23 @@ msgstr "Metadaten werden aktualisiert" msgid "Updating music library" msgstr "Musikbibliothek wird aktualisiert" -#: src/window.rs:167 +#: src/window.rs:166 +msgid "Currently playing music" +msgstr "Musik wird abgespielt" + +#: src/window.rs:190 msgid "Close window?" msgstr "Fenster schließen?" -#: src/window.rs:169 +#: src/window.rs:192 msgid "There are ongoing processes that will be canceled." msgstr "Es gibt laufende Prozesse, die abgebrochen werden." -#: src/window.rs:174 +#: src/window.rs:197 msgid "Keep open" msgstr "Nicht schließen" -#: src/window.rs:175 +#: src/window.rs:198 msgid "Close window" msgstr "Fenster schließen" diff --git a/po/template.pot b/po/template.pot index 03c8554..e47fe6b 100644 --- a/po/template.pot +++ b/po/template.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-04-27 17:54+0200\n" +"POT-Creation-Date: 2025-05-30 15:27+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -784,7 +784,7 @@ msgstr "" msgid "Exporting music library to {}" msgstr "" -#: src/library_manager.rs:234 src/window.rs:282 +#: src/library_manager.rs:234 src/window.rs:305 msgid "Updating metadata" msgstr "" @@ -792,18 +792,22 @@ msgstr "" msgid "Updating music library" msgstr "" -#: src/window.rs:167 +#: src/window.rs:166 +msgid "Currently playing music" +msgstr "" + +#: src/window.rs:190 msgid "Close window?" msgstr "" -#: src/window.rs:169 +#: src/window.rs:192 msgid "There are ongoing processes that will be canceled." msgstr "" -#: src/window.rs:174 +#: src/window.rs:197 msgid "Keep open" msgstr "" -#: src/window.rs:175 +#: src/window.rs:198 msgid "Close window" msgstr "" diff --git a/src/window.rs b/src/window.rs index ce2f4ab..b263423 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,4 +1,7 @@ -use std::{cell::RefCell, path::Path}; +use std::{ + cell::{Cell, RefCell}, + path::Path, +}; use adw::{prelude::*, subclass::prelude::*}; use anyhow::{anyhow, Result}; @@ -31,6 +34,7 @@ mod imp { pub library: RefCell>, pub player: Player, pub process_manager: ProcessManager, + pub inhibitor_cookie: Cell>, #[template_child] pub toast_overlay: TemplateChild, @@ -148,6 +152,25 @@ mod imp { let obj = self.obj().to_owned(); self.player.connect_raise(move |_| obj.present()); + let obj = self.obj().to_owned(); + self.player.connect_playing_notify(move |player| { + if let Some(app) = obj.application() { + if let Some(cookie) = obj.imp().inhibitor_cookie.take() { + app.uninhibit(cookie); + }; + + if player.playing() { + let cookie = app.inhibit( + Some(&obj), + gtk::ApplicationInhibitFlags::SUSPEND, + Some(&gettext("Currently playing music")), + ); + + obj.imp().inhibitor_cookie.set(Some(cookie)); + } + } + }); + let settings = gio::Settings::new(config::APP_ID); let library_path = settings.string("library-path").to_string(); if !library_path.is_empty() { From 3c65905a3739d4c3c4874748fa3e71ae7eb2e4fb Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Sat, 9 Aug 2025 10:43:53 +0200 Subject: [PATCH 5/6] flatpak: Use LLVM 20 --- flatpak/de.johrpan.Musicus.Devel.json | 4 ++-- flatpak/de.johrpan.Musicus.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flatpak/de.johrpan.Musicus.Devel.json b/flatpak/de.johrpan.Musicus.Devel.json index 8e77a87..09a2fd1 100644 --- a/flatpak/de.johrpan.Musicus.Devel.json +++ b/flatpak/de.johrpan.Musicus.Devel.json @@ -5,7 +5,7 @@ "sdk": "org.gnome.Sdk", "sdk-extensions": [ "org.freedesktop.Sdk.Extension.rust-stable", - "org.freedesktop.Sdk.Extension.llvm18" + "org.freedesktop.Sdk.Extension.llvm20" ], "command": "musicus", "finish-args": [ @@ -20,7 +20,7 @@ "--env=G_MESSAGES_DEBUG=none" ], "build-options": { - "append-path": "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm18/bin", + "append-path": "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm20/bin", "build-args": [ "--share=network" ], diff --git a/flatpak/de.johrpan.Musicus.json b/flatpak/de.johrpan.Musicus.json index 3ddfaaa..7b12404 100644 --- a/flatpak/de.johrpan.Musicus.json +++ b/flatpak/de.johrpan.Musicus.json @@ -5,7 +5,7 @@ "sdk": "org.gnome.Sdk", "sdk-extensions": [ "org.freedesktop.Sdk.Extension.rust-stable", - "org.freedesktop.Sdk.Extension.llvm18" + "org.freedesktop.Sdk.Extension.llvm20" ], "command": "musicus", "finish-args": [ @@ -20,7 +20,7 @@ "--env=G_MESSAGES_DEBUG=none" ], "build-options": { - "append-path": "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm18/bin", + "append-path": "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm20/bin", "build-args": [ "--share=network" ], From 48cfdd354aeccf8ab14a2349345c9c2cfaa740c7 Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Sat, 9 Aug 2025 11:00:08 +0200 Subject: [PATCH 6/6] search page: Remove additional clamp for search entry --- data/ui/search_page.blp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/data/ui/search_page.blp b/data/ui/search_page.blp index 01d7b0d..24daf4d 100644 --- a/data/ui/search_page.blp +++ b/data/ui/search_page.blp @@ -73,17 +73,15 @@ template $MusicusSearchPage: Adw.NavigationPage { ] } } + + Gtk.SearchEntry search_entry { + placeholder-text: _("Enter composers, performers, works…"); + margin-top: 24; + activate => $select() swapped; - Adw.Clamp { - Gtk.SearchEntry search_entry { - placeholder-text: _("Enter composers, performers, works…"); - margin-top: 24; - activate => $select() swapped; - - styles [ - "rounded-entry" - ] - } + styles [ + "rounded-entry" + ] } Gtk.Stack stack {