[pitivi] viewer: Make OverlayStack.create a provider
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] viewer: Make OverlayStack.create a provider
- Date: Fri, 22 Apr 2016 04:24:15 +0000 (UTC)
commit 96db4c037fca2338622c75dcbc8207a14f493569
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Thu Apr 14 21:49:43 2016 +0200
viewer: Make OverlayStack.create a provider
Also Pythonify code.
Differential Revision: https://phabricator.freedesktop.org/D942
pitivi/viewer/overlay_stack.py | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/pitivi/viewer/overlay_stack.py b/pitivi/viewer/overlay_stack.py
index 2bac258..962515f 100644
--- a/pitivi/viewer/overlay_stack.py
+++ b/pitivi/viewer/overlay_stack.py
@@ -54,13 +54,17 @@ class OverlayStack(Gtk.Overlay):
for overlay in self.__overlays.values():
overlay.update_from_source()
- def __create_overlay_for_source(self, source):
+ def __overlay_for_source(self, source):
+ if source in self.__overlays:
+ return self.__overlays[source]
+
if type(source) == GES.TitleSource:
overlay = TitleOverlay(self, source)
else:
overlay = MoveScaleOverlay(self, self.app.action_log, source)
self.add_overlay(overlay)
self.__overlays[source] = overlay
+ return overlay
def do_event(self, event):
if event.type == Gdk.EventType.BUTTON_RELEASE:
@@ -115,23 +119,20 @@ class OverlayStack(Gtk.Overlay):
self.__visible_overlays = []
# check if source has instanced viewer
for source in sources:
- if source not in self.__overlays.keys():
- self.__create_overlay_for_source(source)
- self.__visible_overlays.append(self.__overlays[source])
+ overlay = self.__overlay_for_source(source)
+ self.__visible_overlays.append(overlay)
# check if viewer should be visible
- for source in self.__overlays.keys():
+ for source, overlay in self.__overlays.items():
if source in sources:
- self.__overlays[source].show()
+ overlay.show()
else:
- self.__overlays[source].hide()
+ overlay.hide()
def update(self, source):
self.__overlays[source].update_from_source()
def select(self, source):
- if source not in self.__overlays.keys():
- self.__create_overlay_for_source(source)
- self.selected_overlay = self.__overlays[source]
+ self.selected_overlay = self.__overlay_for_source(source)
self.selected_overlay.queue_draw()
def set_cursor(self, name):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]