-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmusicLibraryPage.py
159 lines (129 loc) · 5.73 KB
/
musicLibraryPage.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import soco
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GdkPixbuf
from PageBase import PageBase
from Zone import Zone
from socos.music_lib import MusicLibrary
from mediaListItemsPage import MediaListItemsPage
import imageManager
class Dialog(Gtk.Dialog):
def __init__(self, parent):
Gtk.Dialog.__init__(self, "Pause All", parent, 0,
(Gtk.STOCK_NO, Gtk.ResponseType.CANCEL,
Gtk.STOCK_YES, Gtk.ResponseType.OK))
self.set_default_size(80, 100)
label = Gtk.Label("Do you want to pause all devices?")
box = self.get_content_area()
box.add(label)
self.show_all()
class MusicLibraryPage(PageBase):
def on_Button_A_Clicked(self):
pass
def on_Button_B_Clicked(self):
pass
def on_Button_C_Clicked(self):
self.topLevel.show_queue_page()
def on_Return_Button_Clicked(self):
self.topLevel.show_page("MusicPage")
# The scroll wheel
def on_Scroll_Up(self):
if self.selected_row_iter is not None:
self.selected_row_iter = self.libStore.iter_previous(self.selected_row_iter)
if self.selected_row_iter is None:
self.selected_row_iter = self.libStore.get_iter_first()
self.select.select_iter(self.selected_row_iter)
def on_Scroll_Down(self):
if self.selected_row_iter is not None:
last = self.selected_row_iter
self.selected_row_iter = self.libStore.iter_next(self.selected_row_iter)
if self.selected_row_iter is None:
self.selected_row_iter = last
self.select.select_iter(self.selected_row_iter)
def on_Button_Ok_Clicked(self):
# Enter selected item's function
model, treeiter = self.select.get_selected()
if treeiter is not None:
print(model.get_value(treeiter, 0))
if self.selectedZone is not None:
search_type = model.get_value(treeiter, 2)
if search_type == 'artists':
page = self.topLevel.get_page("MediaListArtistsPage")
elif search_type == 'albums':
page = self.topLevel.get_page("MediaListAlbumsPage")
elif search_type == 'tracks':
page = self.topLevel.get_page("MediaListTracksPage")
if page is not None:
page.clear()
#results = self.selectedZone.sonos.music_library.get_music_library_information(search_type=search_type, start=0, max_items=10)#, complete_result=True)
results = self.selectedZone.sonos.music_library.get_music_library_information(search_type=search_type, complete_result=True)
page.set_items(search_type, results, self)
self.topLevel.show_page(page)
def on_tree_selection_changed(self, selection):
# if row item (2) is false hide B button label, else show it
model, treeiter = selection.get_selected()
if treeiter is not None: # and Zones is not None:
self.libListView.scroll_to_cell(model.get_path(treeiter), column=None, use_align=False, row_align=0.0, col_align=0.0)
print("Selected: ", model.get_value(treeiter, 0))
def on_zone_transport_change_event(self, event):
pass
def on_zone_render_change_event(self, event):
pass
def title(self):
self.titleLabel = Gtk.Label("Music Library")
return(self.titleLabel)
def scrolledWindow(self):
self.arrowMore = imageManager.get_image('more').Scale(16, 16)
self.libStore = Gtk.ListStore(str, GdkPixbuf.Pixbuf, str, bool, object)
self.libListView = Gtk.TreeView(self.libStore)
self.libListView.set_headers_visible(False)
rend = Gtk.CellRendererText()
col = Gtk.TreeViewColumn("Type", rend, text=0)
col.set_resizable(False)
col.set_expand(False)
self.libListView.append_column(col)
rend = Gtk.CellRendererPixbuf()
#rend.set_property('cell-background', 'white')
col = Gtk.TreeViewColumn("I", rend, pixbuf = 1)
col.set_resizable(False)
col.set_expand(False)
col.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
self.libListView.append_column(col)
# Possible browsing items
self.libStore.append(["Artist", self.arrowMore, "artists", True, None])
self.libStore.append(["Albums", self.arrowMore, "albums", True, None])
self.libStore.append(["Composers", self.arrowMore, "composers", True, None])
self.libStore.append(["Genres", self.arrowMore, "genres", True, None])
self.libStore.append(["Tracks", self.arrowMore, "tracks", True, None])
self.libStore.append(["Imported Playlists", self.arrowMore, "playlists", True, None])
self.libStore.append(["Search", self.arrowMore, "search", False, None])
self.libStore.append(["Folders", self.arrowMore, "folders", False, None])
self.select = self.libListView.get_selection()
self.select.connect("changed", self.on_tree_selection_changed)
self.selected_row_iter = self.libStore.get_iter_first()
if self.selected_row_iter is not None:
self.select.select_iter(self.selected_row_iter)
sw = Gtk.ScrolledWindow()
sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER)
#sw.set_min_content_height(250)
sw.add(self.libListView)
return(sw)
def status(self):
return Gtk.Label("Status goes here.")
def footer(self):
grid = Gtk.Grid()
l = Gtk.Label(" ")
l.set_hexpand(True)
l.set_size_request(100, -1)
grid.add(l)
l = Gtk.Label("Add to Queue")
l.set_hexpand(True)
l.set_size_request(100, -1)
grid.attach(l, 1, 0, 1, 1)
l = Gtk.Label("View Queue")
l.set_hexpand(True)
l.set_size_request(100, -1)
grid.attach(l, 2, 0, 1, 1)
return grid
def __init__(self, topLevel):
super().__init__(topLevel)