rendered paste bodyIndex: slideshow_view.py
===================================================================
--- slideshow_view.py (wersja 5059)
+++ slideshow_view.py (kopia robocza)
@@ -265,7 +265,11 @@
if not self.controller.focused:
return False
- self.controller.playing = not self.controller.playing
+ if not self.controller.paused and not self.controller.playing:
+ self.controller.playing = True
+ else:
+ self.controller.paused = not self.controller.paused
+
return True
def playing__set(self, playing):
Index: slideshow_controller.py
===================================================================
--- slideshow_controller.py (wersja 5059)
+++ slideshow_controller.py (kopia robocza)
@@ -37,8 +37,10 @@
supported_models = ('base:list_model',)
duration = 5.0
+ backwards = False
_call_later = None
_playing = False
+ _paused = False
def _cancel_last_call_later(self):
if self._call_later != None and self._call_later.active():
@@ -64,7 +66,7 @@
return True
elif input_event.action == EventAction.PAUSE:
- self.playing = False
+ self.paused = True
return True
elif input_event.action == EventAction.STOP:
@@ -76,19 +78,37 @@
def playing__set(self, playing):
self._playing = playing
- if playing:
+ if playing and not self.backwards:
self.next_image()
self._call_later = reactor.callLater(self.duration,
self.next_image)
+ elif playing and self.backwards:
+ self.previous_image()
+ self._call_later = reactor.callLater(self.duration,
+ self.previous_image)
else:
+ if not self.paused:
+ self.backwards = False
self._cancel_last_call_later()
def playing__get(self):
return self._playing
+ def paused__set(self, paused):
+ self._paused = paused
+ if paused:
+ self.playing = False
+ else:
+ self.playing = True
+
+ def paused__get(self):
+ return self._paused
+
def focused_changed(self, old_focused, new_focused):
if new_focused == False and self.playing == True:
- self.playing = False
+ self.paused = True
+ elif new_focused == True and self.paused == True:
+ self.paused = False
def next_image(self):
self._cancel_last_call_later()
@@ -98,10 +118,12 @@
self.info("Loading image at index %r", index)
self.current_index = index
if self.playing == True:
+ self.backwards = False
self._call_later = reactor.callLater(self.duration,
self.next_image)
return True
else:
+ self.playing = False
self.info("Reached end of slideshow")
return False
@@ -113,10 +135,12 @@
self.info("Loading image at index %r", index)
self.current_index = index
if self.playing == True:
+ self.backwards = True
self._call_later = reactor.callLater(self.duration,
self.previous_image)
return True
else:
+ self.playing = False
self.info("Reached beginning of slideshow")
return False