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



commit fb83103016416fdb566089eaac430954731a866c
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 e3affbda..2eee0c2e 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):
         return self._search_mode_active


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