[gnome-music/wip/jfelder/player-playlist: 6/8] albumwidget: Refactor add_item method
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/player-playlist: 6/8] albumwidget: Refactor add_item method
- Date: Thu, 16 Aug 2018 14:57:12 +0000 (UTC)
commit 555da3e772b8e75a75ab323c0df90084d562f900
Author: Jean Felder <jfelder src gnome org>
Date: Wed Jun 13 17:37:12 2018 +0200
albumwidget: Refactor add_item method
Cosmetic changes. Code should be easier to read.
gnomemusic/widgets/albumwidget.py | 40 +++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
---
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index d0433d4f..72358841 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -197,34 +197,34 @@ class AlbumWidget(Gtk.EventBox):
def add_item(self, source, prefs, song, remaining, data=None):
"""Add a song to the item to album list.
- :param source: The grilo source
- :param prefs:
- :param song: The grilo media object
- :param remaining: Remaining number of items to add
+ If no song is remaining create DiscBox and display the widget.
+ :param GrlTrackerSource source: The grilo source
+ :param prefs: not used
+ :param GrlMedia song: The grilo media object
+ :param int remaining: Remaining number of items to add
:param data: User data
"""
if song:
self._songs.append(song)
-
- self._duration = self._duration + song.get_duration()
+ self._duration += song.get_duration()
return
- discs = {}
- for song in self._songs:
- disc_nr = song.get_album_disc_number()
- if disc_nr not in discs.keys():
- discs[disc_nr] = [song]
- else:
- discs[disc_nr].append(song)
- for disc_nr in discs:
- disc = self._create_disc_box(disc_nr, discs[disc_nr])
- self._disc_listbox.add(disc)
- if len(discs) == 1:
- disc.props.show_disc_label = False
-
if remaining == 0:
- self._set_duration_label()
+ discs = {}
+ for song in self._songs:
+ disc_nr = song.get_album_disc_number()
+ if disc_nr not in discs.keys():
+ discs[disc_nr] = [song]
+ else:
+ discs[disc_nr].append(song)
+
+ for disc_nr in discs:
+ disc = self._create_disc_box(disc_nr, discs[disc_nr])
+ if len(discs) == 1:
+ disc.props.show_disc_label = False
+ self._disc_listbox.add(disc)
+ self._set_duration_label()
self.show_all()
@log
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]