[core/theme] Add true cycling support

Using the freshly introduced eventing system, enable cycling of widget
attributes.
This commit is contained in:
Tobias Witek 2020-02-16 14:39:10 +01:00
parent a4904d998f
commit 6e5e297d93
3 changed files with 26 additions and 6 deletions

View file

@ -14,7 +14,8 @@ class theme(unittest.TestCase):
self.cycleTheme = {
'cycle': [
{ 'fg': 'red', 'bg': 'black' },
{ 'fg': 'black', 'bg': 'red' }
{ 'fg': 'black', 'bg': 'red' },
{ 'fg': 'white', 'bg': 'blue' }
]
}
@ -35,5 +36,12 @@ class theme(unittest.TestCase):
theme = core.theme.Theme(raw_data=self.cycleTheme)
self.assertEqual(self.cycleTheme['cycle'][0]['fg'], theme.fg())
self.assertEqual(self.cycleTheme['cycle'][0]['bg'], theme.bg())
core.event.trigger('next-widget')
core.event.trigger('next-widget')
self.assertEqual(self.cycleTheme['cycle'][2]['fg'], theme.fg())
self.assertEqual(self.cycleTheme['cycle'][2]['bg'], theme.bg())
core.event.trigger('start')
self.assertEqual(self.cycleTheme['cycle'][0]['fg'], theme.fg())
self.assertEqual(self.cycleTheme['cycle'][0]['bg'], theme.bg())
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4