It would be useful to do this with the deleted and updated callbacks too. :) Makes no sense to refresh the ListModel when the object_id doesn't belong to it.
On Fri, Jun 17, 2011 at 10:20 AM, <godi...@sugarlabs.org> wrote: > From: Gonzalo Odiard <godi...@gmail.com> > > Signed-off-by: Gonzalo Odiard <gonz...@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 > > _______________________________________________ > Sugar-devel mailing list > Sugar-devel@lists.sugarlabs.org > http://lists.sugarlabs.org/listinfo/sugar-devel > _______________________________________________ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel