diff --git a/dev.sh b/dev.sh index f6e9865..cf0e282 100755 --- a/dev.sh +++ b/dev.sh @@ -1,5 +1,5 @@ -#!/bin/bash -if ! which entr > /dev/null; then +#!/usr/bin/env bash +if ! command -v entr > /dev/null; then echo "entr is not installed, aborting..." exit 1 fi diff --git a/flake.nix b/flake.nix index 2ae6bcb..b00444f 100644 --- a/flake.nix +++ b/flake.nix @@ -136,6 +136,7 @@ packages = [ pkgs.poetry pkgs.python3 + pkgs.entr ]; }; }); diff --git a/grzegorz_clients/remi_ui.py b/grzegorz_clients/remi_ui.py index c762ccd..8918096 100644 --- a/grzegorz_clients/remi_ui.py +++ b/grzegorz_clients/remi_ui.py @@ -320,6 +320,16 @@ class RemiApp(App): playlist = api.get_playlist() # json structure N = len(playlist) + start_ellipsis = False + end_ellipsis = False + if N > 100: + current, *_ = *(i for i, playlist_item in enumerate(playlist) if playlist_item.get("current", False)), None + if current is not None: + playlist = playlist[max(0, current - 50) : max(current+50, 100)] + start_ellipsis = current - 50 > 0 + end_ellipsis = max(current+50, 100) < N + + # update playlist table content: table = [] for playlist_item in playlist: @@ -340,6 +350,11 @@ class RemiApp(App): icons.TRASH, ]) + if start_ellipsis: + table.insert(0, ["", f"...{current - 50} more ...", "", "", "", "", ""]) + if end_ellipsis: + table.append(["", f"...{N - current - 50} more ...", "", "", "", "", ""]) + this_playlist = list(zip(table, [i.get("current", False) for i in playlist])) # ew, but it works... if this_playlist == self.old_playlist: return self.old_playlist = this_playlist @@ -349,7 +364,7 @@ class RemiApp(App): # styling the new table: # for each row element: - for row_key, playlist_item in zip(self.playlist.table._render_children_list[1:], playlist): + for row_key, playlist_item in zip(self.playlist.table._render_children_list[1:][1 if start_ellipsis else 0 : -1 if end_ellipsis else None], playlist): row_widget = self.playlist.table.get_child(row_key) row_widget.set_on_click_listener(self.on_table_row_click, playlist_item) @@ -399,6 +414,7 @@ class RemiApp(App): #print(index, key, item_widget) + def set_playing(self, is_playing:bool): # Only updates GUI elements! self.playback.play.set_text(icons.PAUSE if is_playing else icons.PLAY) self.playback.seek_slider.set_enabled(is_playing)