示例#1
0
    def __update_view_artists(self, genre_ids, artist_ids):
        """
            Update current view with artists view
            @param genre ids as [int]
            @param artist ids as [int]
        """
        def load():
            if genre_ids and genre_ids[0] == Type.ALL:
                albums = Lp().albums.get_ids(artist_ids, [])
            else:
                albums = []
                if artist_ids and artist_ids[0] == Type.COMPILATIONS:
                    albums += Lp().albums.get_compilation_ids(genre_ids)
                albums += Lp().albums.get_ids(artist_ids, genre_ids)
            return albums

        from lollypop.view_artist import ArtistView
        self.__stop_current_view()
        view = ArtistView(artist_ids, genre_ids)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        self.__stack.add(view)
        self.__stack.set_visible_child(view)
        self.__stack.clean_old_views(view)
示例#2
0
    def _update_view_playlists(self, playlist_ids=[]):
        """
            Update current view with playlist view
            @param playlist ids as [int]
        """
        def load():
            track_ids = []
            for playlist_id in playlist_ids:
                if playlist_id == Type.POPULARS:
                    tracks = Lp().tracks.get_populars()
                elif playlist_id == Type.RECENTS:
                    tracks = Lp().tracks.get_recently_listened_to()
                elif playlist_id == Type.NEVER:
                    tracks = Lp().tracks.get_never_listened_to()
                elif playlist_id == Type.RANDOMS:
                    tracks = Lp().tracks.get_randoms()
                else:
                    tracks = Lp().playlists.get_tracks_ids(playlist_id)
                for track_id in tracks:
                    if track_id not in track_ids:
                        track_ids.append(track_id)
            return track_ids

        view = None
        if playlist_ids:
            view = PlaylistsView(playlist_ids)
            loader = Loader(target=load, view=view)
            loader.start()
        else:
            view = PlaylistsManageView(Type.NONE, [], [], False)
            view.populate()
        view.show()
        self._stack.add(view)
        self._stack.set_visible_child(view)
        self._stack.clean_old_views(view)
示例#3
0
    def _get_view_artists(self, genre_ids, artist_ids):
        """
            Get artists view for genres/artists
            @param genre_ids as [int]
            @param artist_ids as [int]
        """
        def load():
            if genre_ids and genre_ids[0] == Type.ALL:
                if App().settings.get_value("show-performers"):
                    items = App().tracks.get_album_ids(artist_ids, [])
                else:
                    items = App().albums.get_ids(artist_ids, [])
            else:
                if App().settings.get_value("show-performers"):
                    items = App().tracks.get_album_ids(artist_ids, genre_ids)
                else:
                    items = App().albums.get_ids(artist_ids, genre_ids)
            return [
                Album(album_id, genre_ids, artist_ids) for album_id in items
            ]

        if App().window.is_adaptive:
            from lollypop.view_artist_small import ArtistViewSmall
            view = ArtistViewSmall(artist_ids, genre_ids)
        else:
            from lollypop.view_artist import ArtistView
            view = ArtistView(artist_ids, genre_ids)
            loader = Loader(target=load, view=view)
            loader.start()
        view.show()
        return view
示例#4
0
    def _update_view_playlists(self, playlist_ids=[]):
        """
            Update current view with playlist view
            @param playlist ids as [int]
        """
        def load():
            track_ids = []
            for playlist_id in playlist_ids:
                if playlist_id == Type.POPULARS:
                    tracks = Lp().tracks.get_populars()
                elif playlist_id == Type.RECENTS:
                    tracks = Lp().tracks.get_recently_listened_to()
                elif playlist_id == Type.NEVER:
                    tracks = Lp().tracks.get_never_listened_to()
                elif playlist_id == Type.RANDOMS:
                    tracks = Lp().tracks.get_randoms()
                else:
                    tracks = Lp().playlists.get_track_ids(playlist_id)
                for track_id in tracks:
                    if track_id not in track_ids:
                        track_ids.append(track_id)
            return track_ids

        view = None
        if playlist_ids:
            view = PlaylistsView(playlist_ids)
            loader = Loader(target=load, view=view)
            loader.start()
        else:
            view = PlaylistsManageView(Type.NONE, [], [], False)
            view.populate()
        view.show()
        self._stack.add(view)
        self._stack.set_visible_child(view)
        self._stack.clean_old_views(view)
    def _get_view_artists(self, genre_ids, artist_ids):
        """
            Get artists view for genres/artists
            @param genre ids as [int]
            @param artist ids as [int]
        """
        def load():
            if genre_ids and genre_ids[0] == Type.ALL:
                items = App().albums.get_ids(artist_ids, [])
            else:
                items = []
                if artist_ids and artist_ids[0] == Type.COMPILATIONS:
                    items += App().albums.get_compilation_ids(genre_ids)
                items += App().albums.get_ids(artist_ids, genre_ids)
            return [
                Album(album_id, genre_ids, artist_ids) for album_id in items
            ]

        if App().window.is_adaptive:
            from lollypop.view_albums_list import AlbumsListView
            view = AlbumsListView(RowListType.DEFAULT, artist_ids, genre_ids)
        else:
            from lollypop.view_artist import ArtistView
            view = ArtistView(artist_ids, genre_ids)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        return view
