From b9c874ab8cb99523c0e9f2a6e6778ddf4f6c0821 Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Sun, 23 Jun 2024 14:59:26 +0200 Subject: [PATCH] Update build system and Flatpak manifest --- data/de.johrpan.Musicus.desktop.in.in | 11 +++ data/de.johrpan.Musicus.gschema.xml.in | 36 +++++++++ data/de.johrpan.Musicus.service.in | 3 + data/de.johrpan.musicus.appdata.xml.in | 9 --- data/de.johrpan.musicus.desktop.in | 8 -- data/de.johrpan.musicus.gschema.xml | 36 --------- .../apps/de.johrpan.Musicus.Devel.svg | 81 +++++++++++++++++++ ...pan.musicus.svg => de.johrpan.Musicus.svg} | 0 ...ic.svg => de.johrpan.Musicus-symbolic.svg} | 0 data/icons/meson.build | 15 ++-- data/meson.build | 65 ++++++++++----- ...ml => de.johrpan.Musicus.gresource.xml.in} | 2 +- data/res/meson.build | 17 ++-- data/ui/welcome_page.blp | 2 +- ...icus.json => de.johrpan.Musicus.Devel.json | 15 ++-- meson.build | 27 +++++-- meson_options.txt | 9 +++ po/POTFILES | 6 +- po/meson.build | 2 +- src/application.rs | 15 ++-- src/config.rs.in | 8 +- src/home_page.rs | 21 ++--- src/main.rs | 29 ++++--- src/meson.build | 28 ++++--- src/player.rs | 7 +- src/window.rs | 25 +++--- 26 files changed, 317 insertions(+), 160 deletions(-) create mode 100644 data/de.johrpan.Musicus.desktop.in.in create mode 100644 data/de.johrpan.Musicus.gschema.xml.in create mode 100644 data/de.johrpan.Musicus.service.in delete mode 100644 data/de.johrpan.musicus.appdata.xml.in delete mode 100644 data/de.johrpan.musicus.desktop.in delete mode 100644 data/de.johrpan.musicus.gschema.xml create mode 100644 data/icons/hicolor/scalable/apps/de.johrpan.Musicus.Devel.svg rename data/icons/hicolor/scalable/apps/{de.johrpan.musicus.svg => de.johrpan.Musicus.svg} (100%) rename data/icons/hicolor/symbolic/apps/{de.johrpan.musicus-symbolic.svg => de.johrpan.Musicus-symbolic.svg} (100%) rename data/res/{musicus.gresource.xml => de.johrpan.Musicus.gresource.xml.in} (83%) rename de.johrpan.musicus.json => de.johrpan.Musicus.Devel.json (84%) create mode 100644 meson_options.txt diff --git a/data/de.johrpan.Musicus.desktop.in.in b/data/de.johrpan.Musicus.desktop.in.in new file mode 100644 index 0000000..d07ed92 --- /dev/null +++ b/data/de.johrpan.Musicus.desktop.in.in @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=@NAME@ +Icon=@APP_ID@ +Exec=@PKGNAME@ +Terminal=false +Type=Application +Categories=GNOME;GTK;Audio;AudioVideo;Music;Player +# Translators: Search terms to find this application. The list must be separated and terminated by semicolons. +Keywords=Music;Player;Library; +StartupNotify=true +DBusActivatable=true diff --git a/data/de.johrpan.Musicus.gschema.xml.in b/data/de.johrpan.Musicus.gschema.xml.in new file mode 100644 index 0000000..b4e76f5 --- /dev/null +++ b/data/de.johrpan.Musicus.gschema.xml.in @@ -0,0 +1,36 @@ + + + + + 800 + Window width + + + 600 + Window height + + + false + Window maximized state + + + '' + Path to the music library + + + + '{"title":"Just play some music","description":"Randomly select some music. Customize programs using the button in the top right.","design":"Program1","prefer_recently_added":0.0,"prefer_least_recently_played":0.1,"play_full_recordings":true}' + Default settings for program 1 + + + + '{"title":"What\'s new?","description":"Recordings that you recently added to your music library.","design":"Program2","prefer_recently_added":1.0,"prefer_least_recently_played":0.0,"play_full_recordings":true}' + Default settings for program 2 + + + + '{"title":"A long time ago","description":"Works that you haven\'t listend to for a long time.","design":"Program3","prefer_recently_added":0.0,"prefer_least_recently_played":1.0,"play_full_recordings":true}' + Default settings for program 3 + + + diff --git a/data/de.johrpan.Musicus.service.in b/data/de.johrpan.Musicus.service.in new file mode 100644 index 0000000..b76ba84 --- /dev/null +++ b/data/de.johrpan.Musicus.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=@APP_ID@ +Exec=@BINDIR@/@PKGNAME@ --gapplication-service \ No newline at end of file diff --git a/data/de.johrpan.musicus.appdata.xml.in b/data/de.johrpan.musicus.appdata.xml.in deleted file mode 100644 index fc977ec..0000000 --- a/data/de.johrpan.musicus.appdata.xml.in +++ /dev/null @@ -1,9 +0,0 @@ - - - de.johrpan.musicus.desktop - CC0-1.0 - GPL-3.0-or-later - -

