From de74cfcdca28ab34a98ab0823ab0509ae3228e6a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Aug 2010 04:32:23 -0400 Subject: [PATCH] Update (don't re-add) already loaded playlists in HookeFrame._postprocess_playlists --- hooke/ui/gui/__init__.py | 3 +-- hooke/ui/gui/panel/playlist.py | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hooke/ui/gui/__init__.py b/hooke/ui/gui/__init__.py index 3d8a92d..271b00a 100644 --- a/hooke/ui/gui/__init__.py +++ b/hooke/ui/gui/__init__.py @@ -410,10 +410,9 @@ class HookeFrame (wx.Frame): return assert len(results) == 2, results playlists = results[0] - loaded_playlists = [] # TODO if 'playlist' in self._c: for playlist in playlists: - if playlist in loaded_playlists: + if self._c['playlist'].is_playlist_loaded(playlist): self._c['playlist'].update_playlist(playlist) else: self._c['playlist'].add_playlist(playlist) diff --git a/hooke/ui/gui/panel/playlist.py b/hooke/ui/gui/panel/playlist.py index fd46d2d..a863dca 100644 --- a/hooke/ui/gui/panel/playlist.py +++ b/hooke/ui/gui/panel/playlist.py @@ -335,6 +335,11 @@ class Tree (wx.TreeCtrl): """ self._playlists[playlist.name] = playlist + def is_playlist_loaded(self, playlist): + """Return `True` if a playlist is loaded, `False` otherwise. + """ + return playlist.name in self._playlists + class Playlist (Panel, wx.Panel): """:class:`wx.Panel` subclass wrapper for :class:`Tree`. -- 2.26.2