Compare commits

...

3 commits

Author SHA1 Message Date
d37ec6a19a decrash 2024-11-13 16:36:20 +01:00
f0f69b7323 try this 2024-11-13 16:36:20 +01:00
48a5beb8b6 move some things around 2024-11-13 16:36:20 +01:00
4 changed files with 19 additions and 15 deletions

View file

@ -35,12 +35,12 @@ template $AudreyUiWindow: Adw.ApplicationWindow {
vexpand: true; vexpand: true;
Adw.ViewStackPage { Adw.ViewStackPage {
icon-name: "media-optical-cd"; icon-name: "folder-music-symbolic";
title: _("Albums"); title: _("Browse");
child: Adw.NavigationView { child: Adw.NavigationView {
Adw.NavigationPage { Adw.NavigationPage {
title: _("Albums"); title: _("Browse");
vexpand: true; vexpand: true;
child: Adw.ToolbarView { child: Adw.ToolbarView {

View file

@ -17,15 +17,19 @@ mod imp {
impl ObjectImpl for Application {} impl ObjectImpl for Application {}
impl ApplicationImpl for Application { impl ApplicationImpl for Application {
// called once by the primary instance
fn startup(&self) {
self.parent_startup();
ui::Window::new(self.obj().as_ref());
}
// executed by the primary instance
fn activate(&self) { fn activate(&self) {
self.parent_activate(); self.parent_activate();
match self.obj().active_window() { self.obj()
None => { .active_window()
let window = ui::Window::new(self.obj().as_ref()); .expect("no window was active")
window.present(); .present();
}
Some(win) => win.present(),
}
} }
} }

View file

@ -41,9 +41,6 @@ fn main() -> glib::ExitCode {
init_tracing(); init_tracing();
ui::Playbar::ensure_type();
ui::PlayQueue::ensure_type();
gtk::disable_setlocale(); gtk::disable_setlocale();
bindtextdomain("audrey", meson_config::LOCALEDIR).expect("failed to bind text domain"); bindtextdomain("audrey", meson_config::LOCALEDIR).expect("failed to bind text domain");
bind_textdomain_codeset("audrey", "UTF-8").expect("failed to bind textdomaincodeset"); bind_textdomain_codeset("audrey", "UTF-8").expect("failed to bind textdomaincodeset");

View file

@ -176,7 +176,7 @@ mod imp {
None => glib::ControlFlow::Break, None => glib::ControlFlow::Break,
Some(window) => { Some(window) => {
match window.imp().state.get() { match window.imp().state.get() {
State::Idle | State::FileLoading | State::Seeking => {}, State::Idle | State::FileLoading | State::Seeking => {}
State::Active => window.notify("time-pos"), State::Active => window.notify("time-pos"),
other => unreachable!("{other:?}"), other => unreachable!("{other:?}"),
} }
@ -361,7 +361,10 @@ mod imp {
match self.state.get() { match self.state.get() {
State::Idle => 0.0, State::Idle => 0.0,
State::FileLoading | State::FileEnded => self.song().unwrap().duration() as f64, State::FileLoading | State::FileEnded => self
.song()
.map(|song| song.duration() as f64)
.unwrap_or(0.0),
State::FileLoaded | State::Active | State::Seeking => { State::FileLoaded | State::Active | State::Seeking => {
self.mpv.get_property::<f64>("duration").unwrap() self.mpv.get_property::<f64>("duration").unwrap()