No description

-
-
diff --git a/data/de.johrpan.musicus.desktop.in b/data/de.johrpan.musicus.desktop.in deleted file mode 100644 index ee4bf1c..0000000 --- a/data/de.johrpan.musicus.desktop.in +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -Name=Musicus -Exec=musicus -Icon=de.johrpan.musicus -Terminal=false -Type=Application -Categories=GTK; -StartupNotify=true diff --git a/data/de.johrpan.musicus.gschema.xml b/data/de.johrpan.musicus.gschema.xml deleted file mode 100644 index ea75434..0000000 --- a/data/de.johrpan.musicus.gschema.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - 800 - Window width - - - 600 - Window height - - - false - Window maximized state - - - '' - Path to the music library - - - - '{"title":"Just play some music","description":"Randomly select some music. Customize programs using the button in the top right.","design":"Program1","prefer_recently_added":0.0,"prefer_least_recently_played":0.1,"play_full_recordings":true}' - Default settings for program 1 - - - - '{"title":"What\'s new?","description":"Recordings that you recently added to your music library.","design":"Program2","prefer_recently_added":1.0,"prefer_least_recently_played":0.0,"play_full_recordings":true}' - Default settings for program 2 - - - - '{"title":"A long time ago","description":"Works that you haven\'t listend to for a long time.","design":"Program3","prefer_recently_added":0.0,"prefer_least_recently_played":1.0,"play_full_recordings":false}' - Default settings for program 3 - - - diff --git a/data/icons/hicolor/scalable/apps/de.johrpan.Musicus.Devel.svg b/data/icons/hicolor/scalable/apps/de.johrpan.Musicus.Devel.svg new file mode 100644 index 0000000..cfe00be --- /dev/null +++ b/data/icons/hicolor/scalable/apps/de.johrpan.Musicus.Devel.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/icons/hicolor/scalable/apps/de.johrpan.musicus.svg b/data/icons/hicolor/scalable/apps/de.johrpan.Musicus.svg similarity index 100% rename from data/icons/hicolor/scalable/apps/de.johrpan.musicus.svg rename to data/icons/hicolor/scalable/apps/de.johrpan.Musicus.svg diff --git a/data/icons/hicolor/symbolic/apps/de.johrpan.musicus-symbolic.svg b/data/icons/hicolor/symbolic/apps/de.johrpan.Musicus-symbolic.svg similarity index 100% rename from data/icons/hicolor/symbolic/apps/de.johrpan.musicus-symbolic.svg rename to data/icons/hicolor/symbolic/apps/de.johrpan.Musicus-symbolic.svg diff --git a/data/icons/meson.build b/data/icons/meson.build index 12e3055..b192d83 100644 --- a/data/icons/meson.build +++ b/data/icons/meson.build @@ -1,13 +1,12 @@ -application_id = 'de.johrpan.musicus' - -scalable_dir = join_paths('hicolor', 'scalable', 'apps') +scalable_dir = 'hicolor' / 'scalable' / 'apps' install_data( - join_paths(scalable_dir, ('@0@.svg').format(application_id)), - install_dir: join_paths(get_option('datadir'), 'icons', scalable_dir) + scalable_dir / '@0@.svg'.format(app_id), + install_dir: datadir / 'icons' / scalable_dir, ) -symbolic_dir = join_paths('hicolor', 'symbolic', 'apps') +symbolic_dir = 'hicolor' / 'symbolic' / 'apps' install_data( - join_paths(symbolic_dir, ('@0@-symbolic.svg').format(application_id)), - install_dir: join_paths(get_option('datadir'), 'icons', symbolic_dir) + symbolic_dir / '@0@-symbolic.svg'.format(base_id), + install_dir: datadir / 'icons' / symbolic_dir, + rename: '@0@-symbolic.svg'.format(app_id), ) diff --git a/data/meson.build b/data/meson.build index 8268f86..1d65e7e 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,10 +1,21 @@ +# Desktop file + +conf = configuration_data() +conf.set('NAME', name) +conf.set('APP_ID', app_id) +conf.set('PKGNAME', meson.project_name()) + desktop_file = i18n.merge_file( - input: 'de.johrpan.musicus.desktop.in', - output: 'de.johrpan.musicus.desktop', - type: 'desktop', - po_dir: '../po', - install: true, - install_dir: join_paths(get_option('datadir'), 'applications') + input: configure_file( + input: '@0@.desktop.in.in'.format(base_id), + output: '@0@.desktop.in'.format(app_id), + configuration: conf, + ), + output: '@0@.desktop'.format(app_id), + type: 'desktop', + po_dir: '../po', + install: true, + install_dir: datadir / 'applications', ) desktop_utils = find_program('desktop-file-validate', required: false) @@ -12,29 +23,39 @@ if desktop_utils.found() test('Validate desktop file', desktop_utils, args: [desktop_file]) endif -appstream_file = i18n.merge_file( - input: 'de.johrpan.musicus.appdata.xml.in', - output: 'de.johrpan.musicus.appdata.xml', - po_dir: '../po', - install: true, - install_dir: join_paths(get_option('datadir'), 'appdata') -) +# Settings -appstream_util = find_program('appstream-util', required: false) -if appstream_util.found() - test('Validate appstream file', appstream_util, args: ['validate', appstream_file]) -endif +conf = configuration_data() +conf.set('APP_ID', app_id) +conf.set('PATH_ID', path_id) +conf.set('PKGNAME', meson.project_name()) -install_data('de.johrpan.musicus.gschema.xml', - install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas') +configure_file( + input: '@0@.gschema.xml.in'.format(base_id), + output: '@0@.gschema.xml'.format(app_id), + configuration: conf, + install: true, + install_dir: datadir / 'glib-2.0' / 'schemas', ) compile_schemas = find_program('glib-compile-schemas', required: false) if compile_schemas.found() - test('Validate schema file', - compile_schemas, - args: ['--strict', '--dry-run', meson.current_source_dir()]) + test('Validate schema file', compile_schemas, args: ['--strict', '--dry-run', meson.current_source_dir()]) endif +# DBus service + +conf = configuration_data() +conf.set('APP_ID', app_id) +conf.set('BINDIR', bindir) +conf.set('PKGNAME', meson.project_name()) + +configure_file( + input: '@0@.service.in'.format(base_id), + output: '@0@.service'.format(app_id), + configuration: conf, + install_dir: datadir / 'dbus-1' / 'services', +) + subdir('icons') subdir('res') diff --git a/data/res/musicus.gresource.xml b/data/res/de.johrpan.Musicus.gresource.xml.in similarity index 83% rename from data/res/musicus.gresource.xml rename to data/res/de.johrpan.Musicus.gresource.xml.in index 987ec29..de0838a 100644 --- a/data/res/musicus.gresource.xml +++ b/data/res/de.johrpan.Musicus.gresource.xml.in @@ -1,6 +1,6 @@ - + icons/scalable/actions/playlist-symbolic.svg style.css diff --git a/data/res/meson.build b/data/res/meson.build index 643e53d..1b931d0 100644 --- a/data/res/meson.build +++ b/data/res/meson.build @@ -1,9 +1,16 @@ -pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) -gnome = import('gnome') +conf = configuration_data() +conf.set('PATH_ID', path_id) -gnome.compile_resources('musicus', - 'musicus.gresource.xml', +configure_file( + input: '@0@.gresource.xml.in'.format(base_id), + output: '@0@.gresource.xml'.format(app_id), + configuration: conf, +) + +gnome.compile_resources( + app_id, + meson.project_build_root() / 'data' / 'res'/ '@0@.gresource.xml'.format(app_id), gresource_bundle: true, install: true, - install_dir: pkgdatadir, + install_dir: datadir / meson.project_name(), ) \ No newline at end of file diff --git a/data/ui/welcome_page.blp b/data/ui/welcome_page.blp index dffc4f9..6e3e67c 100644 --- a/data/ui/welcome_page.blp +++ b/data/ui/welcome_page.blp @@ -16,7 +16,7 @@ template $MusicusWelcomePage : Adw.NavigationPage { } Adw.StatusPage { - icon-name: "de.johrpan.musicus"; + icon-name: "de.johrpan.Musicus"; title: _("Welcome to Musicus"); description: _("Get started by choosing where to store your music library. Is this your first time using Musicus? If so, create a new empty folder for your library. Musicus will use this location to manage your recordings. You can also select a folder that already contains a music library created by Musicus."); child: Gtk.Button { diff --git a/de.johrpan.musicus.json b/de.johrpan.Musicus.Devel.json similarity index 84% rename from de.johrpan.musicus.json rename to de.johrpan.Musicus.Devel.json index 7fec270..f3dfb23 100644 --- a/de.johrpan.musicus.json +++ b/de.johrpan.Musicus.Devel.json @@ -1,5 +1,5 @@ { - "id": "de.johrpan.musicus", + "id": "de.johrpan.Musicus.Devel", "runtime": "org.gnome.Platform", "runtime-version": "master", "sdk": "org.gnome.Sdk", @@ -9,18 +9,14 @@ ], "command": "musicus", "finish-args": [ - "--share=network", "--share=ipc", "--socket=fallback-x11", "--socket=wayland", "--socket=pulseaudio", "--device=dri", - "--filesystem=host", - "--talk-name=org.mpris.MediaPlayer2.Player", - "--own-name=org.mpris.MediaPlayer2.de.johrpan.musicus", "--env=RUST_LOG=musicus=debug", - "--env=G_MESSAGES_DEBUG=none", - "--env=RUST_BACKTRACE=1" + "--env=RUST_BACKTRACE=1", + "--env=G_MESSAGES_DEBUG=none" ], "build-options": { "append-path": "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm16/bin", @@ -48,6 +44,9 @@ { "name": "musicus", "buildsystem": "meson", + "config-opts": [ + "-Dprofile=development" + ], "sources": [ { "type": "dir", @@ -56,4 +55,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/meson.build b/meson.build index 6650386..449be6a 100644 --- a/meson.build +++ b/meson.build @@ -1,20 +1,35 @@ -project('musicus', 'rust', - version: '0.1.0', - meson_version: '>= 0.62.0', - default_options: [ 'warning_level=2', 'werror=false', ], +project( + 'musicus', + 'rust', + version: '0.1.0', + meson_version: '>= 0.62.0', ) i18n = import('i18n') gnome = import('gnome') +# TODO: Add dependency checks for required shared libraries like SQLite, +# GStreamer (including plugins), Gtk, Libadwaita etc. +name = 'Musicus' +base_id = 'de.johrpan.Musicus' +app_id = base_id +path_id = '/de/johrpan/Musicus' +profile = get_option('profile') +datadir = get_option('prefix') / get_option('datadir') +localedir = get_option('prefix') / get_option('localedir') +bindir = get_option('prefix') / get_option('bindir') + +if profile == 'development' + app_id = '@0@.Devel'.format(app_id) +endif subdir('data') subdir('src') subdir('po') gnome.post_install( - glib_compile_schemas: true, - gtk_update_icon_cache: true, + glib_compile_schemas: true, + gtk_update_icon_cache: true, update_desktop_database: true, ) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..b7f0dab --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,9 @@ +option( + 'profile', + type: 'combo', + choices: [ + 'release', + 'development' + ], + value: 'release', +) diff --git a/po/POTFILES b/po/POTFILES index 48e7687..bb1a88e 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -1,3 +1,4 @@ +# TODO: Update for first release. data/ui/home_page.blp data/ui/library_manager.blp data/ui/player_bar.blp @@ -9,7 +10,6 @@ data/ui/search_tag.blp data/ui/tag_tile.blp data/ui/welcome_page.blp data/ui/window.blp -data/de.johrpan.musicus.desktop.in -data/de.johrpan.musicus.appdata.xml.in -data/de.johrpan.musicus.gschema.xml +data/de.johrpan.Musicus.desktop.in.in +data/de.johrpan.Musicus.gschema.xml.in src/application.rs diff --git a/po/meson.build b/po/meson.build index 38f16f1..e9b77d7 100644 --- a/po/meson.build +++ b/po/meson.build @@ -1 +1 @@ -i18n.gettext('musicus', preset: 'glib') +i18n.gettext(meson.project_name(), preset: 'glib') diff --git a/src/application.rs b/src/application.rs index 40db672..96b6a18 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,8 +1,9 @@ -use crate::{config::VERSION, MusicusWindow}; use adw::subclass::prelude::*; use gettextrs::gettext; use gtk::{gio, glib, prelude::*}; +use crate::{config, MusicusWindow}; + mod imp { use super::*; @@ -51,10 +52,10 @@ glib::wrapper! { } impl MusicusApplication { - pub fn new(application_id: &str, flags: &gio::ApplicationFlags) -> Self { + pub fn new() -> Self { glib::Object::builder() - .property("application-id", application_id) - .property("flags", flags) + .property("application-id", config::APP_ID) + .property("resource-base-path", config::PATH_ID) .build() } @@ -74,10 +75,10 @@ impl MusicusApplication { let window = self.active_window().unwrap(); let about = adw::AboutWindow::builder() .transient_for(&window) - .application_name(gettext("Musicus")) - .application_icon("de.johrpan.musicus") + .application_name(gettext(config::NAME)) + .application_icon(config::APP_ID) .developer_name("Elias Projahn") - .version(VERSION) + .version(config::VERSION) .website("https://code.johrpan.de/johrpan/musicus") .developers(vec!["Elias Projahn "]) .copyright("© 2023 Elias Projahn") diff --git a/src/config.rs.in b/src/config.rs.in index 1a24858..9fd5512 100644 --- a/src/config.rs.in +++ b/src/config.rs.in @@ -1,4 +1,8 @@ +pub static NAME: &str = @NAME@; +pub static PKGNAME: &str = @PKGNAME@; +pub static APP_ID: &str = @APP_ID@; +pub static PATH_ID: &str = @PATH_ID@; pub static VERSION: &str = @VERSION@; -pub static GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@; +pub static PROFILE: &str = @PROFILE@; pub static LOCALEDIR: &str = @LOCALEDIR@; -pub static PKGDATADIR: &str = @PKGDATADIR@; +pub static DATADIR: &str = @DATADIR@; diff --git a/src/home_page.rs b/src/home_page.rs index 75574e0..836bf5d 100644 --- a/src/home_page.rs +++ b/src/home_page.rs @@ -1,5 +1,15 @@ +use std::cell::{OnceCell, RefCell}; + +use adw::subclass::{navigation_page::NavigationPageImpl, prelude::*}; +use gtk::{ + gio, + glib::{self, clone, Properties}, + prelude::*, +}; + use crate::{ album_tile::MusicusAlbumTile, + config, db::models::*, editor::{person_editor::MusicusPersonEditor, work_editor::MusicusWorkEditor}, library::{LibraryQuery, MusicusLibrary}, @@ -12,15 +22,6 @@ use crate::{ tag_tile::MusicusTagTile, }; -use adw::subclass::{navigation_page::NavigationPageImpl, prelude::*}; -use gtk::{ - gio, - glib::{self, clone, Properties}, - prelude::*, -}; - -use std::cell::{OnceCell, RefCell}; - mod imp { use super::*; @@ -109,7 +110,7 @@ mod imp { .sync_create() .build(); - let settings = gio::Settings::new("de.johrpan.musicus"); + let settings = gio::Settings::new(&config::APP_ID); let programs = vec![ Program::deserialize(&settings.string("program1")).unwrap(), diff --git a/src/main.rs b/src/main.rs index 6806c37..e019fae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,24 +22,31 @@ mod welcome_page; mod window; use self::{application::MusicusApplication, window::MusicusWindow}; - -use config::{GETTEXT_PACKAGE, LOCALEDIR, PKGDATADIR}; -use gettextrs::{bind_textdomain_codeset, bindtextdomain, textdomain}; +use gettextrs::LocaleCategory; use gstreamer_play::gst; use gtk::{gio, glib, prelude::*}; fn main() -> glib::ExitCode { tracing_subscriber::fmt::init(); + gtk::init().expect("Failed to initialize GTK!"); gst::init().expect("Failed to initialize GStreamer!"); - bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain"); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8") - .expect("Unable to set the text domain encoding"); - textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain"); + glib::set_application_name(config::NAME); + gtk::Window::set_default_icon_name(config::APP_ID); - let resources = gio::Resource::load(PKGDATADIR.to_owned() + "/musicus.gresource") - .expect("Could not load resources"); - gio::resources_register(&resources); + gettextrs::setlocale(LocaleCategory::LcAll, ""); + gettextrs::bindtextdomain(config::PKGNAME, config::LOCALEDIR).unwrap(); + gettextrs::textdomain(config::PKGNAME).unwrap(); - MusicusApplication::new("de.johrpan.musicus", &gio::ApplicationFlags::empty()).run() + gio::resources_register( + &gio::Resource::load(&format!( + "{}/{}/{}.gresource", + config::DATADIR, + config::PKGNAME, + config::APP_ID + )) + .expect("Could not load resources"), + ); + + MusicusApplication::new().run() } diff --git a/src/meson.build b/src/meson.build index d5e8771..08fe5ac 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,35 +1,43 @@ -pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) +# Configuration file conf = configuration_data() +conf.set_quoted('NAME', name) +conf.set_quoted('PKGNAME', meson.project_name()) +conf.set_quoted('APP_ID', app_id) +conf.set_quoted('PATH_ID', path_id) conf.set_quoted('VERSION', meson.project_version()) -conf.set_quoted('GETTEXT_PACKAGE', 'musicus') -conf.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir'))) -conf.set_quoted('PKGDATADIR', pkgdatadir) +conf.set_quoted('PROFILE', profile) +conf.set_quoted('LOCALEDIR', localedir) +conf.set_quoted('DATADIR', datadir) configure_file( input: 'config.rs.in', output: 'config.rs', - configuration: conf + configuration: conf, ) # Copy the config.rs output to the source directory. run_command( 'cp', - join_paths(meson.project_build_root(), 'src', 'config.rs'), - join_paths(meson.project_source_root(), 'src', 'config.rs'), + meson.project_build_root() / 'src' / 'config.rs', + meson.project_source_root() / 'src' / 'config.rs', check: true ) +# Cargo + cargo_bin = find_program('cargo') cargo_opt = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ] cargo_opt += [ '--target-dir', meson.project_build_root() / 'src' ] cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] -if get_option('buildtype') == 'release' +if get_option('profile') == 'release' cargo_options += [ '--release' ] rust_target = 'release' + message('Building in release mode') else rust_target = 'debug' + message('Building in debug mode') endif cargo_build = custom_target( @@ -39,10 +47,10 @@ cargo_build = custom_target( output: meson.project_name(), console: true, install: true, - install_dir: get_option('bindir'), + install_dir: bindir, command: [ 'env', cargo_env, cargo_bin, 'build', cargo_opt, '&&', 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@', - ] + ], ) diff --git a/src/player.rs b/src/player.rs index d047db0..9a219bf 100644 --- a/src/player.rs +++ b/src/player.rs @@ -15,6 +15,7 @@ use mpris_player::{Metadata, MprisPlayer, PlaybackStatus}; use once_cell::sync::Lazy; use crate::{ + config, db::models::{Recording, Track}, library::MusicusLibrary, playlist_item::PlaylistItem, @@ -122,9 +123,9 @@ mod imp { let play = gstreamer_play::Play::new(None::); let mpris = MprisPlayer::new( - "de.johrpan.musicus".to_string(), - "Musicus".to_string(), - "de.johrpan.musicus.desktop".to_string(), + config::APP_ID.to_owned(), + config::NAME.to_owned(), + config::APP_ID.to_owned(), ); mpris.set_can_raise(true); diff --git a/src/window.rs b/src/window.rs index 7b14942..d9255a9 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,11 +1,13 @@ +use std::path::Path; + +use adw::subclass::prelude::*; +use gtk::{gio, glib, glib::clone, prelude::*}; + use crate::{ - home_page::MusicusHomePage, library::MusicusLibrary, library_manager::LibraryManager, + config, home_page::MusicusHomePage, library::MusicusLibrary, library_manager::LibraryManager, player::MusicusPlayer, player_bar::PlayerBar, playlist_page::MusicusPlaylistPage, welcome_page::MusicusWelcomePage, }; -use adw::subclass::prelude::*; -use gtk::{gio, glib, glib::clone, prelude::*}; -use std::path::Path; mod imp { use super::*; @@ -45,6 +47,10 @@ mod imp { self.parent_constructed(); self.obj().load_window_state(); + if config::PROFILE == "development" { + self.obj().add_css_class("devel"); + } + let navigation_view = self.navigation_view.get().to_owned(); let library_action = gio::ActionEntry::builder("library") .activate(move |_: &super::MusicusWindow, _, _| { @@ -85,7 +91,7 @@ mod imp { let obj = self.obj().to_owned(); self.player.connect_raise(move |_| obj.present()); - let settings = gio::Settings::new("de.johrpan.musicus"); + let settings = gio::Settings::new(config::APP_ID); let library_path = settings.string("library-path").to_string(); if !library_path.is_empty() { self.obj().load_library(&library_path); @@ -124,13 +130,13 @@ impl MusicusWindow { } pub fn load_window_state(&self) { - let settings = gio::Settings::new("de.johrpan.musicus"); + let settings = gio::Settings::new(config::APP_ID); self.set_default_size(settings.int("window-width"), settings.int("window-height")); self.set_property("maximized", settings.boolean("is-maximized")); } pub fn save_window_state(&self) -> Result<(), glib::BoolError> { - let settings = gio::Settings::new("de.johrpan.musicus"); + let settings = gio::Settings::new(config::APP_ID); let size = self.default_size(); settings.set_int("window-width", size.0)?; @@ -144,7 +150,7 @@ impl MusicusWindow { fn set_library_folder(&self, folder: &gio::File) { let path = folder.path().unwrap(); - let settings = gio::Settings::new("de.johrpan.musicus"); + let settings = gio::Settings::new(config::APP_ID); settings .set_string("library-path", path.to_str().unwrap()) .unwrap(); @@ -157,7 +163,8 @@ impl MusicusWindow { self.imp().player.set_library(&library); let navigation = self.imp().navigation_view.get(); - navigation.replace(&[MusicusHomePage::new(&navigation, &library, &self.imp().player).into()]); + navigation + .replace(&[MusicusHomePage::new(&navigation, &library, &self.imp().player).into()]); navigation.add(&LibraryManager::new(&library)); } }