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

Martin Abente martin.abente.lahaye at gmail.com
Fri Jun 17 10:34:48 EDT 2011


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,  <godiard at sugarlabs.org> wrote:
> 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
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>


More information about the Sugar-devel mailing list