Commit a8e75b53 authored by Jean Felder's avatar Jean Felder

albumwidget: Fix selection-mode regression

Displaying an AlbumWidget from the AlbumView causes a freeze as the
selection-mode property is bound each time the widget is displayed.
Move the bind_property to the constructor to solve this issue.

closes: #200
parent 6d20d46b
......@@ -47,8 +47,8 @@ class AlbumsView(BaseView):
super().__init__('albums', _("Albums"), window, None)
self._queue = LifoQueue()
self._album_widget = AlbumWidget(player, self)
self.player = player
self._album_widget = AlbumWidget(player, self, self._header_bar)
self.add(self._album_widget)
self.albums_selected = []
self.all_items = []
......@@ -104,8 +104,7 @@ class AlbumsView(BaseView):
return
# Update and display the album widget if not in selection mode
self._album_widget.update(
item, self._header_bar, self._selection_toolbar)
self._album_widget.update(item, self._selection_toolbar)
self._header_bar.props.state = HeaderBar.State.CHILD
self._header_bar.props.title = utils.get_album_title(item)
......
......@@ -65,7 +65,7 @@ class SearchView(BaseView):
self._albums_selected = []
self._albums = {}
self._albums_index = 0
self._album_widget = AlbumWidget(player, self)
self._album_widget = AlbumWidget(player, self, self._header_bar)
self.add(self._album_widget)
self._artists_albums_selected = []
......@@ -115,8 +115,7 @@ class SearchView(BaseView):
artist = self.model[_iter][3]
item = self.model[_iter][5]
self._album_widget.update(
item, self._header_bar, self._selection_toolbar)
self._album_widget.update(item, self._selection_toolbar)
self._header_bar.props.state = HeaderBar.State.SEARCH
self._header_bar.props.title = title
......
......@@ -61,11 +61,12 @@ class AlbumWidget(Gtk.EventBox):
return '<AlbumWidget>'
@log
def __init__(self, player, parent_view):
def __init__(self, player, parent_view, header_bar):
"""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
"""
super().__init__()
......@@ -77,7 +78,7 @@ class AlbumWidget(Gtk.EventBox):
self._create_model()
self._album = None
self._header_bar = None
self._header_bar = header_bar
# FIXME: Assigned to appease searchview
# _get_selected_songs
......@@ -87,6 +88,11 @@ class AlbumWidget(Gtk.EventBox):
'selection-mode', self._disc_listbox, 'selection-mode',
GObject.BindingFlags.BIDIRECTIONAL)
self.bind_property(
'selection-mode', self._header_bar, 'selection-mode',
GObject.BindingFlags.BIDIRECTIONAL |
GObject.BindingFlags.SYNC_CREATE)
self.show_all()
@log
......@@ -108,11 +114,10 @@ class AlbumWidget(Gtk.EventBox):
)
@log
def update(self, item, header_bar, selection_toolbar):
def update(self, item, selection_toolbar):
"""Update the album widget.
:param item: The grilo media item
:param header_bar: The header bar object
:param selection_toolbar: The selection toolbar object
"""
# reset view
......@@ -122,7 +127,6 @@ class AlbumWidget(Gtk.EventBox):
self._disc_listbox.remove(widget)
self.selection_toolbar = selection_toolbar
self._header_bar = header_bar
self._duration = 0
art = ArtImage(Art.Size.LARGE, item)
art.image = self._cover
......@@ -140,11 +144,6 @@ class AlbumWidget(Gtk.EventBox):
self._set_composer_label(item)
self.bind_property(
'selection-mode', self._header_bar, 'selection-mode',
GObject.BindingFlags.BIDIRECTIONAL |
GObject.BindingFlags.SYNC_CREATE)
self._player.connect('song-changed', self._update_model)
@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