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



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

    searchview: Reset number of selected items on search

 gnomemusic/views/searchview.py | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index b5d46f55..8b23fecb 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -65,6 +65,7 @@ class SearchView(BaseView):
         self.bind_property(
             "search-state", self._search, "state",
             GObject.BindingFlags.SYNC_CREATE)
+        self.connect("notify::search-state", self._on_search_state_changed)
         self._previous_search_state = Search.State.NONE
 
         self._add_list_renderers()
@@ -224,6 +225,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 after with selection mode 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]