示例#6
0
    def _get_view_albums_decades(self):
        """
            Get album view for decades
        """
        def load():
            (years, unknown) = App().albums.get_years()
            decades = []
            decade = []
            current_d = None
            for year in sorted(years):
                d = year // 10
                if current_d is not None and current_d != d:
                    current_d = d
                    decades.append(decade)
                    decade = []
                current_d = d
                decade.append(year)
            if decade:
                decades.append(decade)
            return decades

        from lollypop.view_albums_decade_box import AlbumsDecadeBoxView
        view_type = ViewType.SCROLLED
        if App().window.is_adaptive:
            view_type |= ViewType.MEDIUM
        view = AlbumsDecadeBoxView(self._view_type | view_type)
        view.show()
        loader = Loader(target=load, view=view)
        loader.start()
        return view
示例#7
0
    def _setup_list_artists(self, selection_list, genre_ids, update):
        """
            Setup list for artists
            @param list as SelectionList
            @param genre ids as [int]
            @param update as bool, if True, just update entries
            @thread safe
        """
        def load():
            artists = Lp().artists.get(genre_ids)
            compilations = Lp().albums.get_compilations(genre_ids)
            return (artists, compilations)

        def setup(artists, compilations):
            if selection_list == self._list_one:
                items = self._get_headers()
                items.append((Type.SEPARATOR, ''))
            else:
                items = []
            if compilations:
                items.append((Type.COMPILATIONS, _("Compilations")))
            items += artists
            selection_list.mark_as_artists(True)
            if update:
                selection_list.update_values(items)
            else:
                selection_list.populate(items)

        if selection_list == self._list_one:
            if self._list_two.is_visible():
                self._list_two.hide()
            self._list_two_restore = Type.NONE
        loader = Loader(target=load, view=selection_list,
                        on_finished=lambda r: setup(*r))
        loader.start()
    def __update_list_artists(self, selection_list, genre_ids, update):
        """
            Setup list for artists
            @param list as SelectionList
            @param genre ids as [int]
            @param update as bool, if True, just update entries
        """
        def load():
            artists = App().artists.get(genre_ids)
            compilations = App().albums.get_compilation_ids(genre_ids)
            return (artists, compilations)

        def setup(artists, compilations):
            mask = SelectionListMask.ARTISTS
            if compilations:
                mask |= SelectionListMask.COMPILATIONS
            selection_list.mark_as(mask)
            items = selection_list.get_headers(selection_list.mask)
            items += artists
            if update:
                selection_list.update_values(items)
            else:
                selection_list.populate(items)

        if selection_list == self._list_one:
            if self._list_two.is_visible():
                self._list_two.hide()
            self._list_two_restore = Type.NONE
        loader = Loader(target=load,
                        view=selection_list,
                        on_finished=lambda r: setup(*r))
        loader.start()
示例#9
0
    def __setup_list_artists(self, selection_list):
        """
            Setup list for artists
            @param list as SelectionList
            @thread safe
        """
        def load():
            artists = Lp().artists.get_local()
            compilations = Lp().albums.get_compilation_ids()
            return (artists, compilations)

        def setup(artists, compilations):
            items = []
            items.append((Type.ALL, _("Synced albums")))
            if compilations:
                items.append((Type.COMPILATIONS, _("Compilations")))
                items.append((Type.SEPARATOR, ""))
            items += artists
            selection_list.mark_as_artists(True)
            selection_list.populate(items)

        loader = Loader(target=load,
                        view=selection_list,
                        on_finished=lambda r: setup(*r))
        loader.start()
示例#10
0
 def populate(self):
     """
         Populate view
     """
     def load():
         return Lp().player.get_user_playlist()
     loader = Loader(target=load, view=self._widget)
     loader.start()
