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



commit 51634d254d3cb74e983888962eee583ee0241df4
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 3d0af4a4..ffdca0d1 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -79,6 +79,7 @@ class SearchView(BaseView):
         self._items_found = None
 
         self._previous_search_state = Search.State.NONE
+        self.connect("notify::search-state", self._on_search_state_changed)
 
     @log
     def _setup_view(self):
@@ -214,6 +215,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
+
     @log
     def _add_search_item(self, source, param, item, remaining=0, data=None):
         if not item:


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