[gnome-music/freeze-break: 15/107] Filter tracks on album view



commit d7d6335594c0b7eea81fcbf7a5a4c07e4d7d88ab
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Mon Sep 2 16:21:56 2013 +0200

    Filter tracks on album view

 gnomemusic/searchbar.py |    3 +++
 gnomemusic/widgets.py   |    5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/searchbar.py b/gnomemusic/searchbar.py
index 70d368d..4ae714b 100644
--- a/gnomemusic/searchbar.py
+++ b/gnomemusic/searchbar.py
@@ -36,6 +36,9 @@ class Searchbar(Gtk.SearchBar):
 
     def prepare_search_filter(self, widget, data):
         self.view = self.stack_switcher.get_stack().get_visible_child()
+        if self.view.header_bar._state == 0:
+            # album was selected on album view, view needs to be redefined
+            self.view = self.view._albumWidget
         if not hasattr(self.view.filter, "visible_function_set"):
             self.view.filter.set_visible_func(self.set_view_filter)
             self.view.filter.visible_function_set = True
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 2d32783..450f522 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -107,6 +107,7 @@ class AlbumWidget(Gtk.EventBox):
     tracks = []
     duration = 0
     symbolicIcon = ALBUM_ART_CACHE.make_default_icon(256, 256)
+    filter = None
 
     def __init__(self, player):
         super(Gtk.EventBox, self).__init__()
@@ -235,7 +236,8 @@ class AlbumWidget(Gtk.EventBox):
             'clicked', self._on_header_cancel_button_clicked)
         self.view.connect('view-selection-changed',
                           self._on_view_selection_changed)
-        self.view.set_model(self.model)
+        self.filter = self.model.filter_new(None)
+        self.view.set_model(self.filter)
         escaped_artist = GLib.markup_escape_text(artist)
         escaped_album = GLib.markup_escape_text(album)
         self.ui.get_object('artist_label').set_markup(escaped_artist)
@@ -246,7 +248,6 @@ class AlbumWidget(Gtk.EventBox):
         else:
             self.ui.get_object('released_label_info').set_text('----')
         self.player.connect('playlist-item-changed', self.update_model)
-        #self.emit('loaded')
 
     def _on_view_selection_changed(self, widget):
         items = self.view.get_selection()


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