[pitivi] timeline: Restore the state only when the perspective has been shown
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] timeline: Restore the state only when the perspective has been shown
- Date: Sun, 11 Oct 2020 23:20:36 +0000 (UTC)
commit 343cd37c60c3fdc14b6a96fd97af87d7ee33e9e8
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Thu Oct 1 23:11:30 2020 +0200
timeline: Restore the state only when the perspective has been shown
When seeking too early the Viewer might force the creation of a Window.
pitivi/editorperspective.py | 1 +
pitivi/timeline/timeline.py | 48 ++++++++++++++++++++++++++-------------------
2 files changed, 29 insertions(+), 20 deletions(-)
---
diff --git a/pitivi/editorperspective.py b/pitivi/editorperspective.py
index 4a88a67a0..a25450cd3 100644
--- a/pitivi/editorperspective.py
+++ b/pitivi/editorperspective.py
@@ -111,6 +111,7 @@ class EditorPerspective(Perspective, Loggable):
def refresh(self):
"""Refreshes the perspective."""
+ self.timeline_ui.restore_state()
self.focus_timeline()
def __setup_css(self):
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index f91883f0b..38f8dd8e7 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1453,6 +1453,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self.control_mask = False
self._project = None
+ self.state_restored = False
self.ges_timeline = None
self.__copied_group = None
@@ -1571,30 +1572,37 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self.ruler.set_pipeline(project.pipeline)
self.ruler.zoom_changed()
- position = self.editor_state.get_value("playhead-position")
- if position:
- self._project.pipeline.simple_seek(position)
+ self.timeline.update_snapping_distance()
+ self.markers.markers_container = project.ges_timeline.get_marker_list("markers")
- clip_names = self.editor_state.get_value("selection")
- if clip_names:
- clips = [self.ges_timeline.get_element(clip_name)
- for clip_name in clip_names]
- if all(clips):
- self.timeline.selection.set_selection(clips, SELECT)
+ def restore_state(self):
+ if self.state_restored:
+ return
- zoom_level = self.editor_state.get_value("zoom-level")
- if zoom_level:
- Zoomable.set_zoom_level(zoom_level)
- else:
- self.timeline.set_best_zoom_ratio(allow_zoom_in=True)
+ # One attempt is enough.
+ self.state_restored = True
- self.timeline.update_snapping_distance()
- self.markers.markers_container = project.ges_timeline.get_marker_list("markers")
+ position = self.editor_state.get_value("playhead-position")
+ if position:
+ self._project.pipeline.simple_seek(position)
+
+ clip_names = self.editor_state.get_value("selection")
+ if clip_names:
+ clips = [self.ges_timeline.get_element(clip_name)
+ for clip_name in clip_names]
+ if all(clips):
+ self.timeline.selection.set_selection(clips, SELECT)
+
+ zoom_level = self.editor_state.get_value("zoom-level")
+ if zoom_level:
+ Zoomable.set_zoom_level(zoom_level)
+ else:
+ self.timeline.set_best_zoom_ratio(allow_zoom_in=True)
- scroll = self.editor_state.get_value("scroll")
- if scroll:
- # TODO: Figure out why self.scroll_to_pixel(scroll) which calls _scroll_to_pixel directly
does not work.
- GLib.idle_add(self._scroll_to_pixel, scroll)
+ scroll = self.editor_state.get_value("scroll")
+ if scroll:
+ # TODO: Figure out why self.scroll_to_pixel(scroll) which calls _scroll_to_pixel directly does
not work.
+ GLib.idle_add(self._scroll_to_pixel, scroll)
def update_actions(self):
selection = self.timeline.selection
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]