示例#11
0
 def populate(self):
     """
         Populate view
     """
     def load():
         return Lp().player.get_user_playlist()
     loader = Loader(target=load, view=self._widget)
     loader.start()
    def _get_view_albums(self, genre_ids, artist_ids):
        """
            Get albums view for genres/artists
            @param genre ids as [int]
            @param is compilation as bool
        """
        def load():
            items = []
            is_compilation = artist_ids and artist_ids[0] == Type.COMPILATIONS
            if genre_ids and genre_ids[0] == Type.ALL:
                if is_compilation or\
                        App().settings.get_value(
                            "show-compilations-in-album-view"):
                    items = App().albums.get_compilation_ids([])
                if not is_compilation:
                    items += App().albums.get_ids([], [])
            elif genre_ids and genre_ids[0] == Type.POPULARS:
                items = App().albums.get_rated()
                count = 100 - len(items)
                for album in App().albums.get_populars(count):
                    if album not in items:
                        items.append(album)
            elif genre_ids and genre_ids[0] == Type.LOVED:
                items = App().albums.get_loved_albums()
            elif genre_ids and genre_ids[0] == Type.RECENTS:
                items = App().albums.get_recents()
            elif genre_ids and genre_ids[0] == Type.NEVER:
                items = App().albums.get_never_listened_to()
            elif genre_ids and genre_ids[0] == Type.RANDOMS:
                items = App().albums.get_randoms()
            else:
                if is_compilation or\
                        App().settings.get_value(
                            "show-compilations-in-album-view"):
                    items = App().albums.get_compilation_ids(genre_ids)
                if not is_compilation:
                    items += App().albums.get_ids([], genre_ids)
            return [
                Album(album_id, genre_ids, artist_ids) for album_id in items
            ]

        if App().window.is_adaptive:
            from lollypop.view_albums_list import AlbumsListView
            view = AlbumsListView(RowListType.DEFAULT, genre_ids, artist_ids)
        else:
            from lollypop.view_albums_box import AlbumsBoxView
            view = AlbumsBoxView(genre_ids, artist_ids)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        return view
示例#13
0
    def __update_view_albums(self, genre_ids, artist_ids):
        """
            Update current view with albums view
            @param genre ids as [int]
            @param is compilation as bool
        """
        def load():
            items = []
            is_compilation = artist_ids and artist_ids[0] == Type.COMPILATIONS
            if genre_ids and genre_ids[0] == Type.ALL:
                if is_compilation or\
                        Lp().settings.get_value("show-compilations"):
                    items = Lp().albums.get_compilation_ids()
                if not is_compilation:
                    items += Lp().albums.get_ids()
            elif genre_ids and genre_ids[0] == Type.POPULARS:
                items = Lp().albums.get_rated()
                count = 100 - len(items)
                for album in Lp().albums.get_populars(count):
                    if album not in items:
                        items.append(album)
            elif genre_ids and genre_ids[0] == Type.LOVED:
                items = Lp().albums.get_loves()
            elif genre_ids and genre_ids[0] == Type.RECENTS:
                items = Lp().albums.get_recents()
            elif genre_ids and genre_ids[0] == Type.RANDOMS:
                items = Lp().albums.get_randoms()
            elif genre_ids and genre_ids[0] in [Type.SPOTIFY,
                                                Type.LASTFM]:
                items = Lp().tracks.get_charts_ids(genre_ids)
            elif genre_ids and genre_ids[0] == Type.ITUNES:
                items = Lp().albums.get_charts_ids(genre_ids)
            elif artist_ids and artist_ids[0] == Type.CHARTS:
                items = Lp().albums.get_charts_ids(genre_ids)
            else:
                if is_compilation or\
                        Lp().settings.get_value("show-compilations"):
                    items = Lp().albums.get_compilation_ids(genre_ids)
                if not is_compilation:
                    items += Lp().albums.get_ids([], genre_ids)
            return items

        # Spotify albums contains only one tracks, show playlist view
        if genre_ids and genre_ids[0] in [Type.SPOTIFY,
                                          Type.LASTFM]:
            from lollypop.view_playlists import PlaylistsView
            view = PlaylistsView(genre_ids)
            loader = Loader(target=load, view=view)
            loader.start()
        else:
            from lollypop.view_albums import AlbumsView
            self.__stop_current_view()
            view = AlbumsView(genre_ids, artist_ids)
            loader = Loader(target=load, view=view)
            loader.start()
        view.show()
        self.__stack.add(view)
        self.__stack.set_visible_child(view)
        self.__stack.clean_old_views(view)
