1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

Allow parameters to layout functions

This commit is contained in:
slush0 2016-04-28 04:56:24 +02:00 committed by Pavol Rusnak
parent 46353ed2e1
commit f2703f1af2
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -1,7 +1,9 @@
import sys
_new_layout = None
_current_layout = None
def change_layout(layout):
def change(layout):
global _new_layout
print("Changing layout to %s" % layout)
@ -9,27 +11,26 @@ def change_layout(layout):
yield _current_layout.throw(StopIteration())
def set_main_layout(main_layout):
def set_main(main_layout):
global _new_layout
global _current_layout
layout = main_layout
_current_layout = main_layout
while True:
try:
_current_layout = layout()
layout = yield from _current_layout
_current_layout = yield from _current_layout
except Exception as e:
print("Layout thrown exception %s" % str(e))
sys.print_exception(e)
_current_layout = main_layout
continue
if _new_layout != None:
print("Switching to new layout %s" % _new_layout)
layout = _new_layout
_current_layout = _new_layout
_new_layout = None
elif layout == None:
elif not callable(_current_layout):
print("Switching to main layout %s" % main_layout)
layout = main_layout
_current_layout = main_layout
else:
print("Switching to proposed layout %s" % layout)
print("Switching to proposed layout %s" % _current_layout)