Commit 3772ded1 authored by Jean Felder's avatar Jean Felder Committed by Marinus Schraal

widgets: Implement get_selected_songs method

SearchView relies on AlbumWidget and ArtistAlbum{s}Widget to get a
list of selected songs. Add the appropriate functions to avoid the
call of private methods or members.
parent ab46e6fa
......@@ -342,14 +342,9 @@ class SearchView(BaseView):
@log
def get_selected_songs(self, callback):
if self.get_visible_child() == self._album_widget:
callback(self._album_widget.view.get_selected_items())
callback(self._album_widget.get_selected_songs())
elif self.get_visible_child() == self._artist_albums_widget:
items = []
# FIXME: calling into private model
for row in self._artist_albums_widget._model:
if row[6]:
items.append(row[5])
callback(items)
callback(self._artist_albums_widget.get_selected_songs())
else:
self._albums_index = 0
self._artists_albums_index = 0
......
......@@ -82,10 +82,6 @@ class AlbumWidget(Gtk.EventBox):
self._header_bar = header_bar
self._selection_toolbar = selection_toolbar
# FIXME: Assigned to appease searchview
# _get_selected_songs
self.view = self._disc_listbox
self.bind_property(
'selection-mode', self._disc_listbox, 'selection-mode',
GObject.BindingFlags.BIDIRECTIONAL)
......@@ -275,3 +271,12 @@ class AlbumWidget(Gtk.EventBox):
@log
def select_none(self):
self._disc_listbox.select_none()
@log
def get_selected_songs(self):
"""Return a list of selected songs.
:returns: selected songs
:rtype: list
"""
return self._disc_listbox.get_selected_items()
......@@ -213,3 +213,15 @@ class ArtistAlbumsWidget(Gtk.Box):
def artist(self):
"""Artist name"""
return self._artist
@log
def get_selected_songs(self):
"""Return a list of selected songs.
:returns: selected songs
:rtype: list
"""
songs = []
for widget in self._widgets:
songs += widget.get_selected_songs()
return songs
......@@ -154,3 +154,9 @@ class ArtistAlbumWidget(Gtk.Box):
def select_none(self):
"""Deselect all items"""
self._disc_list_box.select_none()
@log
def get_selected_songs(self):
"""Return a list of selected songs."""
items = self._disc_list_box.get_selected_items()
return items
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment