From 593d66ea5492dcc026d7452a266ca9d261d3aaa8 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Wed, 20 Jun 2018 12:36:56 +0300 Subject: [PATCH] EpisodeWidget: Mark an episode as played when the play button is hit. Ideally episodes would be marked as played only when they have passed a cerain point in their duration, but till thats ready we should keep marking them. --- hammond-gtk/src/widgets/episode.rs | 31 ++++++++++-------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/hammond-gtk/src/widgets/episode.rs b/hammond-gtk/src/widgets/episode.rs index 1af0531..aab0310 100644 --- a/hammond-gtk/src/widgets/episode.rs +++ b/hammond-gtk/src/widgets/episode.rs @@ -442,34 +442,23 @@ fn on_download_clicked(ep: &EpisodeWidgetQuery, sender: &Sender) -> Resu } fn on_play_bttn_clicked( - _widget: &Rc, + widget: &Rc, episode: &mut EpisodeWidgetQuery, sender: &Sender, ) -> Result<(), Error> { + // Mark played + episode.set_played_now()?; + // Grey out the title + widget.info.set_title(&episode); + + // Play the episode + sender.send(Action::InitEpisode(episode.rowid()))?; + // Refresh background views to match the normal/greyout title state sender - .send(Action::InitEpisode(episode.rowid())) + .send(Action::RefreshEpisodesViewBGR) .map_err(From::from) - - // widget.info.set_title(&episode); - // sender - // .send(Action::RefreshEpisodesViewBGR) - // .map_err(From::from) } -// fn open_uri(rowid: i32) -> Result<(), Error> { -// let uri = dbqueries::get_episode_local_uri_from_id(rowid)? -// .ok_or_else(|| format_err!("Expected Some found None."))?; - -// if Path::new(&uri).exists() { -// info!("Opening {}", uri); -// open::that(&uri)?; -// } else { -// bail!("File \"{}\" does not exist.", uri); -// } - -// Ok(()) -// } - // Setup a callback that will update the progress bar. #[inline] #[cfg_attr(feature = "cargo-clippy", allow(if_same_then_else))]