Exemple #1
0
 def __information(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 = Information(librarian, songs, self)
     window.show()
Exemple #2
0
 def __information(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 = Information(librarian, songs, self)
     window.show()
Exemple #3
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
class TInformation(TestCase):
    def setUp(self):
        quodlibet.config.init()
        init_fake_app()
        self.inf = None
        self.library = SongLibrary()

    def tearDown(self):
        destroy_fake_app()
        self.library.destroy()
        quodlibet.config.quit()
        if self.inf:
            self.inf.destroy()

    def test_none(self):
        Information(self.library, []).destroy()

    def test_one(self):
        f = AF({"~filename": fsnative(u"/dev/null")})
        self.inf = Information(self.library, [f])
        self.assert_child_is(OneSong)

    def test_two(self):
        f = AF({"~filename": fsnative(u"/dev/null")})
        f2 = AF({"~filename": fsnative(u"/dev/null2")})
        self.inf = Information(self.library, [f, f2])
        self.assert_child_is(ManySongs)

    def test_album(self):
        f = AF({"~filename": fsnative(u"/dev/null"), "album": "woo"})
        f2 = AF({"~filename": fsnative(u"/dev/null2"), "album": "woo"})
        self.inf = Information(self.library, [f, f2])
        self.assert_child_is(OneAlbum)

    def test_album_special_chars(self):
        f = AF({"~filename": fsnative(u"/dev/null"), "album": "woo & hoo"})
        f2 = AF({"~filename": fsnative(u"/dev/null2"), "album": "woo & hoo"})
        self.inf = Information(self.library, [f, f2])
        self.assert_child_is(OneAlbum)

    def test_artist(self):
        f = AF({"~filename": fsnative(u"/dev/null"), "artist": "woo"})
        f2 = AF({"~filename": fsnative(u"/dev/null2"), "artist": "woo"})
        self.inf = Information(self.library, [f, f2])
        self.assert_child_is(OneArtist)

    def test_performer_roles(self):
        f = AF({"~filename": fsnative(u"/dev/null"), "performer:piano": "woo"})
        self.inf = Information(self.library, [f])
        self.assert_child_is(OneSong)

    def test_remove_song(self):
        f = AF({"~filename": fsnative(u"/dev/null"), "artist": "woo"})
        f2 = AF({"~filename": fsnative(u"/dev/null2"), "artist": "woo"})
        self.library.add([f, f2])
        self.inf = Information(self.library, [f, f2])
        self.library.remove([f])

    def assert_child_is(self, cls):
        self.failUnless(isinstance(self.inf.get_child(), cls))
 def __key_press(self, songlist, event, librarian):
     if event.string in ['0', '1', '2', '3', '4']:
         rating = min(1.0, int(event.string) * config.RATINGS.precision)
         self.__set_rating(rating, self.get_selected_songs(), librarian)
         return True
     elif qltk.is_accel(event, "<ctrl>Return") or \
         qltk.is_accel(event, "<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
Exemple #6
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
Exemple #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]
            dialog = ConfirmRemovePlaylistDialog(self, playlist)
            if dialog.run() == Gtk.ResponseType.YES:
                playlist.delete()
                model.get_model().remove(
                    model.convert_iter_to_child_iter(iter))
            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
Exemple #8
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]
            if confirm_remove_playlist_dialog_invoke(self, playlist,
                                                     self.Confirmer):
                playlist.delete()
            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.songs_lib.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.songs_lib.librarian, songs, self)
                window.show()
            return True
        return False
Exemple #9
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]
            dialog = ConfirmRemovePlaylistDialog(self, playlist)
            if dialog.run() == Gtk.ResponseType.YES:
                playlist.delete()
                model.get_model().remove(
                    model.convert_iter_to_child_iter(iter))
            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
Exemple #10
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
class TInformation(TestCase):

    def setUp(self):
        quodlibet.config.init()
        init_fake_app()
        self.inf = None
        self.library = SongLibrary()

    def tearDown(self):
        destroy_fake_app()
        self.library.destroy()
        quodlibet.config.quit()
        if self.inf:
            self.inf.destroy()

    def test_none(self):
        Information(self.library, []).destroy()

    def test_one(self):
        f = AF({"~filename": fsnative(u"/dev/null")})
        self.inf = Information(self.library, [f])
        self.assert_child_is(OneSong)

    def test_two(self):
        f = AF({"~filename": fsnative(u"/dev/null")})
        f2 = AF({"~filename": fsnative(u"/dev/null2")})
        self.inf = Information(self.library, [f, f2])
        self.assert_child_is(ManySongs)

    def test_album(self):
        f = AF({"~filename": fsnative(u"/dev/null"), "album": "woo"})
        f2 = AF({"~filename": fsnative(u"/dev/null2"), "album": "woo"})
        self.inf = Information(self.library, [f, f2])
        self.assert_child_is(OneAlbum)

    def test_artist(self):
        f = AF({"~filename": fsnative(u"/dev/null"), "artist": "woo"})
        f2 = AF({"~filename": fsnative(u"/dev/null2"), "artist": "woo"})
        self.inf = Information(self.library, [f, f2])
        self.assert_child_is(OneArtist)

    def assert_child_is(self, cls):
        self.failUnless(isinstance(self.inf.get_child(), cls))
