summaryrefslogtreecommitdiff
path: root/src/menu.py
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2023-05-22 08:40:47 +0200
committerSébastien Dailly <sebastien@dailly.me>2023-05-22 08:40:47 +0200
commit597b007333d8ec0d9cfd29e6941fcbe57379108a (patch)
tree0cf87e1ac487e7deb91acf7f2bec70bd4dd06703 /src/menu.py
Initial commit
Diffstat (limited to 'src/menu.py')
-rw-r--r--src/menu.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/menu.py b/src/menu.py
new file mode 100644
index 0000000..319cae1
--- /dev/null
+++ b/src/menu.py
@@ -0,0 +1,23 @@
+import skeleton
+
+def build_application(apps):
+
+ enabled_apps = [app for app in apps if app.visible]
+ max_l = min(12, len(enabled_apps))
+ configuration = skeleton.Configuration("Application menu")
+ for index in range(max_l):
+ if enabled_apps[index] is None:
+ break
+
+ # I use a lambda function here, the index is stored in a closure
+ # otherwise the value is erased and only keep the last iteration
+ # index
+ callback = lambda n:lambda macropad, key, pressed:enabled_apps[n]
+
+ configuration.registerKey(
+ index,
+ enabled_apps[index].title,
+ callback(index),
+ None
+ )
+ return configuration