[kupfer] data: Add SourceController.cache_toplevel_sources



commit cb5f08d212de9d88835cfde6b964013e93137a97
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Wed Oct 28 16:55:18 2009 +0100

    data: Add SourceController.cache_toplevel_sources
    
    Add a method to ensure that all sources are cached on launch. This way
    we reload all sources that do Source.mark_for_update() in
    .unpickle_finish().
    
    This way we put the loading wait before kupfer's window shows up,
    instead of after the first character is input.

 kupfer/data.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/data.py b/kupfer/data.py
index 9e6d62b..d30cc91 100644
--- a/kupfer/data.py
+++ b/kupfer/data.py
@@ -442,6 +442,12 @@ class SourceController (pretty.OutputMixin):
 				continue
 			sourcepickler.pickle_source(source)
 
+	def cache_toplevel_sources(self):
+		"""Ensure that all toplevel sources are cached"""
+		for src in self.toplevel_sources:
+			if not src.is_dynamic():
+				src.get_leaves()
+
 _source_controller = None
 def GetSourceController():
 	global _source_controller
@@ -789,6 +795,7 @@ class DataController (gobject.GObject, pretty.OutputMixin):
 		sc = GetSourceController()
 		sc.add(self.direct_sources, toplevel=True)
 		sc.add(self.other_sources, toplevel=False)
+		sc.cache_toplevel_sources()
 		self.source_pane.source_rebase(sc.root)
 		learn.load()
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]