[gnome-music/wip/jfelder/core-playlists-view] artistalbumswidget: Port to GtkListBox
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/core-playlists-view] artistalbumswidget: Port to GtkListBox
- Date: Wed, 10 Jul 2019 19:25:30 +0000 (UTC)
commit 918e95c699b2f8c1b8e8beffde1b877505066281
Author: Jean Felder <jfelder src gnome org>
Date: Wed Jul 10 19:39:53 2019 +0200
artistalbumswidget: Port to GtkListBox
data/org.gnome.Music.gresource.xml | 1 -
data/ui/ArtistAlbumsWidget.ui | 37 -------------------------------
gnomemusic/widgets/artistalbumswidget.py | 38 +++++---------------------------
3 files changed, 5 insertions(+), 71 deletions(-)
---
diff --git a/data/org.gnome.Music.gresource.xml b/data/org.gnome.Music.gresource.xml
index e84ee34c..62b6fcbd 100644
--- a/data/org.gnome.Music.gresource.xml
+++ b/data/org.gnome.Music.gresource.xml
@@ -9,7 +9,6 @@
<file preprocess="xml-stripblanks">ui/AlbumWidget.ui</file>
<file preprocess="xml-stripblanks">ui/AppMenu.ui</file>
<file preprocess="xml-stripblanks">ui/ArtistAlbumWidget.ui</file>
- <file preprocess="xml-stripblanks">ui/ArtistAlbumsWidget.ui</file>
<file preprocess="xml-stripblanks">ui/ArtistTile.ui</file>
<file preprocess="xml-stripblanks">ui/DiscBox.ui</file>
<file preprocess="xml-stripblanks">ui/DropDown.ui</file>
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index c7e2fe90..d19c0d34 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -33,8 +33,7 @@ from gnomemusic.widgets.artistalbumwidget import ArtistAlbumWidget
logger = logging.getLogger(__name__)
-@Gtk.Template(resource_path='/org/gnome/Music/ui/ArtistAlbumsWidget.ui')
-class ArtistAlbumsWidget(Gtk.Box):
+class ArtistAlbumsWidget(Gtk.ListBox):
"""Widget containing all albums by an artist
A vertical list of ArtistAlbumWidget, containing all the albums
@@ -44,8 +43,6 @@ class ArtistAlbumsWidget(Gtk.Box):
__gtype_name__ = 'ArtistAlbumsWidget'
- _artist_label = Gtk.Template.Child()
-
selected_items_count = GObject.Property(type=int, default=0, minimum=0)
selection_mode = GObject.Property(type=bool, default=False)
@@ -55,46 +52,21 @@ class ArtistAlbumsWidget(Gtk.Box):
@log
def __init__(
self, coreartist, player, window, selection_mode_allowed=False):
- super().__init__(orientation=Gtk.Orientation.VERTICAL)
+ super().__init__()
self._artist = coreartist.props.artist
self._model = coreartist.props.model
self._player = player
self._selection_mode_allowed = selection_mode_allowed
self._window = window
- self._artist_label.props.label = self._artist
-
self._widgets = []
- hbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
- self._album_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
- spacing=48)
- hbox.pack_start(self._album_box, False, False, 16)
-
- self._scrolled_window = Gtk.ScrolledWindow()
- self._scrolled_window.set_policy(Gtk.PolicyType.NEVER,
- Gtk.PolicyType.AUTOMATIC)
- self._scrolled_window.add(hbox)
- self.pack_start(self._scrolled_window, True, True, 0)
-
self._cover_size_group = Gtk.SizeGroup.new(
Gtk.SizeGroupMode.HORIZONTAL)
self._songs_grid_size_group = Gtk.SizeGroup.new(
Gtk.SizeGroupMode.HORIZONTAL)
- self._model.connect("items-changed", self._on_album_items_changed)
-
- # FIXME: Make this a ListBox as well.
- for album in self._model:
- self._add_album(album)
-
- self.show_all()
-
- def _on_album_items_changed(self, model, position, removed, added):
- # FIXME: Just does additions now, use ListBox as well to be
- # hassle free.
- for i in range(added):
- self._add_album(model[position + i])
+ self.bind_model(self._model, self._add_album)
self.show_all()
@@ -123,11 +95,11 @@ class ArtistAlbumsWidget(Gtk.Box):
GObject.BindingFlags.BIDIRECTIONAL
| GObject.BindingFlags.SYNC_CREATE)
- self._album_box.pack_start(widget, False, False, 0)
self._widgets.append(widget)
-
widget.connect("song-activated", self._song_activated)
+ return widget
+
@log
def _model_row_changed(self, model, path, itr):
if not self.props.selection_mode:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]