Update build system and Flatpak manifest

This commit is contained in:
Elias Projahn 2024-06-23 14:59:26 +02:00
parent 1788303bf3
commit b9c874ab8c
26 changed files with 317 additions and 160 deletions

View file

@ -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

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="@APP_ID@" path="@PATH_ID@/" gettext-domain="@PKGNAME@">
<key name="window-width" type="i">
<default>800</default>
<summary>Window width</summary>
</key>
<key name="window-height" type="i">
<default>600</default>
<summary>Window height</summary>
</key>
<key name="is-maximized" type="b">
<default>false</default>
<summary>Window maximized state</summary>
</key>
<key name="library-path" type="s">
<default>''</default>
<summary>Path to the music library</summary>
</key>
<key name="program1" type="s">
<!-- Translators: Configuration for the default programs in JSON. Please only translate the values of "title" and "description". -->
<default l10n="messages">'{"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>
<summary>Default settings for program 1</summary>
</key>
<key name="program2" type="s">
<!-- Translators: Configuration for the default programs in JSON. Please only translate the values of "title" and "description". -->
<default l10n="messages">'{"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>
<summary>Default settings for program 2</summary>
</key>
<key name="program3" type="s">
<!-- Translators: Configuration for the default programs in JSON. Please only translate the values of "title" and "description". -->
<default l10n="messages">'{"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>
<summary>Default settings for program 3</summary>
</key>
</schema>
</schemalist>

View file

@ -0,0 +1,3 @@
[D-BUS Service]
Name=@APP_ID@
Exec=@BINDIR@/@PKGNAME@ --gapplication-service

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>de.johrpan.musicus.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<description>
<p>No description</p>
</description>
</component>

View file

@ -1,8 +0,0 @@
[Desktop Entry]
Name=Musicus
Exec=musicus
Icon=de.johrpan.musicus
Terminal=false
Type=Application
Categories=GTK;
StartupNotify=true

View file

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="musicus">
<schema id="de.johrpan.musicus" path="/de/johrpan/musicus/">
<key name="window-width" type="i">
<default>800</default>
<summary>Window width</summary>
</key>
<key name="window-height" type="i">
<default>600</default>
<summary>Window height</summary>
</key>
<key name="is-maximized" type="b">
<default>false</default>
<summary>Window maximized state</summary>
</key>
<key name="library-path" type="s">
<default>''</default>
<summary>Path to the music library</summary>
</key>
<key name="program1" type="s">
<!-- Translators: Configuration for the default programs in JSON. Please only translate the values of "title" and "description". -->
<default l10n="messages">'{"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>
<summary>Default settings for program 1</summary>
</key>
<key name="program2" type="s">
<!-- Translators: Configuration for the default programs in JSON. Please only translate the values of "title" and "description". -->
<default l10n="messages">'{"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>
<summary>Default settings for program 2</summary>
</key>
<key name="program3" type="s">
<!-- Translators: Configuration for the default programs in JSON. Please only translate the values of "title" and "description". -->
<default l10n="messages">'{"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>
<summary>Default settings for program 3</summary>
</key>
</schema>
</schemalist>

