[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:58:21 EDT 2011
On Fri, Jun 17, 2011 at 10:45 AM, Gonzalo Odiard <godiard at sugarlabs.org> wrote:
>
>
> On Fri, Jun 17, 2011 at 11:34 AM, Martin Abente
> <martin.abente.lahaye at gmail.com> wrote:
>>
>> It would be useful to do this with the deleted and updated callbacks
>> too. :)
>
> Was my first idea, but you can't trigger delete or update when you are
> looking another view
> (like uodate the journal when you are looking a external device)
>
>
It does when the mount point is on a external storage device and the
kids are working with activities. Whenever they changed the tittle or
saved it, it will set it to dirty and force a redraw when they go back
to the journal (actually there is a bug that will force the refresh
even when the journal is fully obscured).
>>
>> Makes no sense to refresh the ListModel when the object_id
>> doesn't belong to it.
>>
>
> This is tricky too. Because in external devices, the object_id is the path
> of the file,
> and when you change the title in the list view, the file_name is changed,
> and the object_id is not synchronized. I was doing tests, but we need change
> a lot of code.
> I think is better do it in a separate patch.
>
Yup, I found many of these problems during my recent devel.
> Gonzalo
>
>
>>
>> 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
>> >
>
>
>
> --
> Gonzalo Odiard
> SugarLabs Argentina
>
>
More information about the Sugar-devel
mailing list