示例#14
0
    def _get_view_genres(self):
        """
            Get view for genres
        """
        def load():
            return App().genres.get_ids()

        from lollypop.view_albums_genre_box import AlbumsGenreBoxView
        view_type = ViewType.SCROLLED
        if App().window.is_adaptive:
            view_type |= ViewType.MEDIUM
        view = AlbumsGenreBoxView(view_type | self._view_type)
        view.show()
        loader = Loader(target=load, view=view)
        loader.start()
        return view
    def _get_view_radios(self):
        """
            Get radios view
            @return RadiosView
        """
        def load():
            from lollypop.radios import Radios
            radios = Radios()
            return radios.get_ids()

        from lollypop.view_radios import RadiosView
        view = RadiosView()
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        return view
示例#16
0
    def _get_view_device_playlists(self, index):
        """
            Show playlists for device at index
            @param index as int
        """
        def load():
            playlist_ids = App().playlists.get_synced_ids(0)
            playlist_ids += App().playlists.get_synced_ids(index)
            return playlist_ids

        from lollypop.view_playlists_manager import PlaylistsManagerView
        view = PlaylistsManagerView(None, ViewType.SCROLLED | ViewType.DEVICES)
        view.show()
        loader = Loader(target=load, view=view)
        loader.start()
        return view
示例#17
0
    def __update_view_albums(self, genre_ids, artist_ids):
        """
            Update current view with albums view
            @param genre ids as [int]
            @param is compilation as bool
        """
        def load():
            items = []
            is_compilation = artist_ids and artist_ids[0] == Type.COMPILATIONS
            if genre_ids and genre_ids[0] == Type.ALL:
                if is_compilation or\
                        Lp().settings.get_value("show-compilations"):
                    items = Lp().albums.get_compilation_ids()
                if not is_compilation:
                    items += Lp().albums.get_ids()
            elif genre_ids and genre_ids[0] == Type.POPULARS:
                items = Lp().albums.get_rated()
                count = 100 - len(items)
                for album in Lp().albums.get_populars(count):
                    if album not in items:
                        items.append(album)
            elif genre_ids and genre_ids[0] == Type.LOVED:
                items = Lp().albums.get_loves()
            elif genre_ids and genre_ids[0] == Type.RECENTS:
                items = Lp().albums.get_recents()
            elif genre_ids and genre_ids[0] == Type.NEVER:
                items = Lp().albums.get_never_listened_to()
            elif genre_ids and genre_ids[0] == Type.RANDOMS:
                items = Lp().albums.get_randoms()
            else:
                if is_compilation or\
                        Lp().settings.get_value("show-compilations"):
                    items = Lp().albums.get_compilation_ids(genre_ids)
                if not is_compilation:
                    items += Lp().albums.get_ids([], genre_ids)
            return items

        from lollypop.view_albums import AlbumsView
        self.__stop_current_view()
        view = AlbumsView(genre_ids, artist_ids)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        self.__stack.add(view)
        self.__stack.set_visible_child(view)
        self.__stack.clean_old_views(view)
示例#18
0
    def __update_list_charts(self):
        """
            Setup list for charts
            @thread safe
        """
        def load():
            genres = Lp().genres.get_charts()
            return genres

        def setup(genres):
            genres.insert(0, (Type.SEPARATOR, ""))
            genres.insert(0, (Type.ITUNES, "Itunes"))
            genres.insert(0, (Type.LASTFM, "Last.fm"))
            genres.insert(0, (Type.SPOTIFY, "Spotify"))
            self.__list_two.populate(genres)
            self.__list_two.mark_as_artists(False)
        loader = Loader(target=load, view=self.__list_two, on_finished=setup)
        loader.start()
示例#19
0
    def __update_list_charts(self):
        """
            Setup list for charts
            @thread safe
        """
        def load():
            genres = Lp().genres.get_charts()
            return genres

        def setup(genres):
            genres.insert(0, (Type.SEPARATOR, ''))
            genres.insert(0, (Type.ITUNES, 'Itunes'))
            genres.insert(0, (Type.LASTFM, 'Last.fm'))
            genres.insert(0, (Type.SPOTIFY, "Spotify"))
            self.__list_two.populate(genres)
            self.__list_two.mark_as_artists(False)
        loader = Loader(target=load, view=self.__list_two, on_finished=setup)
        loader.start()
示例#20
0
    def _get_view_device_albums(self, index):
        """
            Show albums for device at index
            @param index as int
        """
        def load():
            album_ids = App().albums.get_synced_ids(0)
            album_ids += App().albums.get_synced_ids(index)
            return [Album(album_id) for album_id in album_ids]

        from lollypop.view_albums_box import AlbumsBoxView
        view_type = ViewType.SCROLLED
        if App().window.is_adaptive:
            view_type |= ViewType.MEDIUM
        view = AlbumsBoxView([], [], view_type | self._view_type)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        return view
