commit 80e30620cacbb478d59d5eab69dd4d95c9faa764
parent 6ca27597fa317c48f6c1c51482e86416519f4c53
Author: Sylvia Ivory <git@sivory.net>
Date: Thu, 19 Jun 2025 19:19:27 -0700
Enable media controls
Diffstat:
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/background.rs b/src/background.rs
@@ -63,6 +63,7 @@ pub enum Message {
UnsplashCollection(Result<Collection, String>),
UnsplashCollectionPhotos(Result<CollectionPhotos, String>),
RequestUnsplash(isize),
+ PauseUnsplash,
}
impl BackgroundHandle {
@@ -247,6 +248,12 @@ impl BackgroundHandle {
_ => Task::none(),
},
},
+ Message::PauseUnsplash => if let Some(state) = &mut self.unsplash_state {
+ state.paused = !state.paused;
+ Task::none()
+ } else {
+ Task::none()
+ }
}
}
diff --git a/src/main.rs b/src/main.rs
@@ -119,6 +119,11 @@ impl Fjordgard {
Task::none()
}
+ Message::Media(action) => match action {
+ MediaControl::Next => Task::done(Message::Background(background::Message::RequestUnsplash(1))),
+ MediaControl::Previous => Task::done(Message::Background(background::Message::RequestUnsplash(-1))),
+ MediaControl::Pause => Task::done(Message::Background(background::Message::PauseUnsplash)),
+ }
Message::OpenSettings => {
if self.settings_window.is_none() {
let (_id, open) = window::open(window::Settings {
@@ -306,8 +311,7 @@ impl Fjordgard {
Task::none()
}
- },
- _ => Task::none(),
+ }
}
}