[gnome-music/wip/merge: 234/343] artists: code cleanup
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/merge: 234/343] artists: code cleanup
- Date: Thu, 25 Jul 2013 11:32:28 +0000 (UTC)
commit 644b8db1df1a83d91dc22f69813ee1ffac59d988
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Wed Jul 17 19:51:29 2013 +0200
artists: code cleanup
gnomemusic/widgets.py | 74 ++++++++++++++++++++----------------------------
1 files changed, 31 insertions(+), 43 deletions(-)
---
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 6a0cb7d..b703c4a 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -277,7 +277,7 @@ class AlbumWidget(Gtk.EventBox):
iter = playlist.get_iter_first()
if iter is None:
return False
- songPassed = False
+ song_passed = False
while True:
song = playlist.get_value(iter, 5)
@@ -285,8 +285,8 @@ class AlbumWidget(Gtk.EventBox):
if (song == currentSong):
title = "<b>%s</b>" % escapedTitle
iconVisible = True
- songPassed = True
- elif (songPassed):
+ song_passed = True
+ elif (song_passed):
title = "<span>%s</span>" % escapedTitle
iconVisible = False
else:
@@ -339,7 +339,6 @@ class ArtistAlbums(Gtk.VBox):
self.show_all()
self.player.connect('playlist-item-changed', self.update_model)
- #self.emit("albums-loaded")
def add_album(self, album):
widget = ArtistAlbumWidget(self.artist, album, self.player, self.model)
@@ -356,44 +355,39 @@ class ArtistAlbums(Gtk.VBox):
return False
currentSong = playlist.get_value(currentIter, 5)
+ song_passed = False
itr = playlist.get_iter_first()
- if itr is not None:
- return False
- songPassed = False
- while playlist.iter_next(itr):
+ while itr is not None:
song = playlist.get_value(itr, 5)
- songWidget = song.songWidget
+ song_widget = song.song_widget
- if not songWidget.can_be_played:
+ if not song_widget.can_be_played:
continue
escapedTitle = GLib.markup_escape_text(song.get_title(), -1)
if (song == currentSong):
- songWidget.nowPlayingSign.show()
- songWidget.title.set_markup("<b>" + escapedTitle + "</b>")
- songPassed = True
- elif (songPassed):
- songWidget.nowPlayingSign.hide()
- songWidget.title.set_markup("<span>" +
- escapedTitle + "</span>")
+ song_widget.now_playing_sign.show()
+ song_widget.title.set_markup("<b>%s</b>" % escapedTitle)
+ song_passed = True
+ elif (song_passed):
+ song_widget.now_playing_sign.hide()
+ song_widget.title.set_markup("<span>%s</span>" % escapedTitle)
else:
- songWidget.nowPlayingSign.hide()
- songWidget.title.set_markup("<span color='grey'>" +
- escapedTitle + "</span>")
+ song_widget.now_playing_sign.hide()
+ song_widget.title.set_markup("<span color='grey'>%s</span>" % escapedTitle)
+ itr = playlist.iter_next(itr)
return False
def clean_model(self):
itr = self.model.get_iter_first()
- if itr is not None:
- return False
while itr is not None:
song = self.model.get_value(itr, 5)
song_widget = song.song_widget
escapedTitle = GLib.markup_escape_text(song.get_title(), -1)
if song_widget.can_be_played is not None:
- song_widget.nowPlayingSign.hide()
- song_widget.title.set_markup("<span>" + escapedTitle + "</span>")
+ song_widget.now_playing_sign.hide()
+ song_widget.title.set_markup("<span>%s</span>" % escapedTitle)
itr = self.model.iter_next(itr)
return False
@@ -452,7 +446,7 @@ class AllArtistsAlbums(ArtistAlbums):
def add_item(self, source, param, item):
if item is not None:
- self._offset = self._offset + 1
+ self._offset += 1
self.add_album(item)
def _get_remaining_item_count(self):
@@ -485,35 +479,31 @@ class ArtistAlbumWidget(Gtk.HBox):
self.ui.get_object("title").set_label(album.get_title())
if album.get_creation_date() is not None:
self.ui.get_object("year").set_markup(
- "<span color='grey'>(" +
- str(album.get_creation_date().get_year()) + ")</span>"
- )
+ "<span color='grey'>(%s)</span>" %
+ str(album.get_creation_date().get_year()))
self.tracks = []
grilo.get_album_songs(album.get_id(), self.get_songs)
self.pack_start(self.ui.get_object("ArtistAlbumWidget"), True, True, 0)
self.show_all()
- #self.emit("artist-album-loaded")
def get_songs(self, source, prefs, track, unknown, data, error):
if track is not None:
self.tracks.append(track)
-
else:
for i, track in enumerate(self.tracks):
ui = Gtk.Builder()
ui.add_from_resource('/org/gnome/music/TrackWidget.ui')
song_widget = ui.get_object("eventbox1")
self.songs.append(song_widget)
- ui.get_object("num").set_markup("<span color='grey'>"
- + str(len(self.songs))
- + "</span>")
+ ui.get_object("num").set_markup("<span color='grey'>%d</span>" %
+ len(self.songs))
if track.get_title() is not None:
ui.get_object("title").set_text(track.get_title())
ui.get_object("title").set_alignment(0.0, 0.5)
self.ui.get_object("grid1").attach(
song_widget,
int(i / (len(self.tracks) / 2)),
- int((i) % (len(self.tracks) / 2)), 1, 1
+ int(i % (len(self.tracks) / 2)), 1, 1
)
track.song_widget = song_widget
itr = self.model.append()
@@ -527,12 +517,12 @@ class ArtistAlbumWidget(Gtk.HBox):
[0, 1, 2, 3, 4, 5],
[track.get_title(), "", "", False,
NOW_PLAYING_ICON_NAME, track])
- song_widget.nowPlayingSign = ui.get_object("image1")
- song_widget.nowPlayingSign.set_from_icon_name(
+ song_widget.now_playing_sign = ui.get_object("image1")
+ song_widget.now_playing_sign.set_from_icon_name(
NOW_PLAYING_ICON_NAME,
Gtk.IconSize.SMALL_TOOLBAR)
- song_widget.nowPlayingSign.set_no_show_all("True")
- song_widget.nowPlayingSign.set_alignment(0.0, 0.6)
+ song_widget.now_playing_sign.set_no_show_all("True")
+ song_widget.now_playing_sign.set_alignment(0.0, 0.6)
song_widget.can_be_played = True
song_widget.connect('button-release-event',
self.track_selected)
@@ -542,15 +532,13 @@ class ArtistAlbumWidget(Gtk.HBox):
self.model.set(itr, [0, 1, 2, 3, 4, 5],
[track.get_title(), "", "", True,
ERROR_ICON_NAME, track])
- song_widget.nowPlayingSign = ui.get_object("image1")
- song_widget.nowPlayingSign.set_from_icon_name(
+ song_widget.now_playing_sign = ui.get_object("image1")
+ song_widget.now_playing_sign.set_from_icon_name(
ERROR_ICON_NAME,
Gtk.IconSize.SMALL_TOOLBAR)
- song_widget.nowPlayingSign.set_alignment(0.0, 0.6)
+ song_widget.now_playing_sign.set_alignment(0.0, 0.6)
song_widget.can_be_played = False
self.ui.get_object("grid1").show_all()
- #FIXME: Add signal
- #self.emit("tracks-loaded")
def _update_album_art(self):
ALBUM_ART_CACHE.lookup(128, self.artist,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]