Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
 def __init__(self):
     """
         Init Popover
     """
     Gtk.Popover.__init__(self)
     self.set_position(Gtk.PositionType.BOTTOM)
     self.connect('map', self.__on_map)
     self.connect('unmap', self.__on_unmap)
     self._widget = PlaylistsView(Lp().player.get_user_playlist_ids(),
                                  False)
     self._widget.show()
     self.add(self._widget)
Ejemplo n.º 4
0
 def __init__(self):
     """
         Init Popover
     """
     Popover.__init__(self)
     self.set_position(Gtk.PositionType.BOTTOM)
     self.connect("map", self.__on_map)
     self.connect("unmap", self.__on_unmap)
     self.__view = PlaylistsView(App().player.playlist_ids,
                                 RowListType.DND | RowListType.POPOVER,
                                 False)
     self.__view.show()
     self.add(self.__view)
 def _get_view_playlists(self, playlist_id=None):
     """
         Get playlists view for playlists
         @param playlist_id as int
         @return View
     """
     view_type = ViewType.PLAYLISTS | ViewType.SCROLLED
     if playlist_id is None:
         from lollypop.view_playlists_manager import PlaylistsManagerView
         view = PlaylistsManagerView(view_type)
     else:
         from lollypop.view_playlists import PlaylistsView
         view_type |= ViewType.DND
         view = PlaylistsView(playlist_id, view_type)
     view.populate()
     return view
Ejemplo n.º 6
0
 def _get_view_current(self):
     """
         Get view for current playlist
         @return View
     """
     if App().player.playlist_ids:
         from lollypop.view_playlists import PlaylistsView
         view = PlaylistsView(App().player.playlist_ids,
                              RowListType.DND | RowListType.POPOVER, False)
         view.populate(App().player.playlist_tracks)
     else:
         from lollypop.view_current_albums import CurrentAlbumsView
         view = CurrentAlbumsView()
         view.populate(App().player.albums)
     view.set_margin_top(5)
     view.set_margin_start(5)
     view.set_margin_end(5)
     view.show()
     return view
Ejemplo n.º 7
0
 def get_view_current(self, view_type=ViewType.DND):
     """
         Get view for current playlist
         @return View
     """
     if App().player.queue and not view_type & ViewType.FULLSCREEN:
         from lollypop.view_queue import QueueView
         view = QueueView(view_type | self._view_type)
         view.populate()
     elif App().player.playlist_ids:
         from lollypop.view_playlists import PlaylistsView
         view = PlaylistsView(App().player.playlist_ids,
                              view_type | self._view_type)
         view.populate(App().player.playlist_tracks)
     else:
         from lollypop.view_current_albums import CurrentAlbumsView
         view = CurrentAlbumsView(view_type | self._view_type)
         view.populate(App().player.albums)
     view.set_margin_top(MARGIN_SMALL)
     view.set_margin_start(MARGIN_SMALL)
     view.show()
     return view
Ejemplo n.º 8
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