From a83270699f556d511038e2310854f4105e2fce71 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Mon, 18 Jun 2018 18:05:53 +0300 Subject: [PATCH] PlayerWidget: refactor seek method. --- hammond-gtk/src/widgets/player.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/hammond-gtk/src/widgets/player.rs b/hammond-gtk/src/widgets/player.rs index 8c1d338..596eb35 100644 --- a/hammond-gtk/src/widgets/player.rs +++ b/hammond-gtk/src/widgets/player.rs @@ -342,22 +342,13 @@ impl PlayerExt for PlayerWidget { return; } + let duration = self.player.get_duration(); let destination = match direction { - SeekDirection::Backwards => { - if position >= offset { - Some(position - offset) - } else { - None - } - } - SeekDirection::Forward => { - let duration = self.player.get_duration(); - if duration != ClockTime::none() && position + offset <= duration { - Some(position + offset) - } else { - None - } + SeekDirection::Backwards if position >= offset => Some(position - offset), + SeekDirection::Forward if !duration.is_none() && position + offset <= duration => { + Some(position + offset) } + _ => None, }; destination.map(|d| self.player.seek(d));