Exemple #12
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
Exemple #13
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
 def test_two(self):
     f = AF({"~filename": fsnative(u"/dev/null")})
     f2 = AF({"~filename": fsnative(u"/dev/null2")})
     self.inf = Information(self.library, [f, f2])
     self.assert_child_is(ManySongs)
 def test_none(self):
     Information(self.library, []).destroy()
 def test_one(self):
     f = AF({"~filename": fsnative(u"/dev/null")})
     self.inf = Information(self.library, [f])
     self.assert_child_is(OneSong)
Exemple #17
0
 def information_cb(menu_item):
     window = Information(librarian, songs, parent)
     window.show()
 def test_two(self):
     f = AF({"~filename": "/dev/null"})
     f2 = AF({"~filename": "/dev/null2"})
     Information(self.library, [f, f2]).destroy()
 def test_performer_roles(self):
     f = AF({"~filename": fsnative(u"/dev/null"), "performer:piano": "woo"})
     self.inf = Information(self.library, [f])
     self.assert_child_is(OneSong)
Exemple #20
0
 def __current_song_info(self, *args):
     song = app.player.song
     if song:
         librarian = self.__library.librarian
         window = Information(librarian, [song], self)
         window.show()
 def test_performer_roles(self):
     f = AF({"~filename": fsnative(u"/dev/null"), "performer:piano": "woo"})
     self.inf = Information(self.library, [f])
     self.assert_child_is(OneSong)
 def test_one(self):
     f = AF({"~filename": fsnative(u"/dev/null")})
     self.inf = Information(self.library, [f])
     self.assert_child_is(OneSong)
Exemple #23
0
 def test_album(self):
     f = AF({"~filename": fsnative(u"/dev/null"), "album": "woo"})
     f2 = AF({"~filename": fsnative(u"/dev/null2"), "album": "woo"})
     Information(self.library, [f, f2]).destroy()
Exemple #24
0
 def information_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = Information(librarian, songs, parent)
     window.show()
Exemple #25
0
 def __information(self, *args):
     song = app.player.song
     if song:
         window = Information(app.librarian, [song])
         window.show()
Exemple #26
0
 def on_information(*args):
     song = player.song
     window = Information(app.librarian, [song])
     window.show()
 def test_one(self):
     f = AF({"~filename": "/dev/null"})
     Information(self.library, [f]).destroy()
 def test_album_special_chars(self):
     f = AF({"~filename": fsnative(u"/dev/null"), "album": "woo & hoo"})
     f2 = AF({"~filename": fsnative(u"/dev/null2"), "album": "woo & hoo"})
     self.inf = Information(self.library, [f, f2])
     self.assert_child_is(OneAlbum)
 def test_two(self):
     f = AF({"~filename": fsnative(u"/dev/null")})
     f2 = AF({"~filename": fsnative(u"/dev/null2")})
     self.inf = Information(self.library, [f, f2])
     self.assert_child_is(ManySongs)
 def test_artist(self):
     f = AF({"~filename": fsnative(u"/dev/null"), "artist": "woo"})
     f2 = AF({"~filename": fsnative(u"/dev/null2"), "artist": "woo"})
     self.inf = Information(self.library, [f, f2])
     self.assert_child_is(OneArtist)
 def test_artist(self):
     f = AF({"~filename": fsnative(u"/dev/null"), "artist": "woo"})
     f2 = AF({"~filename": fsnative(u"/dev/null2"), "artist": "woo"})
     self.inf = Information(self.library, [f, f2])
     self.assert_child_is(OneArtist)
 def test_remove_song(self):
     f = AF({"~filename": fsnative(u"/dev/null"), "artist": "woo"})
     f2 = AF({"~filename": fsnative(u"/dev/null2"), "artist": "woo"})
     self.library.add([f, f2])
     self.inf = Information(self.library, [f, f2])
     self.library.remove([f])
 def test_remove_song(self):
     f = AF({"~filename": fsnative(u"/dev/null"), "artist": "woo"})
     f2 = AF({"~filename": fsnative(u"/dev/null2"), "artist": "woo"})
     self.library.add([f, f2])
     self.inf = Information(self.library, [f, f2])
     self.library.remove([f])
Exemple #34
0
 def on_information(*args):
     song = player.song
     window = Information(app.librarian, [song])
     window.show()
 def test_artist(self):
     f = AF({"~filename": "/dev/null", "artist": "woo"})
     f2 = AF({"~filename": "/dev/null2", "artist": "woo"})
     Information(self.library, [f, f2]).destroy()
Exemple #36
0
 def edit(widget):
     print_d("Launching lyrics editor for %s" % song("~filename"))
     assert isinstance(song, SongWrapper)
     information = Information(app.librarian, [song._song])
     information.get_child()._switch_to_lyrics()
     information.show()
 def __current_song_info(self, *args):
     song = app.player.song
     if song:
         librarian = self.__library.librarian
         window = Information(librarian, [song], self)
         window.show()
 def __information(self, *args):
     song = app.player.song
     if song:
         window = Information(app.librarian, [song])
         window.show()
Exemple #39
0
 def information_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = Information(librarian, songs, parent)
     window.show()
Exemple #40
0
 def edit(widget):
     print_d("Launching lyrics editor for %s" % song("~filename"))
     assert isinstance(song, SongWrapper)
     information = Information(app.librarian, [song._song])
     information.get_child()._switch_to_lyrics()
     information.show()
 def test_album_special_chars(self):
     f = AF({"~filename": fsnative(u"/dev/null"), "album": "woo & hoo"})
     f2 = AF({"~filename": fsnative(u"/dev/null2"), "album": "woo & hoo"})
     self.inf = Information(self.library, [f, f2])
     self.assert_child_is(OneAlbum)