示例#21
0
    def _get_view_radios(self):
        """
            Get radios view
            @return RadiosView
        """
        def load():
            from lollypop.radios import Radios
            radios = Radios()
            return radios.get_ids()

        from lollypop.view_radios import RadiosView
        view_type = ViewType.SCROLLED
        if App().window.is_adaptive:
            view_type |= ViewType.MEDIUM
        view = RadiosView(view_type | self._view_type)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        return view
示例#22
0
    def _get_view_albums_years(self, years):
        """
            Get album view for years
            @param years as [int]
        """
        def load():
            items = []
            for year in years:
                items += App().albums.get_compilations_for_year(year)
                items += App().albums.get_albums_for_year(year)
            return [Album(album_id, [Type.YEARS], []) for album_id in items]

        from lollypop.view_albums_box import AlbumsBoxView
        view_type = ViewType.SCROLLED
        if App().window.is_adaptive:
            view_type |= ViewType.MEDIUM
        view = AlbumsBoxView([Type.YEARS], years, view_type | self._view_type)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        return view
    def __update_list_genres(self, selection_list, update):
        """
            Setup list for genres
            @param list as SelectionList
            @param update as bool, if True, just update entries
        """
        def load():
            genres = App().genres.get()
            return genres

        def setup(genres):
            selection_list.mark_as(SelectionListMask.GENRE)
            items = selection_list.get_headers(selection_list.mask)
            items += genres
            if update:
                selection_list.update_values(items)
            else:
                selection_list.populate(items)

        loader = Loader(target=load, view=selection_list, on_finished=setup)
        loader.start()
示例#24
0
    def _update_view_artists(self, artist_ids, genre_ids):
        """
            Update current view with artists view
            @param artist id as int
            @param genre id as int
        """
        def load():
            if artist_ids and artist_ids[0] == Type.COMPILATIONS:
                albums = Lp().albums.get_compilations(genre_ids)
            elif genre_ids and genre_ids[0] == Type.ALL:
                albums = Lp().albums.get_ids(artist_ids, [])
            else:
                albums = Lp().albums.get_ids(artist_ids, genre_ids)
            return albums

        view = ArtistView(artist_ids, genre_ids)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        self._stack.add(view)
        self._stack.set_visible_child(view)
        self._stack.clean_old_views(view)
示例#25
0
    def __update_view_albums(self, genre_ids, artist_ids):
        """
            Update current view with albums view
            @param genre ids as [int]
            @param is compilation as bool
        """
        def load():
            items = []
            is_compilation = artist_ids and artist_ids[0] == Type.COMPILATIONS
            if genre_ids and genre_ids[0] == Type.ALL:
                if is_compilation or\
                        Lp().settings.get_value('show-compilations'):
                    items = Lp().albums.get_compilation_ids()
                if not is_compilation:
                    items += Lp().albums.get_ids()
            elif genre_ids and genre_ids[0] == Type.POPULARS:
                items = Lp().albums.get_rated()
                count = 100 - len(items)
                for album in Lp().albums.get_populars(count):
                    if album not in items:
                        items.append(album)
            elif genre_ids and genre_ids[0] == Type.LOVED:
                items = Lp().albums.get_loves()
            elif genre_ids and genre_ids[0] == Type.RECENTS:
                items = Lp().albums.get_recents()
            elif genre_ids and genre_ids[0] == Type.RANDOMS:
                items = Lp().albums.get_randoms()
            elif genre_ids and genre_ids[0] in [Type.SPOTIFY,
                                                Type.LASTFM]:
                items = Lp().tracks.get_charts_ids(genre_ids)
            elif genre_ids and genre_ids[0] == Type.ITUNES:
                items = Lp().albums.get_charts_ids(genre_ids)
            elif artist_ids and artist_ids[0] == Type.CHARTS:
                items = Lp().albums.get_charts_ids(genre_ids)
            else:
                if is_compilation or\
                        Lp().settings.get_value('show-compilations'):
                    items = Lp().albums.get_compilation_ids(genre_ids)
                if not is_compilation:
                    items += Lp().albums.get_ids([], genre_ids)
            return items

        # Spotify albums contains only one tracks, show playlist view
        if genre_ids and genre_ids[0] in [Type.SPOTIFY,
                                          Type.LASTFM]:
            from lollypop.view_playlists import PlaylistsView
            view = PlaylistsView(genre_ids)
            loader = Loader(target=load, view=view)
            loader.start()
        else:
            from lollypop.view_albums import AlbumsView
            self.__stop_current_view()
            view = AlbumsView(genre_ids, artist_ids)
            loader = Loader(target=load, view=view)
            loader.start()
        view.show()
        self.__stack.add(view)
        self.__stack.set_visible_child(view)
        self.__stack.clean_old_views(view)
    def _get_view_albums_years(self, years):
        """
            Get album view for years
            @param years as [int]
        """
        def load():
            items = []
            for year in years:
                items += App().albums.get_compilations_for_year(year)
                items += App().albums.get_albums_for_year(year)
            return [Album(album_id, [Type.YEARS], []) for album_id in items]

        if App().window.is_adaptive:
            from lollypop.view_albums_list import AlbumsListView
            view = AlbumsListView(RowListType.DEFAULT, years, [Type.YEARS])
        else:
            from lollypop.view_albums_box import AlbumsBoxView
            view = AlbumsBoxView([Type.YEARS], years)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        return view
