-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu_mopidy.py
51 lines (43 loc) · 1.24 KB
/
menu_mopidy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from pathlib import Path
import logging
from menu import ListMenu
logger = logging.getLogger(__name__)
class MopidyMenu(ListMenu):
def __init__(
self,
model=None,
name=None,
background_bitmap=None,
icon_path=Path(),
parent=None,
selected_child=None,
uri=None,
):
super().__init__(
model=model,
name=name,
background_bitmap=background_bitmap,
icon_path=icon_path,
parent=parent,
selected_child=selected_child,
)
self.children = []
self.uri = uri
def __str__(self):
return f"{type(self)} {self.name} {self.uri}"
def callback(self):
if not self.children:
logger.info("populating children")
self.populate_children_from_uri()
self.model.current_menu = self
def populate_children_from_uri(self):
refs = self.model.mopidy.library.browse(self.uri)
for ref in refs:
self.add_child(
MopidyMenu(
self.model,
name=ref.name,
background_bitmap="menu_albums_album.bmp",
uri=ref.uri,
)
)