audrey/src/main.rs

71 lines
2.1 KiB
Rust
Raw Normal View History

2024-10-29 12:01:42 +00:00
mod application;
2024-10-29 13:02:29 +00:00
pub use application::Application;
2024-10-30 06:32:21 +00:00
mod meson_config;
2024-10-29 13:02:29 +00:00
pub mod ui;
2024-10-29 12:01:42 +00:00
2024-10-30 09:06:10 +00:00
pub mod mpris;
pub use mpris::Mpris;
pub mod playbin;
pub use playbin::Playbin;
pub mod subsonic;
2024-10-31 12:16:42 +00:00
pub mod subsonic_vala;
2024-10-30 09:06:10 +00:00
2024-10-30 06:32:21 +00:00
use gettextrs::{bind_textdomain_codeset, bindtextdomain, setlocale, textdomain, LocaleCategory};
2024-10-29 12:01:42 +00:00
use gtk::prelude::*;
2024-10-29 13:02:29 +00:00
use gtk::{gio, glib};
2024-10-29 10:46:58 +00:00
2024-10-30 07:41:17 +00:00
pub mod mpv;
2024-10-29 10:37:15 +00:00
#[link(name = "audrey")]
#[link(name = "gcrypt")]
#[link(name = "json-glib-1.0")]
2024-10-29 18:13:58 +00:00
#[link(name = "secret-1")]
2024-10-29 10:37:15 +00:00
#[link(name = "soup-3.0")]
2024-10-29 13:02:29 +00:00
extern "C" {}
2024-10-29 10:37:15 +00:00
2024-10-31 12:16:42 +00:00
pub fn runtime() -> &'static tokio::runtime::Runtime {
static RUNTIME: std::sync::OnceLock<tokio::runtime::Runtime> = std::sync::OnceLock::new();
RUNTIME.get_or_init(|| {
tokio::runtime::Runtime::new().expect("could not initialize the tokio runtime")
})
}
2024-10-29 12:01:42 +00:00
fn main() -> glib::ExitCode {
2024-10-29 10:46:58 +00:00
gio::resources_register_include!("audrey.gresource").expect("could not register resources");
2024-10-30 11:45:50 +00:00
ui::Playbar::ensure_type();
2024-10-31 11:02:00 +00:00
ui::PlayQueue::ensure_type();
2024-10-30 11:45:50 +00:00
2024-10-29 12:01:42 +00:00
gtk::disable_setlocale();
2024-10-30 06:32:21 +00:00
bindtextdomain("audrey", meson_config::LOCALEDIR).expect("failed to bind text domain");
bind_textdomain_codeset("audrey", "UTF-8").expect("failed to bind textdomaincodeset");
textdomain("audrey").expect("unable to switch to text domain");
setlocale(LocaleCategory::LcAll, "");
setlocale(LocaleCategory::LcNumeric, "C.UTF-8");
2024-10-29 12:01:42 +00:00
let app = Application::new();
2024-11-01 08:29:59 +00:00
// smol test for the subsonic client
runtime().spawn(async {
let keyring = oo7::Keyring::new().await.unwrap();
let attributes = vec![("xdg:schema", "eu.callcc.audrey")];
let items = keyring.search_items(&attributes).await.unwrap();
if !items.is_empty() {
let item = &items[0];
let attributes = item.attributes().await.unwrap();
let client = subsonic::Client::with_password(
&attributes["server-url"],
&attributes["username"],
&item.secret().await.unwrap(),
)
.unwrap();
client.ping().await.unwrap();
2024-11-01 08:43:55 +00:00
println!("{:#?}", client.get_random_songs(10).await.unwrap());
2024-11-01 08:29:59 +00:00
}
});
2024-10-29 12:01:42 +00:00
app.run()
2024-10-29 10:37:15 +00:00
}