示例#27
0
    def _get_view_artists_rounded(self, static):
        """
            Get rounded artists view
            @return view
        """
        def load():
            if App().settings.get_value("show-performers"):
                ids = App().artists.get_all()
            else:
                ids = App().artists.get()
            compilations = App().albums.get_compilation_ids([])
            return (ids, compilations)

        def get_items(artist_ids, compilation_ids):
            items = []
            if static:
                mask = SelectionListMask.ARTISTS_VIEW |\
                       SelectionListMask.ARTISTS
                if compilation_ids:
                    mask |= SelectionListMask.COMPILATIONS
                items = ShownLists.get(mask)
            items += artist_ids
            return items

        def setup(artist_ids, compilation_ids):
            view.populate(get_items(artist_ids, compilation_ids))

        from lollypop.view_artists_rounded import RoundedArtistsView
        view_type = ViewType.SCROLLED
        if App().window.is_adaptive:
            view_type |= ViewType.MEDIUM
        view = RoundedArtistsView(view_type | self._view_type, not static)
        self._stack.add(view)
        loader = Loader(target=load,
                        view=view,
                        on_finished=lambda r: setup(*r))
        loader.start()
        view.show()
        return view
示例#28
0
    def _update_view_albums(self, genre_ids, is_compilation=False):
        """
            Update current view with albums view
            @param genre ids as [int]
            @param is compilation as bool
        """
        def load():
            albums = []
            if genre_ids and genre_ids[0] == Type.ALL:
                if is_compilation:
                    albums = Lp().albums.get_compilations()
                else:
                    if Lp().settings.get_value('show-compilations'):
                        albums = Lp().albums.get_compilations()
                    albums += Lp().albums.get_ids()
            elif genre_ids and genre_ids[0] == Type.POPULARS:
                albums = Lp().albums.get_populars()
            elif genre_ids and genre_ids[0] == Type.RECENTS:
                albums = Lp().albums.get_recents()
            elif genre_ids and genre_ids[0] == Type.RANDOMS:
                albums = Lp().albums.get_randoms()
            elif is_compilation:
                albums = Lp().albums.get_compilations(genre_ids)
            else:
                if Lp().settings.get_value('show-compilations'):
                    albums = Lp().albums.get_compilations(genre_ids)
                albums += Lp().albums.get_ids([], genre_ids)
            return albums

        artist_ids = []
        if is_compilation:
            artist_ids.append(Type.COMPILATIONS)
        view = AlbumsView(genre_ids, artist_ids)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        self._stack.add(view)
        self._stack.set_visible_child(view)
        self._stack.clean_old_views(view)
示例#29
0
    def _update_view_albums(self, genre_ids, is_compilation=False):
        """
            Update current view with albums view
            @param genre ids as [int]
            @param is compilation as bool
        """
        def load():
            albums = []
            if genre_ids and genre_ids[0] == Type.ALL:
                if is_compilation:
                    albums = Lp().albums.get_compilations()
                else:
                    if Lp().settings.get_value('show-compilations'):
                        albums = Lp().albums.get_compilations()
                    albums += Lp().albums.get_ids()
            elif genre_ids and genre_ids[0] == Type.POPULARS:
                albums = Lp().albums.get_populars()
            elif genre_ids and genre_ids[0] == Type.RECENTS:
                albums = Lp().albums.get_recents()
            elif genre_ids and genre_ids[0] == Type.RANDOMS:
                albums = Lp().albums.get_randoms()
            elif is_compilation:
                albums = Lp().albums.get_compilations(genre_ids)
            else:
                if Lp().settings.get_value('show-compilations'):
                    albums = Lp().albums.get_compilations(genre_ids)
                albums += Lp().albums.get_ids([], genre_ids)
            return albums

        artist_ids = []
        if is_compilation:
            artist_ids.append(Type.COMPILATIONS)
        view = AlbumsView(genre_ids, artist_ids)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        self._stack.add(view)
        self._stack.set_visible_child(view)
        self._stack.clean_old_views(view)
