mirror of
https://github.com/vale981/clay
synced 2025-03-05 09:31:40 -05:00
Fix #29
This commit is contained in:
parent
4edb5cd4f3
commit
b180bee6bb
9 changed files with 91 additions and 7 deletions
42
clay/app.py
42
clay/app.py
|
@ -99,7 +99,7 @@ class AppWidget(urwid.Frame):
|
||||||
body=urwid.Filler(urwid.Text('Loading...', align='center'))
|
body=urwid.Filler(urwid.Text('Loading...', align='center'))
|
||||||
)
|
)
|
||||||
|
|
||||||
self.set_page('MyLibraryPage')
|
self.set_page('library')
|
||||||
self.log_in()
|
self.log_in()
|
||||||
|
|
||||||
def log_in(self, use_token=True):
|
def log_in(self, use_token=True):
|
||||||
|
@ -181,11 +181,11 @@ class AppWidget(urwid.Frame):
|
||||||
"""
|
"""
|
||||||
self.loop = loop
|
self.loop = loop
|
||||||
|
|
||||||
def set_page(self, classname):
|
def set_page(self, slug):
|
||||||
"""
|
"""
|
||||||
Switch to a different tab.
|
Switch to a different tab.
|
||||||
"""
|
"""
|
||||||
page = [page for page in self.pages if page.__class__.__name__ == classname][0]
|
page = [page for page in self.pages if page.slug == slug][0]
|
||||||
self.current_page = page
|
self.current_page = page
|
||||||
self.contents['body'] = (page, None)
|
self.contents['body'] = (page, None)
|
||||||
|
|
||||||
|
@ -225,13 +225,41 @@ class AppWidget(urwid.Frame):
|
||||||
Handle keypress.
|
Handle keypress.
|
||||||
Can switch tabs, control playback, flags, notifications and app state.
|
Can switch tabs, control playback, flags, notifications and app state.
|
||||||
"""
|
"""
|
||||||
for tab in self.tabs:
|
# for tab in self.tabs:
|
||||||
if 'meta {}'.format(tab.page.key) == key:
|
# if 'meta {}'.format(tab.page.key) == key:
|
||||||
self.set_page(tab.page.__class__.__name__)
|
# self.set_page(tab.page.__class__.__name__)
|
||||||
return
|
# return
|
||||||
|
|
||||||
hotkey_manager.keypress("global", self, super(AppWidget, self), size, key)
|
hotkey_manager.keypress("global", self, super(AppWidget, self), size, key)
|
||||||
|
|
||||||
|
def show_debug(self):
|
||||||
|
""" Show debug page. """
|
||||||
|
self.set_page('debug')
|
||||||
|
|
||||||
|
def show_library(self):
|
||||||
|
""" Show library page. """
|
||||||
|
self.set_page('library')
|
||||||
|
|
||||||
|
def show_playlists(self):
|
||||||
|
""" Show playlists page. """
|
||||||
|
self.set_page('playlists')
|
||||||
|
|
||||||
|
def show_stations(self):
|
||||||
|
""" Show stations page. """
|
||||||
|
self.set_page('stations')
|
||||||
|
|
||||||
|
def show_queue(self):
|
||||||
|
""" Show queue page. """
|
||||||
|
self.set_page('queue')
|
||||||
|
|
||||||
|
def show_search(self):
|
||||||
|
""" Show search page. """
|
||||||
|
self.set_page('search')
|
||||||
|
|
||||||
|
def show_settings(self):
|
||||||
|
""" Show settings page. """
|
||||||
|
self.set_page('settings')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def seek_start():
|
def seek_start():
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -19,6 +19,13 @@ hotkeys:
|
||||||
prev_song: mod + a
|
prev_song: mod + a
|
||||||
toggle_repeat_one: mod + o
|
toggle_repeat_one: mod + o
|
||||||
handle_escape: esc, mod + _
|
handle_escape: esc, mod + _
|
||||||
|
show_debug: meta + 0
|
||||||
|
show_library: meta + 1
|
||||||
|
show_playlists: meta + 2
|
||||||
|
show_stations: meta + 3
|
||||||
|
show_queue: meta + 4
|
||||||
|
show_search: meta + 5
|
||||||
|
show_settings: meta + 9
|
||||||
|
|
||||||
library_item:
|
library_item:
|
||||||
activate: enter
|
activate: enter
|
||||||
|
|
|
@ -97,6 +97,13 @@ class DebugPage(urwid.Pile, AbstractPage):
|
||||||
"""
|
"""
|
||||||
return "Debug"
|
return "Debug"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def slug(self):
|
||||||
|
"""
|
||||||
|
Return page ID (str).
|
||||||
|
"""
|
||||||
|
return "debug"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def key(self):
|
def key(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -23,6 +23,13 @@ class MyLibraryPage(urwid.Columns, AbstractPage):
|
||||||
def key(self):
|
def key(self):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@property
|
||||||
|
def slug(self):
|
||||||
|
"""
|
||||||
|
Return page ID (str).
|
||||||
|
"""
|
||||||
|
return "library"
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.app = app
|
self.app = app
|
||||||
self.songlist = SongListBox(app)
|
self.songlist = SongListBox(app)
|
||||||
|
|
|
@ -126,6 +126,13 @@ class MyPlaylistsPage(urwid.Columns, AbstractPage):
|
||||||
def key(self):
|
def key(self):
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
|
@property
|
||||||
|
def slug(self):
|
||||||
|
"""
|
||||||
|
Return page ID (str).
|
||||||
|
"""
|
||||||
|
return "playlists"
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,13 @@ class MyStationsPage(urwid.Columns, AbstractPage):
|
||||||
def key(self):
|
def key(self):
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
|
@property
|
||||||
|
def slug(self):
|
||||||
|
"""
|
||||||
|
Return page ID (str).
|
||||||
|
"""
|
||||||
|
return "stations"
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,13 @@ class QueuePage(urwid.Columns, AbstractPage):
|
||||||
def key(self):
|
def key(self):
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
|
@property
|
||||||
|
def slug(self):
|
||||||
|
"""
|
||||||
|
Return page ID (str).
|
||||||
|
"""
|
||||||
|
return "queue"
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.app = app
|
self.app = app
|
||||||
self.songlist = SongListBox(app)
|
self.songlist = SongListBox(app)
|
||||||
|
|
|
@ -60,6 +60,13 @@ class SearchPage(urwid.Pile, AbstractPage):
|
||||||
def key(self):
|
def key(self):
|
||||||
return 5
|
return 5
|
||||||
|
|
||||||
|
@property
|
||||||
|
def slug(self):
|
||||||
|
"""
|
||||||
|
Return page ID (str).
|
||||||
|
"""
|
||||||
|
return "search"
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.app = app
|
self.app = app
|
||||||
self.songlist = SongListBox(app)
|
self.songlist = SongListBox(app)
|
||||||
|
|
|
@ -138,6 +138,13 @@ class SettingsPage(urwid.Columns, AbstractPage):
|
||||||
def key(self):
|
def key(self):
|
||||||
return 9
|
return 9
|
||||||
|
|
||||||
|
@property
|
||||||
|
def slug(self):
|
||||||
|
"""
|
||||||
|
Return page ID (str).
|
||||||
|
"""
|
||||||
|
return "settings"
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.app = app
|
self.app = app
|
||||||
self.username = urwid.Edit(
|
self.username = urwid.Edit(
|
||||||
|
|
Loading…
Add table
Reference in a new issue