[#1] Added ability to load play queue from the server

This commit is contained in:
Sumner Evans
2019-06-29 22:56:30 -06:00
parent 51453d3f3b
commit fd7be04d37
2 changed files with 25 additions and 2 deletions

View File

@@ -104,6 +104,10 @@ class LibremsonicApp(Gtk.Application):
add_action('shuffle-press', self.on_shuffle_press) add_action('shuffle-press', self.on_shuffle_press)
add_action('mute-toggle', self.on_mute_toggle) add_action('mute-toggle', self.on_mute_toggle)
add_action(
'update-play-queue-from-server',
lambda a, p: self.update_play_state_from_server(),
)
def do_activate(self): def do_activate(self):
# We only allow a single window and raise any existing ones # We only allow a single window and raise any existing ones
@@ -292,6 +296,18 @@ class LibremsonicApp(Gtk.Application):
def update_window(self): def update_window(self):
GLib.idle_add(self.window.update, self.state) GLib.idle_add(self.window.update, self.state)
def update_play_state_from_server(self):
# TODO make this non-blocking eventually (need to make everything in
# loading state)
play_queue = CacheManager.get_play_queue()
self.state.play_queue = [s.id for s in play_queue.entry]
self.state.song_progress = play_queue.position / 1000
current_song_idx = self.state.play_queue.index(str(play_queue.current))
self.state.current_song = play_queue.entry[current_song_idx]
self.update_window()
def play_song(self, song: Child, reset=False, play_queue=None): def play_song(self, song: Child, reset=False, play_queue=None):
# Do this the old fashioned way so that we can have access to ``reset`` # Do this the old fashioned way so that we can have access to ``reset``
# in the callback. # in the callback.

View File

@@ -287,13 +287,20 @@ class PlayerControls(Gtk.ActionBar):
self.up_next_popover = Gtk.PopoverMenu(name='up-next-popover') self.up_next_popover = Gtk.PopoverMenu(name='up-next-popover')
popover_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) popover_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
popover_box_header = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
self.popover_label = Gtk.Label( self.popover_label = Gtk.Label(
'<b>Up Next</b>', '<b>Up Next</b>',
name='label',
use_markup=True, use_markup=True,
halign=Gtk.Align.START, halign=Gtk.Align.START,
) )
popover_box.add(self.popover_label) popover_box_header.add(self.popover_label)
load_up_next = Gtk.Button('Load Queue from Server', margin=5)
load_up_next.set_action_name('app.update-play-queue-from-server')
popover_box_header.pack_end(load_up_next, False, False, 0)
popover_box.add(popover_box_header)
popover_scroll_box = Gtk.ScrolledWindow( popover_scroll_box = Gtk.ScrolledWindow(
min_content_height=600, min_content_height=600,