[gnome-music] view: Reshow previous view when search bar is hidden



commit 1c1f0c252dce90d8e5b26bd1fcecfe978d4dcc71
Author: Arnel Borja <arnelborja src gnome org>
Date:   Mon May 5 00:17:33 2014 +0800

    view: Reshow previous view when search bar is hidden
    
    If the current view is the search view showing all results, go back to
    the previous view when the search bar is hidden.

 gnomemusic/searchbar.py |    6 ++++--
 gnomemusic/view.py      |    3 +++
 gnomemusic/window.py    |    3 +++
 3 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/searchbar.py b/gnomemusic/searchbar.py
index 18375f2..dedfcdd 100644
--- a/gnomemusic/searchbar.py
+++ b/gnomemusic/searchbar.py
@@ -253,8 +253,10 @@ class Searchbar(Gd.Revealer):
         fields_filter = self.dropdown.searchFieldsManager.get_active()
         search_term = self._search_entry.get_text()
 
-        view = self.stack_switcher.get_stack().get_child_by_name('search')
-        self.stack_switcher.get_stack().set_visible_child(view)
+        stack = self.stack_switcher.get_stack()
+        view = stack.get_child_by_name('search')
+        if search_term != "":
+            stack.set_visible_child(view)
         view.set_search_text(search_term, fields_filter)
 
     @log
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 77a3162..3eeea72 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -1300,6 +1300,9 @@ class Search(ViewContainer):
         self.filter_model.set_visible_func(self._filter_visible_func)
         self.view.set_model(self.filter_model)
 
+        if search_term == "":
+            return
+
         albums_iter = self._model.insert_with_values(None, -1, [2], ['Albums'])
         artists_iter = self._model.insert_with_values(None, -1, [2], ['Artists'])
         songs_iter = self._model.insert_with_values(None, -1, [2], ['Songs'])
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index dc23e87..4482702 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -343,6 +343,9 @@ class Window(Gtk.ApplicationWindow):
     @log
     def _on_search_toggled(self, button, data=None):
         self.toolbar.searchbar.show_bar(button.get_active())
+        if not button.get_active() and self.curr_view == self.views[4] and \
+           self.toolbar._state == ToolbarState.MAIN:
+            self._stack.set_visible_child(self.prev_view)
 
     @log
     def _on_selection_mode_changed(self, widget, data=None):


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