[gnome-music/wip/jfelder/artist-view-selection-fixes-3-34: 5/8] artistalbumswidget: Prevent the albums from being selectable
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/artist-view-selection-fixes-3-34: 5/8] artistalbumswidget: Prevent the albums from being selectable
- Date: Thu, 12 Sep 2019 21:24:53 +0000 (UTC)
commit c6ae8b6408d27d4283109e2378be8673049ce53e
Author: Jean Felder <jfelder src gnome org>
Date: Tue Sep 10 13:57:24 2019 +0200
artistalbumswidget: Prevent the albums from being selectable
If the model has already been loaded (if the artist has already been
selected from ArtistsView), _on_model_items_changed method will never
be called. Therefore, the rows associated with each album will be
selectable.
Fix the issue by creating the rows of each album in _add_album method
and setting the selectable property to False. Indeed, _add_album is
called everytime, whether the model has already been loaded or not.
Related: #300
data/ui/ArtistAlbumWidget.ui | 1 +
gnomemusic/widgets/artistalbumswidget.py | 13 +++++--------
2 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/data/ui/ArtistAlbumWidget.ui b/data/ui/ArtistAlbumWidget.ui
index a5ca2d2e..54ccb83f 100644
--- a/data/ui/ArtistAlbumWidget.ui
+++ b/data/ui/ArtistAlbumWidget.ui
@@ -5,6 +5,7 @@
<template parent="GtkBox" class="ArtistAlbumWidget">
<property name="margin_top">30</property>
<property name="margin_right">120</property>
+ <property name="visible">True</property>
<child>
<object class="CoverStack" id="_cover_stack">
<property name="visible">True</property>
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index 6dfead35..114ff46b 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -67,8 +67,6 @@ class ArtistAlbumsWidget(Gtk.ListBox):
self._songs_grid_size_group = Gtk.SizeGroup.new(
Gtk.SizeGroupMode.HORIZONTAL)
- self._model.props.model.connect_after(
- "items-changed", self. _on_model_items_changed)
self.bind_model(self._model, self._add_album)
self.get_style_context().add_class("artist-albums-widget")
@@ -90,6 +88,9 @@ class ArtistAlbumsWidget(Gtk.ListBox):
coremodel.set_player_model(PlayerPlaylist.Type.ARTIST, self._model)
def _add_album(self, corealbum):
+ row = Gtk.ListBoxRow()
+ row.props.selectable = False
+
widget = ArtistAlbumWidget(
corealbum, self._selection_mode_allowed,
self._songs_grid_size_group, self._cover_size_group)
@@ -99,15 +100,11 @@ class ArtistAlbumsWidget(Gtk.ListBox):
GObject.BindingFlags.BIDIRECTIONAL
| GObject.BindingFlags.SYNC_CREATE)
+ row.add(widget)
self._widgets.append(widget)
widget.connect("song-activated", self._song_activated)
- return widget
-
- def _on_model_items_changed(self, model, position, removed, added):
- for i in range(model.get_n_items()):
- row = self.get_row_at_index(i)
- row.props.selectable = False
+ return row
@log
def select_all(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]