Commit 66c20994 authored by Jean Felder's avatar Jean Felder

albumwidget: Move selection_toolbar to the constructor

selection_toolbar is static to the object. It does not need to be
updated.
Make the variable private.
parent a8e75b53
......@@ -48,7 +48,8 @@ class AlbumsView(BaseView):
self._queue = LifoQueue()
self.player = player
self._album_widget = AlbumWidget(player, self, self._header_bar)
self._album_widget = AlbumWidget(
player, self, self._header_bar, self._selection_toolbar)
self.add(self._album_widget)
self.albums_selected = []
self.all_items = []
......@@ -104,7 +105,7 @@ class AlbumsView(BaseView):
return
# Update and display the album widget if not in selection mode
self._album_widget.update(item, self._selection_toolbar)
self._album_widget.update(item)
self._header_bar.props.state = HeaderBar.State.CHILD
self._header_bar.props.title = utils.get_album_title(item)
......
......@@ -65,7 +65,8 @@ class SearchView(BaseView):
self._albums_selected = []
self._albums = {}
self._albums_index = 0
self._album_widget = AlbumWidget(player, self, self._header_bar)
self._album_widget = AlbumWidget(
player, self, self._header_bar, self._selection_toolbar)
self.add(self._album_widget)
self._artists_albums_selected = []
......@@ -115,7 +116,7 @@ class SearchView(BaseView):
artist = self.model[_iter][3]
item = self.model[_iter][5]
self._album_widget.update(item, self._selection_toolbar)
self._album_widget.update(item)
self._header_bar.props.state = HeaderBar.State.SEARCH
self._header_bar.props.title = title
......
......@@ -61,12 +61,13 @@ class AlbumWidget(Gtk.EventBox):
return '<AlbumWidget>'
@log
def __init__(self, player, parent_view, header_bar):
def __init__(self, player, parent_view, header_bar, selection_toolbar):
"""Initialize the AlbumWidget.
:param player: The player object
:param parent_view: The view this widget is part of
:param header_bar: The header bar object
:param selection_toolbar: The selection toolbar object
"""
super().__init__()
......@@ -79,6 +80,7 @@ class AlbumWidget(Gtk.EventBox):
self._create_model()
self._album = None
self._header_bar = header_bar
self._selection_toolbar = selection_toolbar
# FIXME: Assigned to appease searchview
# _get_selected_songs
......@@ -114,11 +116,10 @@ class AlbumWidget(Gtk.EventBox):
)
@log
def update(self, item, selection_toolbar):
def update(self, item):
"""Update the album widget.
:param item: The grilo media item
:param selection_toolbar: The selection toolbar object
"""
# reset view
self._songs = []
......@@ -126,7 +127,6 @@ class AlbumWidget(Gtk.EventBox):
for widget in self._disc_listbox.get_children():
self._disc_listbox.remove(widget)
self.selection_toolbar = selection_toolbar
self._duration = 0
art = ArtImage(Art.Size.LARGE, item)
art.image = self._cover
......@@ -168,7 +168,7 @@ class AlbumWidget(Gtk.EventBox):
@log
def _on_selection_changed(self, widget):
n_items = len(self._disc_listbox.get_selected_items())
self.selection_toolbar.props.items_selected = n_items
self._selection_toolbar.props.items_selected = n_items
self._header_bar.items_selected = n_items
@log
......
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