示例#30
0
    def __setup_list_artists(self, selection_list, genre_ids, update):
        """
            Setup list for artists
            @param list as SelectionList
            @param genre ids as [int]
            @param update as bool, if True, just update entries
            @thread safe
        """
        def load():
            artists = Lp().artists.get(genre_ids)
            compilations = Lp().albums.get_compilation_ids(genre_ids)
            return (artists, compilations)

        def setup(artists, compilations):
            if selection_list == self.__list_one:
                items = selection_list.get_headers()
                if not compilations:
                    items.append((Type.SEPARATOR, ''))
            else:
                items = []
            if compilations:
                items.append((Type.COMPILATIONS, _("Compilations")))
                items.append((Type.SEPARATOR, ''))
            items += artists
            selection_list.mark_as_artists(True)
            if update:
                selection_list.update_values(items)
            else:
                selection_list.populate(items)

        if selection_list == self.__list_one:
            if self.__list_two.is_visible():
                self.__list_two.hide()
            self.__list_two_restore = Type.NONE
        loader = Loader(target=load,
                        view=selection_list,
                        on_finished=lambda r: setup(*r))
        loader.start()
示例#31
0
    def _setup_list_genres(self, selection_list, update):
        """
            Setup list for genres
            @param list as SelectionList
            @param update as bool, if True, just update entries
            @thread safe
        """
        def load():
            genres = Lp().genres.get()
            return genres

        def setup(genres):
            items = self._get_headers()
            items.append((Type.SEPARATOR, ''))
            items += genres
            selection_list.mark_as_artists(False)
            if update:
                selection_list.update_values(items)
            else:
                selection_list.populate(items)

        loader = Loader(target=load, view=selection_list, on_finished=setup)
        loader.start()
示例#32
0
    def _get_view_albums(self, genre_ids, artist_ids):
        """
            Get albums view for genres/artists
            @param genre_ids as [int]
            @param is compilation as bool
        """
        def load():
            album_ids = self.get_view_album_ids(genre_ids, artist_ids)
            return [
                Album(album_id, genre_ids, artist_ids)
                for album_id in album_ids
            ]

        from lollypop.view_albums_box import AlbumsBoxView
        view_type = ViewType.SCROLLED
        if App().window.is_adaptive:
            view_type |= ViewType.MEDIUM
        view = AlbumsBoxView(genre_ids, artist_ids,
                             view_type | self._view_type)
        loader = Loader(target=load, view=view)
        loader.start()
        view.show()
        return view
示例#33
0
    def __setup_list_genres(self, selection_list, update):
        """
            Setup list for genres
            @param list as SelectionList
            @param update as bool, if True, just update entries
            @thread safe
        """
        def load():
            genres = Lp().genres.get()
            return genres

        def setup(genres):
            items = selection_list.get_headers()
            items.append((Type.SEPARATOR, ''))
            items += genres
            selection_list.mark_as_artists(False)
            if update:
                selection_list.update_values(items)
            else:
                selection_list.populate(items)

        loader = Loader(target=load, view=selection_list, on_finished=setup)
        loader.start()
示例#34
0
    def __setup_list_artists(self, selection_list):
        """
            Setup list for artists
            @param list as SelectionList
            @thread safe
        """
        def load():
            artists = Lp().artists.get_local()
            compilations = Lp().albums.get_compilation_ids()
            return (artists, compilations)

        def setup(artists, compilations):
            items = []
            items.append((Type.ALL, _("Synced albums")))
            if compilations:
                items.append((Type.COMPILATIONS, _("Compilations")))
                items.append((Type.SEPARATOR, ''))
            items += artists
            selection_list.mark_as_artists(True)
            selection_list.populate(items)
        loader = Loader(target=load, view=selection_list,
                        on_finished=lambda r: setup(*r))
        loader.start()
