[Sugar-devel] [PATCH] Journal: Do not rescan external device if is not needed - OLPC #10841

godiard at sugarlabs.org godiard at sugarlabs.org
Fri Jun 17 10:20:03 EDT 2011


From: Gonzalo Odiard <godiard at gmail.com>

Signed-off-by: Gonzalo Odiard <gonzalo at laptop.org>

Do not rescan if the created item is not part of the currently selected view
---
 src/jarabe/journal/listview.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
index 0aee1b7..1bc8f8a 100644
--- a/src/jarabe/journal/listview.py
+++ b/src/jarabe/journal/listview.py
@@ -118,7 +118,8 @@ class BaseListView(gtk.Bin):
         model.deleted.connect(self.__model_deleted_cb)
 
     def __model_created_cb(self, sender, **kwargs):
-        self._set_dirty()
+        if self._is_new_item_visible(kwargs):
+            self._set_dirty()
 
     def __model_updated_cb(self, sender, **kwargs):
         self._set_dirty()
@@ -126,6 +127,13 @@ class BaseListView(gtk.Bin):
     def __model_deleted_cb(self, sender, **kwargs):
         self._set_dirty()
 
+    def _is_new_item_visible(self, kwargs):
+        """Check if the created item is part of the currently selected view"""
+        if self._query['mountpoints'] == ['/']:
+            return not kwargs['object_id'].startswith('/')
+        else:
+            return kwargs['object_id'].startswith(self._query['mountpoints'][0])
+
     def _add_columns(self):
         cell_favorite = CellRendererFavorite(self.tree_view)
         cell_favorite.connect('clicked', self.__favorite_clicked_cb)
-- 
1.7.4.4



More information about the Sugar-devel mailing list