mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Update build system and Flatpak manifest
This commit is contained in:
parent
1788303bf3
commit
b9c874ab8c
26 changed files with 317 additions and 160 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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@;
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
29
src/main.rs
29
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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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@',
|
||||
]
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue