Commit 5c6fb168 authored by RashiSah's avatar RashiSah Committed by Marinus Schraal

Consistently use song as identifier

Music was using both track and song to indicate the same kind of item in
different parts the source, use just song instead.

https://bugzilla.gnome.org/show_bug.cgi?id=774470
parent dd4ba5e8
......@@ -58,7 +58,7 @@ class AlbumWidget(Gtk.EventBox):
"""
Gtk.EventBox.__init__(self)
self._tracks = []
self._songs = []
scale = self.get_scale_factor()
self._cache = AlbumArtCache(scale)
......@@ -97,7 +97,7 @@ class AlbumWidget(Gtk.EventBox):
view_box.add(self._disc_listbox)
# FIXME: Assigned to appease searchview
# get_selected_tracks
# _get_selected_songs
self.view = self._disc_listbox
self.add(self._builder.get_object('AlbumWidget'))
......@@ -140,7 +140,7 @@ class AlbumWidget(Gtk.EventBox):
:param selection_toolbar: The selection toolbar object
"""
# reset view
self._tracks = []
self._songs = []
self._create_model()
for widget in self._disc_listbox.get_children():
self._disc_listbox.remove(widget)
......@@ -225,13 +225,13 @@ class AlbumWidget(Gtk.EventBox):
self._player.actionbar.set_visible(True)
@log
def _create_disc_box(self, disc_nr, disc_tracks):
def _create_disc_box(self, disc_nr, disc_songs):
disc_box = DiscBox(self._model)
disc_box.set_tracks(disc_tracks)
disc_box.set_songs(disc_songs)
disc_box.set_disc_number(disc_nr)
disc_box.set_columns(1)
disc_box.show_song_numbers(False)
disc_box.connect('track-activated', self._track_activated)
disc_box.connect('song-activated', self._song_activated)
disc_box.connect('selection-toggle', self._selection_mode_toggled)
return disc_box
......@@ -246,7 +246,7 @@ class AlbumWidget(Gtk.EventBox):
@log
def _track_activated(self, widget, song_widget):
def _song_activated(self, widget, song_widget):
if not song_widget.can_be_played:
return
......@@ -261,28 +261,28 @@ class AlbumWidget(Gtk.EventBox):
return True
@log
def add_item(self, source, prefs, track, remaining, data=None):
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 track: The grilo media object
:param song: The grilo media object
:param remaining: Remaining number of items to add
:param data: User data
"""
if track:
self._tracks.append(track)
if song:
self._songs.append(song)
self._duration = self._duration + track.get_duration()
self._duration = self._duration + song.get_duration()
return
discs = {}
for track in self._tracks:
disc_nr = track.get_album_disc_number()
for song in self._songs:
disc_nr = song.get_album_disc_number()
if disc_nr not in discs.keys():
discs[disc_nr] = [track]
discs[disc_nr] = [song]
else:
discs[disc_nr].append(track)
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)
......
......@@ -130,7 +130,7 @@ class ArtistAlbumsWidget(Gtk.Box):
self._widgets.append(widget)
if is_last_album:
widget.connect('tracks-loaded', self._on_last_album_displayed)
widget.connect('songs-loaded', self._on_last_album_displayed)
@log
def _update_model(self, player, playlist, current_iter):
......
......@@ -35,7 +35,7 @@ import gnomemusic.utils as utils
class ArtistAlbumWidget(Gtk.Box):
__gsignals__ = {
'tracks-loaded': (GObject.SignalFlags.RUN_FIRST, None, ()),
'songs-loaded': (GObject.SignalFlags.RUN_FIRST, None, ()),
}
def __repr__(self):
......@@ -63,7 +63,8 @@ class ArtistAlbumWidget(Gtk.Box):
self._header_bar = header_bar
self._selection_mode = False
self._selection_mode_allowed = selection_mode_allowed
self._tracks = []
self._songs = []
self._header_bar._select_button.connect(
'toggled', self._on_header_select_button_toggled)
......@@ -97,14 +98,14 @@ class ArtistAlbumWidget(Gtk.Box):
grilo.populate_album_songs(self._media, self._add_item)
def create_disc_box(self, disc_nr, disc_tracks):
def create_disc_box(self, disc_nr, disc_songs):
disc_box = DiscBox(self._model)
disc_box.set_tracks(disc_tracks)
disc_box.set_songs(disc_songs)
disc_box.set_disc_number(disc_nr)
disc_box.set_columns(2)
disc_box.show_duration(False)
disc_box.show_favorites(False)
disc_box.connect('track-activated', self._track_activated)
disc_box.connect('song-activated', self._song_activated)
disc_box.connect('selection-toggle', self._selection_mode_toggled)
return disc_box
......@@ -138,18 +139,18 @@ class ArtistAlbumWidget(Gtk.Box):
self._player.actionbar.set_visible(True)
@log
def _add_item(self, source, prefs, track, remaining, data=None):
if track:
self._tracks.append(track)
def _add_item(self, source, prefs, song, remaining, data=None):
if song:
self._songs.append(song)
return
discs = {}
for track in self._tracks:
disc_nr = track.get_album_disc_number()
for song in self._songs:
disc_nr = song.get_album_disc_number()
if disc_nr not in discs.keys():
discs[disc_nr] = [track]
discs[disc_nr] = [song]
else:
discs[disc_nr].append(track)
discs[disc_nr].append(song)
for disc_nr in discs:
disc = self.create_disc_box(disc_nr, discs[disc_nr])
......@@ -158,7 +159,7 @@ class ArtistAlbumWidget(Gtk.Box):
disc.show_disc_label(False)
if remaining == 0:
self.emit("tracks-loaded")
self.emit("songs-loaded")
@log
def _update_album_art(self):
......@@ -170,7 +171,7 @@ class ArtistAlbumWidget(Gtk.Box):
self.cover.set_from_surface(surface)
@log
def _track_activated(self, widget, song_widget):
def _song_activated(self, widget, song_widget):
if (not song_widget.can_be_played
or self._selection_mode):
return
......
......@@ -143,7 +143,7 @@ class DiscBox(Gtk.Box):
__gsignals__ = {
'selection-changed': (GObject.SignalFlags.RUN_FIRST, None, ()),
'selection-toggle': (GObject.SignalFlags.RUN_FIRST, None, ()),
'track-activated': (GObject.SignalFlags.RUN_FIRST, None, (Gtk.Widget,))
'song-activated': (GObject.SignalFlags.RUN_FIRST, None, (Gtk.Widget,))
}
......@@ -237,16 +237,16 @@ class DiscBox(Gtk.Box):
self._disc_songs_flowbox.foreach(child_show_song_number)
@log
def set_tracks(self, tracks):
def set_songs(self, songs):
"""Songs to display
:param list tracks: A list of Grilo media items to
:param list songs: A list of Grilo media items to
add to the widget
"""
for track in tracks:
song_widget = self._create_song_widget(track)
for song in songs:
song_widget = self._create_song_widget(song)
self._disc_songs_flowbox.insert(song_widget, -1)
track.song_widget = song_widget
song.song_widget = song_widget
@log
def set_selection_mode(self, selection_mode):
......@@ -298,11 +298,11 @@ class DiscBox(Gtk.Box):
self._disc_songs_flowbox.foreach(child_select_none)
@log
def _create_song_widget(self, track):
def _create_song_widget(self, song):
"""Helper function to create a song widget for a
single song
:param track: A Grilo media item
:param song: A Grilo media item
:returns: A complete song widget
:rtype: Gtk.EventBox
"""
......@@ -311,21 +311,21 @@ class DiscBox(Gtk.Box):
song_widget = builder.get_object('eventbox1')
self._songs.append(song_widget)
title = utils.get_media_title(track)
title = utils.get_media_title(song)
itr = self._model.append(None)
self._model[itr][0, 1, 2, 5, 6] = [title, '', '', track, False]
self._model[itr][0, 1, 2, 5, 6] = [title, '', '', song, False]
song_widget.itr = itr
song_widget.model = self._model
track_number = track.get_track_number()
if track_number == 0:
track_number = ""
song_number = song.get_track_number()
if song_number == 0:
song_number = ""
song_widget.number = builder.get_object('num')
song_widget.number.set_markup(
'<span color=\'grey\'>{}</span>'.format(track_number))
'<span color=\'grey\'>{}</span>'.format(song_number))
song_widget.number.set_no_show_all(True)
song_widget.title = builder.get_object('title')
......@@ -333,7 +333,7 @@ class DiscBox(Gtk.Box):
song_widget.title.set_max_width_chars(50)
song_widget.duration = builder.get_object('duration')
time = utils.seconds_to_string(track.get_duration())
time = utils.seconds_to_string(song.get_duration())
song_widget.duration.set_text(time)
song_widget.check_button = builder.get_object('select')
......@@ -348,10 +348,10 @@ class DiscBox(Gtk.Box):
Gtk.IconSize.SMALL_TOOLBAR)
song_widget.now_playing_sign.set_no_show_all(True)
song_widget.can_be_played = True
song_widget.connect('button-release-event', self._track_activated)
song_widget.connect('button-release-event', self._song_activated)
song_widget.star_image = builder.get_object('starimage')
song_widget.star_image.set_favorite(track.get_favourite())
song_widget.star_image.set_favorite(song.get_favourite())
song_widget.star_image.set_visible(True)
song_widget.starevent = builder.get_object('starevent')
......@@ -390,13 +390,13 @@ class DiscBox(Gtk.Box):
song_widget.check_button.set_active(False)
@log
def _track_activated(self, widget, event):
def _song_activated(self, widget, event):
# FIXME: don't think keys work correctly, if they did ever
# even.
if (not event.button == Gdk.BUTTON_SECONDARY
or (event.button == Gdk.BUTTON_PRIMARY
and event.state & Gdk.ModifierType.CONTROL_MASK)):
self.emit('track-activated', widget)
self.emit('song-activated', widget)
if self._selection_mode:
itr = widget.itr
self._model[itr][6] = not self._model[itr][6]
......
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