1# Copyright (c) 2014-2021 Cedric Bellegarde <cedric.bellegarde@adishatz.org>
2# This program is free software: you can redistribute it and/or modify
3# it under the terms of the GNU General Public License as published by
4# the Free Software Foundation, either version 3 of the License, or
5# (at your option) any later version.
6# This program is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9# GNU General Public License for more details.
10# You should have received a copy of the GNU General Public License
11# along with this program. If not, see <http://www.gnu.org/licenses/>.
12
13from gettext import gettext as _
14
15from lollypop.define import Type, App
16
17
18class ShownLists:
19    """
20        Handle shown lists
21    """
22
23    IDS = {
24        Type.SUGGESTIONS: _("Suggestions"),
25        Type.POPULARS: _("Popular albums"),
26        Type.RANDOMS: _("Random albums"),
27        Type.LOVED: _("Loved albums"),
28        Type.RECENTS: _("Recently added albums"),
29        Type.LITTLE: _("Seldomly played albums"),
30        Type.PLAYLISTS: _("Playlists"),
31        Type.YEARS: _("Years"),
32        Type.GENRES: _("Genres"),
33        Type.GENRES_LIST: _("Genres (list)"),
34        Type.WEB: _("Web"),
35        Type.LYRICS: _("Lyrics"),
36        Type.ALL: _("Albums"),
37        Type.ARTISTS: _("Artists"),
38        Type.ARTISTS_LIST: _("Artists (list)"),
39        Type.SEARCH: _("Search"),
40        Type.CURRENT: _("Playing albums"),
41        Type.INFO: _("Information"),
42        Type.COMPILATIONS: _("Compilations"),
43    }
44
45    def get(mask, get_all=False):
46        """
47            Get list
48            @param mask as bit mask
49            @param get_all as bool
50            @return [(,)]
51        """
52        wanted = list(App().settings.get_value("shown-album-lists"))
53        lists = []
54        for key in ShownLists.IDS.keys():
55            string = ShownLists.IDS[key]
56            if get_all or key in wanted:
57                lists.append((key, string, ""))
58        lists.append((Type.SEPARATOR, "", ""))
59        lists.sort(key=lambda tup: tup[0], reverse=True)
60        return lists
61
62
63class ShownPlaylists(ShownLists):
64    """
65        Handle shown playlists
66    """
67    IDS = {
68        Type.POPULARS: _("Popular tracks"),
69        Type.RANDOMS: _("Random tracks"),
70        Type.LOVED: _("Loved tracks"),
71        Type.RECENTS: _("Recently played tracks"),
72        Type.LITTLE: _("Seldomly played tracks"),
73        Type.SKIPPED: _("Skipped tracks"),
74        Type.ALL: _("All tracks")
75    }
76
77    def get(get_all=False):
78        """
79            Get list
80            @return [(,)]
81        """
82        wanted = App().settings.get_value("shown-playlists")
83        lists = []
84        for key in ShownPlaylists.IDS.keys():
85            string = ShownPlaylists.IDS[key]
86            if get_all or key in wanted:
87                lists.append((key, string, ""))
88        lists.sort(key=lambda tup: tup[0], reverse=True)
89        return lists
90