Commit ce5dcb4e authored by Cédric Bellegarde's avatar Cédric Bellegarde

Fix #2489

parent 23b10d2d
Pipeline #197191 passed with stage
in 3 minutes and 54 seconds
......@@ -10,7 +10,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from gi.repository import Gio, GLib
from gi.repository import Gio
from gettext import gettext as _
......@@ -40,27 +40,8 @@ class CurrentAlbumsMenu(Gio.Menu):
"activate", self.__on_save_playback_action_activate)
App().add_action(save_playback_action)
menu.append(_("Create a new playlist"), "app.save_playback")
show_track_number_action = Gio.SimpleAction.new_stateful(
"show_track_number",
None,
GLib.Variant.new_boolean(
App().settings.get_value("show-tag-tracknumber")))
App().add_action(show_track_number_action)
show_track_number_action.connect(
"change-state", self.__on_show_track_number_change_state)
menu.append(_("Show tracks number"), "app.show_track_number")
self.append_section(_("Playing albums"), menu)
def __on_show_track_number_change_state(self, action, variant):
"""
Update settings and reload view
@param Gio.SimpleAction
@param GLib.Variant
"""
action.set_state(variant)
App().settings.set_value("show-tag-tracknumber", variant)
App().window.container.reload_view()
def __on_save_playback_action_activate(self, action, variant):
"""
Create a new playlist based on current playback
......
......@@ -10,11 +10,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from gi.repository import Gio, Gtk, GLib
from gi.repository import Gio, Gtk
from gettext import gettext as _
from lollypop.define import App, MARGIN_SMALL, ViewType, Type
from lollypop.define import App, MARGIN_SMALL, Type
class PlaylistMenu(Gio.Menu):
......@@ -61,17 +61,6 @@ class PlaylistMenu(Gio.Menu):
menu.append(_("Remove playlist"), "app.remove_pl_action")
from lollypop.menu_playback import PlaylistPlaybackMenu
playback_menu = PlaylistPlaybackMenu(playlist_id)
if view_type & ViewType.BANNER:
show_track_number = Gio.SimpleAction.new_stateful(
"show_track_number",
None,
GLib.Variant.new_boolean(
App().settings.get_value("show-tag-tracknumber")))
App().add_action(show_track_number)
show_track_number.connect("change-state",
self.__on_show_track_number_change_state)
playback_menu.append(_("Show tracks number"),
"app.show_track_number")
self.append_section(_("Playlist"), playback_menu)
section = Gio.Menu()
self.append_section(_("Add to"), section)
......@@ -115,16 +104,6 @@ class PlaylistMenu(Gio.Menu):
App().window.container.add_overlay(notification)
notification.set_reveal_child(True)
def __on_show_track_number_change_state(self, action, variant):
"""
Update settings and reload view
@param Gio.SimpleAction
@param GLib.Variant
"""
action.set_state(variant)
App().settings.set_value("show-tag-tracknumber", variant)
App().window.container.reload_view()
def __on_save_action_activate(self, action, variant):
"""
Save playlist to file
......
......@@ -211,11 +211,9 @@ class AlbumTracksView(TracksView):
for track in tracks:
# If user does not want to show real tracknumber and we are
# in album view, calculate a fake tracknumber
if not self.__show_tag_tracknumber and\
self.view_type & ViewType.ALBUM:
if not self.__show_tag_tracknumber:
track.set_number(position + 1)
row = TrackRow(track, self.__album.artist_ids, self.view_type,
self.__show_tag_tracknumber)
row = TrackRow(track, self.__album.artist_ids, self.view_type)
row.show()
row.connect("removed", self.__on_track_row_removed)
widget.add(row)
......
......@@ -89,7 +89,7 @@ class SearchTracksView(TracksView, SignalsHelper):
"""
for track in tracks:
track.set_number(position + 1)
row = TrackRow(track, [], self.view_type, False)
row = TrackRow(track, [], self.view_type)
row.show()
widget.add(row)
position += 1
......
......@@ -47,18 +47,16 @@ class TrackRow(Gtk.ListBoxRow):
height = min_height
return height
def __init__(self, track, album_artist_ids, view_type, show_track_number):
def __init__(self, track, album_artist_ids, view_type):
"""
Init row widgets
@param track as Track
@param album_artist_ids as [int]
@param view_type as ViewType
@param show_track_number as bool
"""
# We do not use Gtk.Builder for speed reasons
Gtk.ListBoxRow.__init__(self)
self.__view_type = view_type
self.__show_track_number = show_track_number
self._track = track
self._grid = Gtk.Grid()
self._grid.set_property("valign", Gtk.Align.CENTER)
......@@ -175,23 +173,14 @@ class TrackRow(Gtk.ListBoxRow):
self._num_label.get_style_context().add_class("queued")
pos = App().player.get_track_position(self._track.id)
self._num_label.set_text(str(pos))
self._num_label.show()
elif self.__show_track_number:
self._num_label.get_style_context().remove_class("queued")
# Just track number for albums or playlists if only one album
if self.__view_type & ViewType.ALBUM or\
len(self._track.album.discs) == 1:
self._num_label.set_text(str(self._track.number))
# Prepend disc number
elif len(self._track.album.discs) > 1:
else:
if len(self._track.album.discs) > 1:
discnumber = App().tracks.get_discnumber(self._track.id)
label = "(%s) %s" % (discnumber, self._track.number)
self._num_label.set_text(label)
self._num_label.show()
else:
else:
label = str(self._track.number)
self._num_label.set_text(label)
self._num_label.get_style_context().remove_class("queued")
self._num_label.set_text("")
self._num_label.hide()
def popup_menu(self, parent, x=None, y=None):
"""
......
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