示例#35
0
    def __update_list_device(self):
        """
            Setup list for device
            @param list as SelectionList
            @thread safe
        """
        def load():
            artists = App().artists.get()
            compilations = App().albums.get_compilation_ids([])
            return (artists, compilations)

        def setup(artists, compilations):
            items = [(Type.ALL, _("Synced albums"), "")]
            items.append((Type.PLAYLISTS, _("Playlists"), ""))
            if compilations:
                items.append((Type.COMPILATIONS, _("Compilations"), ""))
                items.append((Type.SEPARATOR, "", ""))
            items += artists
            self.__selection_list.populate(items)

        loader = Loader(target=load,
                        view=self.__selection_list,
                        on_finished=lambda r: setup(*r))
        loader.start()
    def _get_view_artists_rounded(self, static):
        """
            Get rounded artists view
            @return view
        """
        def load():
            ids = App().artists.get()
            compilations = App().albums.get_compilation_ids([])
            return (ids, compilations)

        def get_items(artist_ids, compilation_ids):
            items = []
            if static:
                mask = SelectionListMask.LIST_ONE |\
                       SelectionListMask.ARTISTS |\
                       SelectionListMask.ALL_ARTISTS
                if compilation_ids:
                    mask |= SelectionListMask.COMPILATIONS
                items = ShownLists.get(mask)
                for dev in self.devices.values():
                    items.append((dev.id, dev.name, dev.name))
            items += artist_ids
            return items

        def setup(artist_ids, compilation_ids):
            view.populate(get_items(artist_ids, compilation_ids))

        from lollypop.view_artists_rounded import RoundedArtistsView
        view = RoundedArtistsView()
        self._stack.add(view)
        loader = Loader(target=load,
                        view=view,
                        on_finished=lambda r: setup(*r))
        loader.start()
        view.show()
        return view
示例#37
0
 def __update_view_artists(self, genre_ids, artist_ids):
     """
         Update current view with artists view
         @param genre ids as [int]
         @param artist ids as [int]
     """
     def load():
         if genre_ids and genre_ids[0] == Type.ALL:
             albums = Lp().albums.get_ids(artist_ids, [])
         else:
             albums = []
             if artist_ids and artist_ids[0] == Type.COMPILATIONS:
                 albums += Lp().albums.get_compilation_ids(genre_ids)
             albums += Lp().albums.get_ids(artist_ids, genre_ids)
         return albums
     from lollypop.view_artist import ArtistView
     self.__stop_current_view()
     view = ArtistView(artist_ids, genre_ids)
     loader = Loader(target=load, view=view)
     loader.start()
     view.show()
     self.__stack.add(view)
     self.__stack.set_visible_child(view)
     self.__stack.clean_old_views(view)
示例#38
0
    def _get_view_playlists(self, playlist_ids=[]):
        """
            Get playlists view for playlists
            @param playlist_ids as [int]
            @return View
        """
        def load():
            tracks = []
            all_ids = []
            for playlist_id in playlist_ids:
                if playlist_id == Type.LOVED:
                    ids = App().tracks.get_loved_track_ids()
                else:
                    ids = App().playlists.get_track_ids(playlist_id)
                for id in ids:
                    if id in all_ids:
                        continue
                    all_ids.append(id)
                    track = Track(id)
                    tracks.append(track)
            return tracks

        def load_smart():
            tracks = []
            request = App().playlists.get_smart_sql(playlist_ids[0])
            ids = App().db.execute(request)
            for id in ids:
                track = Track(id)
                # Smart playlist may report invalid tracks
                # An album always have an artist so check
                # object is valid. Others Lollypop widgets assume
                # objects are valid
                if not track.album.artist_ids:
                    continue
                tracks.append(track)
            return tracks

        if App().window.is_adaptive:
            view_type = ViewType.DND
        else:
            view_type = ViewType.TWO_COLUMNS |\
                        ViewType.DND |\
                        ViewType.PLAYLISTS
        if len(playlist_ids) == 1 and\
                App().playlists.get_smart(playlist_ids[0]):
            from lollypop.view_playlists import PlaylistsView
            view = PlaylistsView(playlist_ids, view_type | self._view_type)
            view.show()
            loader = Loader(target=load_smart, view=view)
            loader.start()
        elif playlist_ids:
            from lollypop.view_playlists import PlaylistsView
            view = PlaylistsView(playlist_ids, view_type | self._view_type)
            view.show()
            loader = Loader(target=load, view=view)
            loader.start()
        else:
            from lollypop.view_playlists_manager import PlaylistsManagerView
            view_type = ViewType.SCROLLED
            if App().window.is_adaptive:
                view_type |= ViewType.MEDIUM
            view = PlaylistsManagerView(None, view_type | self._view_type)
            view.populate()
            view.show()
        return view