Whitespace

This commit is contained in:
Peder Bergebakken Sundt 2022-02-20 00:13:19 +01:00
parent 5e848cb16f
commit b4bf1d335a
1 changed files with 76 additions and 58 deletions

View File

@ -17,7 +17,7 @@ class RemiApp(App):
self.old_playlist = None
super(RemiApp, self).__init__(*args, static_file_path=res_path)
def make_gui_elements(self):#content and behaviour
def make_gui_elements(self): # content and behaviour
#logo:
self.logo_image = gui.Image('/res/logo.png')
self.logo_image.attributes["onclick"] = "document.location='https://www.youtube.com/watch?v=t-fcrn1Edik'"
@ -205,6 +205,7 @@ class RemiApp(App):
@call_as_thread
def playback_previous(self, widget):
api.playlist_previous()
@call_as_thread
def playback_play(self, widget):# toggle playblack
if api.is_playing():
@ -213,9 +214,11 @@ class RemiApp(App):
else:
api.set_playing(True)
self.set_playing(True)
@call_as_thread
def playback_next(self, widget):
api.playlist_next()
@call_as_thread
def input_submit(self, widget, value=None):
if value is None:
@ -232,39 +235,51 @@ class RemiApp(App):
self.input.submit.set_enabled(True)
api.load_path(value, data)
@call_as_thread
def change_seek(self, widget, value):
api.seek_percent(value)
@call_as_thread
def change_volume(self, widget, value):
api.set_volume(value)
@call_as_thread
def on_table_row_click(self, row_widget, playlist_item):
print("row", playlist_item)
@call_as_thread
def on_table_item_move_click(self, row_widget, playlist_item, down = True):
index = playlist_item["index"]
dest = index + 2 if down else index-1
api.playlist_move(index, dest)
@call_as_thread
def on_table_item_remove_click(self, row_widget, playlist_item):
api.playlist_remove(playlist_item["index"])
@call_as_thread
def on_table_item_goto_item(self, row_widget, playlist_item):
def on_table_item_play_item(self, row_widget, playlist_item):
api.playlist_goto(playlist_item["index"])
api.set_playing(True)
self.set_playing(True)
@call_as_thread
def on_playlist_set_looping(self, row_widget):
toggled = not row_widget.get_value()
api.playlist_set_looping(toggled)
row_widget.set_value(toggled)
@call_as_thread
def on_playlist_clear_shuffle(self, row_widget):
api.playlist_shuffle()
@call_as_thread
def on_playlist_clear_click(self, row_widget):
api.playlist_clear()
# gui updaters:
@call_as_thread
def playback_update(self):
is_playing = api.is_playing()
@ -289,6 +304,7 @@ class RemiApp(App):
self.playback.timestamp.set_text(f"{current} - {total}")
else:
self.playback.timestamp.set_text("--:-- - --:--")
@call_as_thread
def volume_update(self):
volume = api.get_volume()
@ -297,6 +313,7 @@ class RemiApp(App):
if self.playback.volume_slider.get_value() != volume:
self.playback.volume_slider.set_value(volume)
@call_as_thread
def playlist_update(self):
playlist = api.get_playlist() # json structure
@ -356,7 +373,7 @@ class RemiApp(App):
if item_index == 3: # seek here
item_widget.style["color"] = COLOR_GREEN#COLOR_RED if playlist_item.get("current", False) else
item_widget.set_on_click_listener(self.on_table_item_goto_item, playlist_item)
item_widget.set_on_click_listener(self.on_table_item_play_item, playlist_item)
item_widget.attributes["title"] = "Play this item"
if item_index == 4: # move up
@ -380,6 +397,7 @@ class RemiApp(App):
item_widget.attributes["title"] = "Remove this item from the playlist"
#print(index, key, item_widget)
def set_playing(self, is_playing:bool): # Updates GUI elements
def set_playing(self, is_playing:bool): # Only updates GUI elements!
self.playback.play.set_text(ICON_PAUSE if is_playing else ICON_PLAY)
self.playback.seek_slider.set_enabled(is_playing)