Play next and add to queue work now
This commit is contained in:
@@ -282,12 +282,22 @@ class LibremsonicApp(Gtk.Application):
|
|||||||
self.update_window()
|
self.update_window()
|
||||||
|
|
||||||
def on_play_next(self, action, song_ids):
|
def on_play_next(self, action, song_ids):
|
||||||
# TODO
|
if self.state.current_song is None:
|
||||||
print(song_ids)
|
insert_at = 0
|
||||||
|
else:
|
||||||
|
insert_at = (
|
||||||
|
self.state.play_queue.index(self.state.current_song.id) + 1)
|
||||||
|
|
||||||
|
self.state.play_queue = (self.state.play_queue[:insert_at]
|
||||||
|
+ list(song_ids)
|
||||||
|
+ self.state.play_queue[insert_at:])
|
||||||
|
self.state.old_play_queue.extend(song_ids)
|
||||||
|
self.update_window()
|
||||||
|
|
||||||
def on_add_to_queue(self, action, song_ids):
|
def on_add_to_queue(self, action, song_ids):
|
||||||
# TODO
|
self.state.play_queue.extend(song_ids)
|
||||||
print(song_ids)
|
self.state.old_play_queue.extend(song_ids)
|
||||||
|
self.update_window()
|
||||||
|
|
||||||
def on_go_to_album(self, action, album_id):
|
def on_go_to_album(self, action, album_id):
|
||||||
# TODO
|
# TODO
|
||||||
|
@@ -124,6 +124,7 @@ class AlbumsPanel(Gtk.Box):
|
|||||||
model.append((genre.value, genre.value))
|
model.append((genre.value, genre.value))
|
||||||
|
|
||||||
self.populating_genre_combo = False
|
self.populating_genre_combo = False
|
||||||
|
# TODO Get this from state
|
||||||
self.genre_combo.set_active_id(self.currently_active_genre)
|
self.genre_combo.set_active_id(self.currently_active_genre)
|
||||||
|
|
||||||
genres_future = CacheManager.get_genres()
|
genres_future = CacheManager.get_genres()
|
||||||
|
@@ -74,26 +74,30 @@ class AlbumWithSongs(Gtk.Box):
|
|||||||
halign=Gtk.Align.START,
|
halign=Gtk.Align.START,
|
||||||
))
|
))
|
||||||
|
|
||||||
play_btn = IconButton('media-playback-start-symbolic')
|
self.play_btn = IconButton('media-playback-start-symbolic',
|
||||||
play_btn.connect('clicked', self.play_btn_clicked)
|
sensitive=False)
|
||||||
album_title_and_buttons.pack_start(play_btn, False, False, 5)
|
self.play_btn.connect('clicked', self.play_btn_clicked)
|
||||||
|
album_title_and_buttons.pack_start(self.play_btn, False, False, 5)
|
||||||
|
|
||||||
shuffle_btn_clicked = IconButton('media-playlist-shuffle-symbolic')
|
self.shuffle_btn = IconButton('media-playlist-shuffle-symbolic',
|
||||||
shuffle_btn_clicked.connect('clicked', self.shuffle_btn_clicked)
|
sensitive=False)
|
||||||
album_title_and_buttons.pack_start(shuffle_btn_clicked, False, False,
|
self.shuffle_btn.connect('clicked', self.shuffle_btn_clicked)
|
||||||
|
album_title_and_buttons.pack_start(self.shuffle_btn, False, False, 5)
|
||||||
|
|
||||||
|
self.play_next_btn = IconButton('go-top-symbolic',
|
||||||
|
action_name='app.play-next')
|
||||||
|
album_title_and_buttons.pack_start(self.play_next_btn, False, False, 5)
|
||||||
|
|
||||||
|
self.add_to_queue_btn = IconButton('go-jump-symbolic',
|
||||||
|
action_name='app.add-to-queue')
|
||||||
|
album_title_and_buttons.pack_start(self.add_to_queue_btn, False, False,
|
||||||
5)
|
5)
|
||||||
|
|
||||||
play_next = IconButton('go-top-symbolic')
|
self.download_all_btn = IconButton('folder-download-symbolic',
|
||||||
play_next.connect('clicked', self.play_next_clicked)
|
sensitive=False)
|
||||||
album_title_and_buttons.pack_start(play_next, False, False, 5)
|
self.download_all_btn.connect('clicked', self.on_download_all_click)
|
||||||
|
album_title_and_buttons.pack_end(self.download_all_btn, False, False,
|
||||||
add_to_queue = IconButton('go-jump-symbolic')
|
5)
|
||||||
add_to_queue.connect('clicked', self.add_to_queue_clicked)
|
|
||||||
album_title_and_buttons.pack_start(add_to_queue, False, False, 5)
|
|
||||||
|
|
||||||
download_all_btn = IconButton('folder-download-symbolic')
|
|
||||||
download_all_btn.connect('clicked', self.on_download_all_click)
|
|
||||||
album_title_and_buttons.pack_end(download_all_btn, False, False, 5)
|
|
||||||
|
|
||||||
album_details.add(album_title_and_buttons)
|
album_details.add(album_title_and_buttons)
|
||||||
|
|
||||||
@@ -250,14 +254,6 @@ class AlbumWithSongs(Gtk.Box):
|
|||||||
{'force_shuffle_state': True},
|
{'force_shuffle_state': True},
|
||||||
)
|
)
|
||||||
|
|
||||||
def play_next_clicked(self, btn):
|
|
||||||
# TODO
|
|
||||||
print('play next')
|
|
||||||
|
|
||||||
def add_to_queue_clicked(self, btn):
|
|
||||||
# TODO
|
|
||||||
print('add to queue')
|
|
||||||
|
|
||||||
# Helper Methods
|
# Helper Methods
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
def deselect_all(self):
|
def deselect_all(self):
|
||||||
@@ -283,5 +279,15 @@ class AlbumWithSongs(Gtk.Box):
|
|||||||
song.id,
|
song.id,
|
||||||
] for song in (album.get('child') or album.get('song') or [])]
|
] for song in (album.get('child') or album.get('song') or [])]
|
||||||
|
|
||||||
|
song_ids = [song[-1] for song in new_store]
|
||||||
|
|
||||||
|
self.play_btn.set_sensitive(True)
|
||||||
|
self.shuffle_btn.set_sensitive(True)
|
||||||
|
self.play_next_btn.set_action_target_value(GLib.Variant(
|
||||||
|
'as', song_ids))
|
||||||
|
self.add_to_queue_btn.set_action_target_value(
|
||||||
|
GLib.Variant('as', song_ids))
|
||||||
|
self.download_all_btn.set_sensitive(True)
|
||||||
|
|
||||||
util.diff_store(self.album_song_store, new_store)
|
util.diff_store(self.album_song_store, new_store)
|
||||||
self.loading_indicator.hide()
|
self.loading_indicator.hide()
|
||||||
|
@@ -10,8 +10,9 @@ class IconButton(Gtk.Button):
|
|||||||
relief=False,
|
relief=False,
|
||||||
icon_size=Gtk.IconSize.BUTTON,
|
icon_size=Gtk.IconSize.BUTTON,
|
||||||
label=None,
|
label=None,
|
||||||
|
**kwargs
|
||||||
):
|
):
|
||||||
Gtk.Button.__init__(self)
|
Gtk.Button.__init__(self, **kwargs)
|
||||||
self.icon_size = icon_size
|
self.icon_size = icon_size
|
||||||
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
|
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
|
||||||
name='icon-button-box')
|
name='icon-button-box')
|
||||||
|
Reference in New Issue
Block a user