[pitivi] timeline: Fix state restoring
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] timeline: Fix state restoring
- Date: Thu, 20 May 2021 19:38:49 +0000 (UTC)
commit 8f3569ed8efcb608848a917b0a8256374dfcc877
Author: UnHired-Coder <pratyushtiwarimj gmail com>
Date: Wed May 19 23:47:00 2021 +0530
timeline: Fix state restoring
The state must be restored when both project and timeline are ready.
Fixes #2341
pitivi/editorstate.py | 5 +----
pitivi/timeline/timeline.py | 9 +++++++++
2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/editorstate.py b/pitivi/editorstate.py
index 963a66f2c..21c9735b8 100644
--- a/pitivi/editorstate.py
+++ b/pitivi/editorstate.py
@@ -44,9 +44,6 @@ class EditorState(Loggable):
self._editor_state = {}
self.__state_saving_handle = 0
- self.project_manager.connect("new-project-loaded",
- self._new_project_loaded_cb)
-
def get_value(self, key):
"""Get a value from the loaded editor state."""
return self._editor_state.get(key)
@@ -65,7 +62,7 @@ class EditorState(Loggable):
self.__state_saving_handle = 0
self.save_editor_state()
- def _new_project_loaded_cb(self, project_manager, project):
+ def set_project(self, project):
self.project = project
self.conf_file_path = os.path.join(self.conf_folder_path, self.project.get_project_id() + ".conf")
self.load_editor_state()
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 100b24337..b92845339 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1584,11 +1584,16 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self.timeline.update_snapping_distance()
self.markers.markers_container = project.ges_timeline.get_marker_list("markers")
+ self.editor_state.set_project(project)
+ self.restore_state()
def restore_state(self):
if self.state_restored:
return
+ if not self._project or not self.get_realized():
+ return
+
# One attempt is enough.
self.state_restored = True
@@ -1614,6 +1619,10 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
# 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 do_realize(self):
+ Gtk.Widget.do_realize(self)
+ self.restore_state()
+
def update_actions(self):
selection = self.timeline.selection
selection_non_empty = bool(selection)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]