[gnome-music/wip/jfelder/search-selection-reset: 11/11] searchview: Reset number of selected items on search



commit 5982be261e8a7b8d9fc4cc0e8a3527fcae03713b
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Feb 27 21:11:36 2019 +0100

    searchview: Reset number of selected items on search
    
    If a search is triggered after when selection mode activated, it is
    necessary to reset the number of selected items.

 gnomemusic/views/searchview.py | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 2c557c88..247001bf 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -79,6 +79,7 @@ class SearchView(BaseView):
         self._items_found = None
 
         self._search_mode_active = False
+        self.connect("notify::search-state", self._on_search_state_changed)
 
     @log
     def _setup_view(self):
@@ -212,6 +213,14 @@ class SearchView(BaseView):
         cells[4].props.visible = self.props.selection_mode
         col.queue_resize()
 
+    @log
+    def _on_search_state_changed(self, klass, param):
+        # If a search is triggered when selection mode is activated,
+        # reset the number of selected items.
+        if (self.props.selection_mode
+                and self.props.search_state != Search.State.NONE):
+            self.props.selected_items_count = 0
+
     @GObject.Property(type=bool, default=False)
     def search_mode_active(self):
         """Get search mode status.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]