[pitivi] medialibrary: Perform batch updates to the model when importing
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] medialibrary: Perform batch updates to the model when importing
- Date: Sun, 2 Sep 2012 04:04:42 +0000 (UTC)
commit 497976f4ef551f10d77ad51c121a86336e1eaa3e
Author: Renà Stadler <mail renestadler de>
Date: Mon Aug 27 18:00:55 2012 -0700
medialibrary: Perform batch updates to the model when importing
This helps with O(n^2) time caused by current GtkIconView (invalidating all
rows for each insert).
pitivi/medialibrary.py | 27 +++++++++++++++++++--------
1 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index eafeea8..0ad08fa 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -270,6 +270,8 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
gtk.VBox.__init__(self)
Loggable.__init__(self)
+ self.pending_rows = []
+
self.app = instance
self.settings = instance.settings
self._errors = []
@@ -807,14 +809,22 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
else:
short_text = info_name(info)
- self.storemodel.append([thumbnail,
- thumbnail_large,
- beautify_info(info),
- info,
- info.get_uri(),
- duration,
- info_name(info),
- short_text])
+ self.pending_rows.append((thumbnail,
+ thumbnail_large,
+ beautify_info(info),
+ info,
+ info.get_uri(),
+ duration,
+ info_name(info),
+ short_text))
+ if len(self.pending_rows) > 50:
+ self.flush_pending_rows()
+
+ def flush_pending_rows(self):
+
+ for row in self.pending_rows:
+ self.storemodel.append(row)
+ del self.pending_rows[:]
# medialibrary callbacks
@@ -848,6 +858,7 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
self._progressbar.show()
def _sourcesStoppedImportingCb(self, unused_medialibrary):
+ self.flush_pending_rows()
self._progressbar.hide()
if self._errors:
if len(self._errors) > 1:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]