Example #1
0
 def __song_properties(self, librarian):
     model, rows = self.get_selection().get_selected_rows()
     if rows:
         songs = [model[row][0] for row in rows]
     else:
         from quodlibet import app
         if app.player.song:
             songs = [app.player.song]
         else:
             return
     window = SongProperties(librarian, songs, parent=self)
     window.show()
Example #2
0
def _properties(app, value=None):
    library = app.library
    player = app.player
    window = app.window

    if value:
        if value in library:
            songs = [library[value]]
        else:
            songs = library.query(value)
    else:
        songs = [player.song]
    songs = filter(None, songs)

    if songs:
        window = SongProperties(library, songs, parent=window)
        window.show()
Example #3
0
 def __key_press(self, songlist, event, librarian, player):
     if qltk.is_accel(event, "<Primary>Return", "<Primary>KP_Enter"):
         self.__enqueue(self.get_selected_songs())
         return True
     elif qltk.is_accel(event, "<Primary>F"):
         self.emit('start-interactive-search')
         return True
     elif qltk.is_accel(event, "<Primary>Delete"):
         songs = self.get_selected_songs()
         if songs:
             trash_songs(self, songs, librarian)
         return True
     elif qltk.is_accel(event, "<alt>Return"):
         songs = self.get_selected_songs()
         if songs:
             window = SongProperties(librarian, songs, parent=self)
             window.show()
         return True
     elif qltk.is_accel(event, "<Primary>I"):
         songs = self.get_selected_songs()
         if songs:
             window = Information(librarian, songs, self)
             window.show()
         return True
     elif qltk.is_accel(event, "space", "KP_Space") and player is not None:
         player.paused = not player.paused
         return True
     return False
Example #4
0
    def __key_press(self, songlist, event, librarian):
        rating_accels = [
            "<ctrl>%d" % i for i in range(min(10, config.RATINGS.number + 1))]

        if qltk.is_accel(event, *rating_accels):
            rating = int(chr(event.keyval)) * config.RATINGS.precision
            self.__set_rating(rating, self.get_selected_songs(), librarian)
            return True
        elif qltk.is_accel(event, "<ctrl>Return", "<ctrl>KP_Enter"):
            self.__enqueue(self.get_selected_songs())
            return True
        elif qltk.is_accel(event, "<control>F"):
            self.emit('start-interactive-search')
            return True
        elif qltk.is_accel(event, "<alt>Return"):
            songs = self.get_selected_songs()
            if songs:
                window = SongProperties(librarian, songs, parent=self)
                window.show()
            return True
        elif qltk.is_accel(event, "<control>I"):
            songs = self.get_selected_songs()
            if songs:
                window = Information(librarian, songs, self)
                window.show()
            return True
        return False
Example #5
0
 def __key_pressed(self, widget, event, librarian):
     if qltk.is_accel(event, "<Primary>I"):
         songs = self.__get_selected_songs()
         if songs:
             window = Information(librarian, songs, self)
             window.show()
         return True
     elif qltk.is_accel(event, "<alt>Return"):
         songs = self.__get_selected_songs()
         if songs:
             window = SongProperties(librarian, songs, self)
             window.show()
         return True
     return False
Example #6
0
 def __key_pressed(self, view, event, librarian):
     # if ctrl+a is pressed, intercept and select the All entry instead
     if is_accel(event, "<Primary>a"):
         self.set_selected([])
         return True
     elif is_accel(event, "<Primary>Return", "<Primary>KP_Enter"):
         self.__enqueue(self.__get_selected_songs(sort=True))
         return True
     elif is_accel(event, "<alt>Return"):
         songs = self.__get_selected_songs(sort=True)
         if songs:
             window = SongProperties(librarian, songs, parent=self)
             window.show()
         return True
     elif is_accel(event, "<Primary>I"):
         songs = self.__get_selected_songs(sort=True)
         if songs:
             window = Information(librarian, songs, self)
             window.show()
         return True
     return False
Example #7
0
    def __key_pressed(self, widget, event):
        if qltk.is_accel(event, "Delete"):
            model, iter = self.__selected_playlists()
            if not iter:
                return False

            playlist = model[iter][0]
            response = confirm_remove_playlist_dialog_invoke(
                self, playlist, self.Confirmer)
            if response:
                playlist.delete()
                model.get_model().remove(
                    model.convert_iter_to_child_iter(iter))
            else:
                print_d("Playlist removal cancelled through prompt")
            return True
        elif qltk.is_accel(event, "F2"):
            model, iter = self.__selected_playlists()
            if iter:
                self._start_rename(model.get_path(iter))
            return True
        elif qltk.is_accel(event, "<Primary>I"):
            songs = self._get_playlist_songs()
            if songs:
                window = Information(self.library.librarian, songs, self)
                window.show()
            return True
        elif qltk.is_accel(event, "<Primary>Return", "<Primary>KP_Enter"):
            qltk.enqueue(self._get_playlist_songs())
            return True
        elif qltk.is_accel(event, "<alt>Return"):
            songs = self._get_playlist_songs()
            if songs:
                window = SongProperties(self.library.librarian, songs, self)
                window.show()
            return True
        return False
