Process episode list selection changes every 250ms.

A fast key repeat rate can cause on_episode_list_selection_changed to be
called quicker than it can update the UI. This slows down
shift-selections and results in continued processing long after the key
has been released.

The 250ms timer batches multiple events into a single update, and
improves responsiveness on slower machines.
This commit is contained in:
auouymous 2022-12-17 17:49:42 -07:00
parent e1fc290ef2
commit 6c7337f5fb
1 changed files with 9 additions and 0 deletions

View File

@ -93,6 +93,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
self.last_episode_date_refresh = None
self.refresh_episode_dates()
self.on_episode_list_selection_changed_id = None
def new(self):
if self.application.want_headerbar:
self.header_bar = Gtk.HeaderBar()
@ -1059,6 +1061,13 @@ class gPodder(BuilderWidget, dbus.service.Object):
self._search_episodes.show_search(grab_focus=False)
def on_episode_list_selection_changed(self, selection):
# Only update the UI every 250ms to prevent lag when rapidly changing selected episode or shift-selecting episodes
if self.on_episode_list_selection_changed_id is None:
self.on_episode_list_selection_changed_id = util.idle_timeout_add(250, self._on_episode_list_selection_changed)
def _on_episode_list_selection_changed(self):
self.on_episode_list_selection_changed_id = None
# Update the toolbar buttons
self.play_or_download()
# and the shownotes