View file

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="128px" viewBox="0 0 128 128" width="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<filter id="a" height="100%" width="100%" x="0%" y="0%">
<feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
</filter>
<clipPath id="b">
<rect height="128" width="128"/>
</clipPath>
<clipPath id="c">
<rect height="128" width="128"/>
</clipPath>
<mask id="d">
<g filter="url(#a)">
<g clip-path="url(#c)" filter="url(#a)">
<g clip-path="url(#b)">
<path d="m 16 28 h 96 c 4.417969 0 8 3.582031 8 8 v 72 c 0 4.417969 -3.582031 8 -8 8 h -96 c -4.417969 0 -8 -3.582031 -8 -8 v -72 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#77767b"/>
<path d="m 16 28 h 96 c 4.417969 0 8 3.582031 8 8 v 56 c 0 4.417969 -3.582031 8 -8 8 h -96 c -4.417969 0 -8 -3.582031 -8 -8 v -56 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#9a9996"/>
<path d="m 92.714844 68 c 0 22.09375 -17.910156 40 -40 40 c -22.09375 0 -40 -17.90625 -40 -40 c 0 -22.089844 17.90625 -40 40 -40 c 22.089844 0 40 17.910156 40 40 z m 0 0" fill="#5e5c64"/>
<path d="m 92.714844 64 c 0 22.09375 -17.910156 40 -40 40 c -22.09375 0 -40 -17.90625 -40 -40 c 0 -22.089844 17.90625 -40 40 -40 c 22.089844 0 40 17.910156 40 40 z m 0 0" fill="#3d3846"/>
<path d="m 62.714844 64 c 0 5.523438 -4.476563 10 -10 10 c -5.523438 0 -10 -4.476562 -10 -10 s 4.476562 -10 10 -10 c 5.523437 0 10 4.476562 10 10 z m 0 0" fill="#c64600"/>
<path d="m 54.714844 64 c 0 1.105469 -0.894532 2 -2 2 c -1.105469 0 -2 -0.894531 -2 -2 s 0.894531 -2 2 -2 c 1.105468 0 2 0.894531 2 2 z m 0 0" fill="#c0bfbc"/>
<path d="m 54.59375 63.226562 c 0 0.550782 -0.445312 1 -1 1 c -0.550781 0 -1 -0.449218 -1 -1 c 0 -0.554687 0.449219 -1 1 -1 c 0.554688 0 1 0.445313 1 1 z m 0 0" fill="#f6f5f4"/>
<path d="m 75.339844 86.628906 c -12.496094 12.496094 -32.757813 12.496094 -45.253906 0 c -12.496094 -12.496094 -12.496094 -32.757812 0 -45.253906 c 12.496093 -12.5 32.757812 -12.5 45.253906 0" fill="none" stroke="#5e5c64" stroke-linecap="round" stroke-width="2"/>
<path d="m 52.714844 88 c -10.347656 0 -19.527344 -6.628906 -22.78125 -16.449219 c -3.253906 -9.820312 0.148437 -20.621093 8.449218 -26.800781 c 8.296876 -6.179688 19.621094 -6.34375 28.097657 -0.410156" fill="none" stroke="#5e5c64" stroke-linecap="round" stroke-width="2"/>
<path d="m 41.398438 75.3125 c -5.488282 -5.488281 -6.246094 -14.128906 -1.789063 -20.488281 c 4.453125 -6.363281 12.828125 -8.605469 19.867187 -5.324219" fill="none" stroke="#5e5c64" stroke-linecap="round" stroke-width="2"/>
<path d="m 112 45 c 0 4.417969 -3.582031 8 -8 8 s -8 -3.582031 -8 -8 s 3.582031 -8 8 -8 s 8 3.582031 8 8 z m 0 0" fill="#e66100"/>
<path d="m 104 45 l -30.800781 27.53125" fill="#ffa348" stroke="#e66100" stroke-linecap="round" stroke-width="4"/>
<path d="m 112 44 c 0 4.417969 -3.582031 8 -8 8 s -8 -3.582031 -8 -8 s 3.582031 -8 8 -8 s 8 3.582031 8 8 z m 0 0" fill="#ffa348"/>
<path d="m 104 44 l -30.800781 27.53125" fill="#ffa348" stroke="#ffa348" stroke-linecap="round" stroke-width="4"/>
<path d="m 104 60 v 32" fill="none" stroke="#77767b" stroke-linecap="round" stroke-width="4"/>
<path d="m 110 72.503906 c 0 3.316406 -2.6875 6 -6 6 s -6 -2.683594 -6 -6 c 0 -3.3125 2.6875 -6 6 -6 s 6 2.6875 6 6 z m 0 0" fill="#e66100"/>
<path d="m 110 71.503906 c 0 3.316406 -2.6875 6 -6 6 s -6 -2.683594 -6 -6 c 0 -3.3125 2.6875 -6 6 -6 s 6 2.6875 6 6 z m 0 0" fill="#ffa348"/>
</g>
</g>
</g>
</mask>
<mask id="e">
<g filter="url(#a)">
<rect fill-opacity="0.8" height="184.32" width="184.32" x="-28.16" y="-28.16"/>
</g>
</mask>
<linearGradient id="f" gradientTransform="matrix(0 0.37 -0.98462 0 295.38501 -30.360001)" gradientUnits="userSpaceOnUse" x1="300" x2="428" y1="235" y2="235">
<stop offset="0" stop-color="#f9f06b"/>
<stop offset="1" stop-color="#f5c211"/>
</linearGradient>
<clipPath id="g">
<rect height="128" width="128"/>
</clipPath>
<clipPath id="h">
<rect height="128" width="128"/>
</clipPath>
<path d="m 16 28 h 96 c 4.417969 0 8 3.582031 8 8 v 72 c 0 4.417969 -3.582031 8 -8 8 h -96 c -4.417969 0 -8 -3.582031 -8 -8 v -72 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#77767b"/>
<path d="m 16 28 h 96 c 4.417969 0 8 3.582031 8 8 v 56 c 0 4.417969 -3.582031 8 -8 8 h -96 c -4.417969 0 -8 -3.582031 -8 -8 v -56 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#9a9996"/>
<path d="m 92.714844 68 c 0 22.09375 -17.910156 40 -40 40 c -22.09375 0 -40 -17.90625 -40 -40 c 0 -22.089844 17.90625 -40 40 -40 c 22.089844 0 40 17.910156 40 40 z m 0 0" fill="#5e5c64"/>
<path d="m 92.714844 64 c 0 22.09375 -17.910156 40 -40 40 c -22.09375 0 -40 -17.90625 -40 -40 c 0 -22.089844 17.90625 -40 40 -40 c 22.089844 0 40 17.910156 40 40 z m 0 0" fill="#3d3846"/>
<path d="m 62.714844 64 c 0 5.523438 -4.476563 10 -10 10 c -5.523438 0 -10 -4.476562 -10 -10 s 4.476562 -10 10 -10 c 5.523437 0 10 4.476562 10 10 z m 0 0" fill="#c64600"/>
<path d="m 54.714844 64 c 0 1.105469 -0.894532 2 -2 2 c -1.105469 0 -2 -0.894531 -2 -2 s 0.894531 -2 2 -2 c 1.105468 0 2 0.894531 2 2 z m 0 0" fill="#c0bfbc"/>
<path d="m 54.59375 63.226562 c 0 0.550782 -0.445312 1 -1 1 c -0.550781 0 -1 -0.449218 -1 -1 c 0 -0.554687 0.449219 -1 1 -1 c 0.554688 0 1 0.445313 1 1 z m 0 0" fill="#f6f5f4"/>
<g fill="none" stroke="#5e5c64" stroke-linecap="round" stroke-width="2">
<path d="m 75.339844 86.628906 c -12.496094 12.496094 -32.757813 12.496094 -45.253906 0 c -12.496094 -12.496094 -12.496094 -32.757812 0 -45.253906 c 12.496093 -12.5 32.757812 -12.5 45.253906 0"/>
<path d="m 52.714844 88 c -10.347656 0 -19.527344 -6.628906 -22.78125 -16.449219 c -3.253906 -9.820312 0.148437 -20.621093 8.449218 -26.800781 c 8.296876 -6.179688 19.621094 -6.34375 28.097657 -0.410156"/>
<path d="m 41.398438 75.3125 c -5.488282 -5.488281 -6.246094 -14.128906 -1.789063 -20.488281 c 4.453125 -6.363281 12.828125 -8.605469 19.867187 -5.324219"/>
</g>
<path d="m 112 45 c 0 4.417969 -3.582031 8 -8 8 s -8 -3.582031 -8 -8 s 3.582031 -8 8 -8 s 8 3.582031 8 8 z m 0 0" fill="#e66100"/>
<path d="m 104 45 l -30.800781 27.53125" fill="#ffa348" stroke="#e66100" stroke-linecap="round" stroke-width="4"/>
<path d="m 112 44 c 0 4.417969 -3.582031 8 -8 8 s -8 -3.582031 -8 -8 s 3.582031 -8 8 -8 s 8 3.582031 8 8 z m 0 0" fill="#ffa348"/>
<path d="m 104 44 l -30.800781 27.53125" fill="#ffa348" stroke="#ffa348" stroke-linecap="round" stroke-width="4"/>
<path d="m 104 60 v 32" fill="none" stroke="#77767b" stroke-linecap="round" stroke-width="4"/>
<path d="m 110 72.503906 c 0 3.316406 -2.6875 6 -6 6 s -6 -2.683594 -6 -6 c 0 -3.3125 2.6875 -6 6 -6 s 6 2.6875 6 6 z m 0 0" fill="#e66100"/>
<path d="m 110 71.503906 c 0 3.316406 -2.6875 6 -6 6 s -6 -2.683594 -6 -6 c 0 -3.3125 2.6875 -6 6 -6 s 6 2.6875 6 6 z m 0 0" fill="#ffa348"/>
<g mask="url(#d)">
<g clip-path="url(#h)">
<g mask="url(#e)">
<g clip-path="url(#g)">
<path d="m 128 80.640625 v 47.359375 h -128 v -47.359375 z m 0 0" fill="url(#f)"/>
<path d="m 13.308594 80.640625 l 47.355468 47.359375 h 21.214844 l -47.359375 -47.359375 z m 42.421875 0 l 47.363281 47.359375 h 21.214844 l -47.363282 -47.359375 z m 42.429687 0 l 29.839844 29.839844 v -21.210938 l -8.628906 -8.628906 z m -98.160156 7.90625 v 21.214844 l 18.238281 18.238281 h 21.214844 z m 0 0"/>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 996 B

After

Width:  |  Height:  |  Size: 996 B

Before After
Before After

View file

@ -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),
)

View file

@ -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')

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/de/johrpan/musicus">
<gresource prefix="@PATH_ID@">
<file preprocess="xml-stripblanks">icons/scalable/actions/playlist-symbolic.svg</file>
<file compressed="true">style.css</file>
</gresource>

View file

@ -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(),
)

View file

@ -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 {

View file

@ -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 @@
]
}
]
}
}

View file

@ -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,
)

9
meson_options.txt Normal file
View file

@ -0,0 +1,9 @@
option(
'profile',
type: 'combo',
choices: [
'release',
'development'
],
value: 'release',
)

View file

@ -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

View file

@ -1 +1 @@
i18n.gettext('musicus', preset: 'glib')
i18n.gettext(meson.project_name(), preset: 'glib')

View file

@ -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 <elias@johrpan.de>"])
.copyright("© 2023 Elias Projahn")

View file

@ -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@;

View file

@ -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(),

View file

@ -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()
}

View file

@ -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@',
]
],
)

View file

@ -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::<gstreamer_play::PlayVideoRenderer>);
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);

View file

@ -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));
}
}