Example #8
0
    def test_edit_tags_popup_menu(self):
        song = AudioFile({"~filename": "/dev/null", "artist": "Person",
                          "album": "Dj Bars of FOO"})
        props = SongProperties(app.library, [song], app.window)
        box = EditTags(props, app.library)

        # Add a fake plugin
        plugin_cls = DummyEditPlugin
        box.handler = Mock(EditTagsPluginHandler)
        box.handler.plugins = [plugin_cls]
        model = box._view.get_model()

        # Make sure there's a row
        tag, value = "artist", song("artist")
        entry = ListEntry(tag, Comment(value))
        model.append(row=[entry])

        box._group_info = AudioFileGroup([song])
        box._view.select_by_func(lambda _: True)
        # Prevent weird mouse stuff failing in tests
        box._view.ensure_popup_selection = lambda: False
        box._popup_menu(box._view, props)
        box.show()
        assert plugin_cls.activations == [(tag, value)]
Example #9
0
class TSongProperties(TestCase):
    af1 = AudioFile({"title": "woo"})
    af1.sanitize(fsnative(u"invalid"))
    af2 = AudioFile({"title": "bar", "album": "quux"})
    af2.sanitize(fsnative(u"alsoinvalid"))

    def setUp(self):
        SongProperties.plugins = DummyPlugins()
        config.init()
        self.library = SongLibrary()

    def test_onesong(self):
        self.window = SongProperties(self.library, [self.af1])

    def test_twosong(self):
        self.window = SongProperties(self.library, [self.af2, self.af1])

    def test_changed(self):
        self.test_twosong()
        self.window.hide()
        self.library.emit('changed', [self.af2])
        while Gtk.events_pending():
            Gtk.main_iteration()

    def test_removed(self):
        self.test_twosong()
        self.window.hide()
        self.library.emit('removed', [self.af2])
        while Gtk.events_pending():
            Gtk.main_iteration()

    def tearDown(self):
        try:
            self.window.destroy()
        except AttributeError:
            pass
        else:
            del (self.window)
        self.library.destroy()
        del (SongProperties.plugins)
        config.quit()
class TSongProperties(TestCase):
    af1 = AudioFile({"title": "woo"})
    af1.sanitize(fsnative(u"invalid"))
    af2 = AudioFile({"title": "bar", "album": "quux"})
    af2.sanitize(fsnative(u"alsoinvalid"))

    def setUp(self):
        SongProperties.plugins = DummyPlugins()
        config.init()
        self.library = SongLibrary()

    def test_onesong(self):
        self.window = SongProperties(self.library, [self.af1])

    def test_twosong(self):
        self.window = SongProperties(self.library, [self.af2, self.af1])

    def test_changed(self):
        self.test_twosong()
        self.window.hide()
        self.library.emit('changed', [self.af2])
        while Gtk.events_pending():
            Gtk.main_iteration()

    def test_removed(self):
        self.test_twosong()
        self.window.hide()
        self.library.emit('removed', [self.af2])
        while Gtk.events_pending():
            Gtk.main_iteration()

    def tearDown(self):
        try:
            self.window.destroy()
        except AttributeError:
            pass
        else:
            del(self.window)
        self.library.destroy()
        del(SongProperties.plugins)
        config.quit()
Example #11
0
 def __key_pressed(self, view, event, librarian):
     # if ctrl+a is pressed, intercept and select the All entry instead
     if is_accel(event, "<Primary>a"):
         self.set_selected([])
         return True
     elif is_accel(event, "<Primary>Return", "<Primary>KP_Enter"):
         qltk.enqueue(self.__get_selected_songs(sort=True))
         return True
     elif is_accel(event, "<alt>Return"):
         songs = self.__get_selected_songs(sort=True)
         if songs:
             window = SongProperties(librarian, songs, parent=self)
             window.show()
         return True
     elif is_accel(event, "<Primary>I"):
         songs = self.__get_selected_songs(sort=True)
         if songs:
             window = Information(librarian, songs, self)
             window.show()
         return True
     return False
Example #12
0
 def song_properties_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = SongProperties(librarian, songs, parent)
     window.show()
Example #13
0
 def song_properties_cb(menu_item):
     window = SongProperties(librarian, songs, parent)
     window.show()
Example #14
0
 def on_properties(*args):
     song = player.song
     window = SongProperties(app.librarian, [song])
     window.show()
Example #15
0
 def test_edit_tags_starts(self):
     props = SongProperties(app.library, [], quodlibet.app.window)
     EditTags(props, app.library)
Example #16
0
 def test_twosong(self):
     self.window = SongProperties(self.library, [self.af2, self.af1])
 def test_twosong(self):
     self.window = SongProperties(self.library, [self.af2, self.af1])
Example #18
0
 def __current_song_prop(self, *args):
     song = app.player.song
     if song:
         librarian = self.__library.librarian
         window = SongProperties(librarian, [song], parent=self)
         window.show()
 def __properties(self, *args):
     song = app.player.song
     if song:
         window = SongProperties(app.librarian, [song])
         window.show()
Example #20
0
 def song_properties_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = SongProperties(librarian, songs, parent)
     window.show()
Example #21
0
 def __properties(self, *args):
     song = app.player.song
     if song:
         window = SongProperties(app.librarian, [song])
         window.show()
Example #22
0
 def on_properties(*args):
     song = player.song
     window = SongProperties(app.librarian, [song])
     window.show()
Example #23
0
 def __current_song_prop(self, *args):
     song = app.player.song
     if song:
         librarian = self.__library.librarian
         window = SongProperties(librarian, [song], parent=self)
         window.show()