Skip to content

Commit

Permalink
Disable editing for Soundcloud tracks (#4097)
Browse files Browse the repository at this point in the history
* Disable editing for Soundcloud tracks

* This was never going to be useful anyway
* But we _do_ want track information, so separate these two options everywhere.

Fixes #4092

* Also add test for SC songsmenu

* No i18n for SC tests

* Remove import too
  • Loading branch information
declension committed Aug 17, 2022
1 parent 8910c14 commit fec3e52
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion quodlibet/browsers/soundcloud/library.py
Expand Up @@ -159,7 +159,7 @@ def can_change(self, k=None):
if k is None:
return ["~rating", "~#rating"]
else:
return "rating" in k
return k.endswith("rating")

def write(self):
if not self.client or not self.client.online:
Expand Down
2 changes: 1 addition & 1 deletion quodlibet/browsers/soundcloud/main.py
Expand Up @@ -130,7 +130,7 @@ def __init__(self, library):
self.show()

def Menu(self, songs, library, items):
return SongsMenu(library, songs, download=True, items=items)
return SongsMenu(library, songs, edit=False, download=True, items=items)

@property
def online(self):
Expand Down
5 changes: 3 additions & 2 deletions quodlibet/qltk/songsmenu.py
Expand Up @@ -268,8 +268,8 @@ def init_plugins(cls):
PluginManager.instance.register_handler(cls.plugins)

def __init__(self, library, songs, plugins=True, playlists=True, queue=True,
remove=True, delete=False, edit=True, ratings=True, show_files=True,
download=False, items=None, accels=True,
remove=True, delete=False, edit=True, info=True, ratings=True,
show_files=True, download=False, items=None, accels=True,
removal_confirmer=None, folder_chooser=None):
super().__init__()
# The library may actually be a librarian; if it is, use it,
Expand Down Expand Up @@ -388,6 +388,7 @@ def song_properties_cb(menu_item):
b.connect('activate', song_properties_cb)
self.append(b)

if info:
b = qltk.MenuItem(_("_Information"), Icons.DIALOG_INFORMATION)
b.set_sensitive(bool(songs))
if accels:
Expand Down
22 changes: 19 additions & 3 deletions tests/test_browsers_soundcloud.py
Expand Up @@ -3,17 +3,19 @@
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

import time
from unittest import TestCase

import time
from gi.repository import Gtk

from quodlibet import config
from quodlibet import const
from quodlibet.browsers.soundcloud import SoundcloudBrowser
from quodlibet.browsers.soundcloud.api import SoundcloudApiClient
from quodlibet.browsers.soundcloud.query import SoundcloudQuery, convert_time

from quodlibet import const
from quodlibet.query import QueryType
from quodlibet.util.dprint import print_d
from tests.test_browsers__base import TBrowserBase

NONE = set([])

Expand Down Expand Up @@ -72,6 +74,20 @@ def verify(self, text, expected, term='q'):
% (term, expected, terms))


class TestMenu(TBrowserBase):
Kind = SoundcloudBrowser

def test_songsmenu_has_information_but_no_edit(self):
menu = self.b.Menu([], self.library, [])
assert menu
items = [item.get_label() for item in menu.get_children()
if type(item) is not Gtk.SeparatorMenuItem]
# We're always in en_US
assert "_Rating" in items
assert "_Information" in items, "Should have included Information"
assert "Edit _Tags" not in items, "Shouldn't have included edit"


class TestHttpsDefault(TestCase):
def setUp(self):
config.init()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_qltk_songsmenu.py
Expand Up @@ -120,12 +120,12 @@ def choose(*args, **kwargs):
# TODO: some useful assertions, without needing a UI

def empty_menu_with(self, plugins=False, playlists=False, queue=False,
remove=False, delete=False, edit=False, ratings=False,
show_files=False, download=False,
remove=False, delete=False, edit=False, info=False,
ratings=False, show_files=False, download=False,
removal_confirmer=None, folder_chooser=None):
return SongsMenu(self.library, self.songs, plugins=plugins, playlists=playlists,
queue=queue, remove=remove, delete=delete, edit=edit,
ratings=ratings, show_files=show_files,
info=info, ratings=ratings, show_files=show_files,
removal_confirmer=removal_confirmer,
download=download, folder_chooser=folder_chooser)

Expand Down

0 comments on commit fec3e52

Please sign in to comment.