Ticket #10841: 0001-Journal-Do-not-rescan-external-device-if-not-needed-2.patch

File 0001-Journal-Do-not-rescan-external-device-if-not-needed-2.patch, 1.1 KB (added by erikos, 3 years ago)

Second version

  • src/jarabe/journal/listview.py

    diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
    index 0aee1b7..1bc8f8a 100644
    a b  
    118118        model.deleted.connect(self.__model_deleted_cb) 
    119119 
    120120    def __model_created_cb(self, sender, **kwargs): 
    121         self._set_dirty() 
     121        if self._is_new_item_visible(kwargs): 
     122            self._set_dirty() 
    122123 
    123124    def __model_updated_cb(self, sender, **kwargs): 
    124125        self._set_dirty() 
     
    126127    def __model_deleted_cb(self, sender, **kwargs): 
    127128        self._set_dirty() 
    128129 
     130    def _is_new_item_visible(self, kwargs): 
     131        """Check if the created item is part of the currently selected view""" 
     132        if self._query['mountpoints'] == ['/']: 
     133            return not kwargs['object_id'].startswith('/') 
     134        else: 
     135            return kwargs['object_id'].startswith(self._query['mountpoints'][0]) 
     136 
    129137    def _add_columns(self): 
    130138        cell_favorite = CellRendererFavorite(self.tree_view) 
    131139        cell_favorite.connect('clicked', self.__favorite_clicked_cb)