Skip to content

Commit

Permalink
Several issues with history tab
Browse files Browse the repository at this point in the history
* enable again after closing
* clearing not working
* info widget does not show all information

Fixes #921
  • Loading branch information
luzip665 committed May 11, 2024
1 parent 76accdc commit 7870bed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
24 changes: 19 additions & 5 deletions plugins/history/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def on_gui_loaded(self):
if save_on_exit:
self.history_playlist.load_from_location(self.history_loc)

self.history_page = HistoryPlaylistPage(self.history_playlist, player.PLAYER)
self.history_tab = NotebookTab(main.get_playlist_notebook(), self.history_page)
self.history_tab = None
self.history_page = None

# add menu item to 'view' to display our playlist
self.menu = menu.check_menu_item(
Expand All @@ -81,7 +81,13 @@ def on_gui_loaded(self):

providers.register('menubar-view-menu', self.menu)

def on_exaile_loaded(self):
# add the history playlist to the primary notebook
save_on_exit = settings.get_option(
'plugin/history/save_on_exit', history_preferences.save_on_exit_default
)
shown = settings.get_option('plugin/history/shown', False)

if save_on_exit and shown:
self.show_history(True)

Expand Down Expand Up @@ -126,6 +132,8 @@ def disable(self, exaile):
dialog.destroy()

def is_shown(self):
if self.history_page is None:
return False
return main.get_playlist_notebook().page_num(self.history_page) != -1

def on_playback_history(self, menu, name, parent, context):
Expand All @@ -135,11 +143,17 @@ def show_history(self, show):
if show == self.is_shown():
return

pn = main.get_playlist_notebook()
if show:
pn = main.get_playlist_notebook()
self.history_page = HistoryPlaylistPage(
self.history_playlist, player.PLAYER
)
self.history_tab = NotebookTab(
main.get_playlist_notebook(), self.history_page
)
pn.add_tab(self.history_tab, self.history_page)
else:
self.history_tab.close()
pn.remove_tab(self.history_tab)


plugin_class = HistoryPlugin
Expand Down Expand Up @@ -190,7 +204,7 @@ def on_save(self):
self.save_history()

def on_clear_history(self, widget):
self.playlist._clear()
self.playlist.clear()

def on_save_history(self, widget):
self.save_history()
Expand Down
8 changes: 2 additions & 6 deletions xlgui/widgets/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,7 @@ def get_playlist_count(

page = xlgui.main.get_selected_page()

if not isinstance(page, playlist.PlaylistPage) and not isinstance(
page, queue.QueuePage
):
if not isinstance(page, playlist.PlaylistPageBase):
return ""

playlist_count = len(page.playlist)
Expand Down Expand Up @@ -488,9 +486,7 @@ def get_playlist_duration(self, format='short', selection='none'):

page = xlgui.main.get_selected_page()

if not isinstance(page, playlist.PlaylistPage) and not isinstance(
page, queue.QueuePage
):
if not isinstance(page, playlist.PlaylistPageBase):
return ''

playlist_duration = sum(t.get_tag_raw('__length') or 0 for t in page.playlist)
Expand Down

0 comments on commit 7870bed

Please sign in to comment.