summaryrefslogtreecommitdiff
path: root/docs/guide
diff options
context:
space:
mode:
authorKevin <[email protected]>2025-01-23 09:34:46 -0300
committerGitHub <[email protected]>2025-01-23 13:34:46 +0100
commit907230e479ba6c9489463797f81c7348ed754302 (patch)
tree4f12e013cebcff9097ae6a0e23885f1236b8b3d7 /docs/guide
parent4d6d85562be7fe25cf659f1f1898244e1bdb44ca (diff)
add: lua gtk3 examples (#156)
Diffstat (limited to 'docs/guide')
-rw-r--r--docs/guide/getting-started/supported-languages.md9
-rw-r--r--docs/guide/lua/binding.md21
-rw-r--r--docs/guide/lua/examples.md9
3 files changed, 34 insertions, 5 deletions
diff --git a/docs/guide/getting-started/supported-languages.md b/docs/guide/getting-started/supported-languages.md
index 0dc3f62..c38a001 100644
--- a/docs/guide/getting-started/supported-languages.md
+++ b/docs/guide/getting-started/supported-languages.md
@@ -39,6 +39,15 @@ Examples:
- [Simple Bar](https://github.com/Aylur/astal/tree/main/examples/gtk3/lua/simple-bar)
![simple-bar](https://github.com/user-attachments/assets/a306c864-56b7-44c4-8820-81f424f32b9b)
+- [Notification Popups](https://github.com/Aylur/astal/tree/main/examples/lua/notifications)
+![notification-popups](https://github.com/user-attachments/assets/0df0eddc-5c74-4af0-a694-48dc8ec6bb44)
+
+- [Applauncher](https://github.com/Aylur/astal/tree/main/examples/lua/applauncher)
+![launcher](https://github.com/user-attachments/assets/2695e3bb-dff4-478a-b392-279fe638bfd3)
+
+- [Media Player](https://github.com/Aylur/astal/tree/main/examples/lua/media-player)
+![media-player](https://github.com/user-attachments/assets/891e9706-74db-4505-bd83-c3628d7b4fd0)
+
## Python
There is a WIP [package for python](https://github.com/aylur/astal/tree/feat/python),
diff --git a/docs/guide/lua/binding.md b/docs/guide/lua/binding.md
index f4d5f0b..f9957b5 100644
--- a/docs/guide/lua/binding.md
+++ b/docs/guide/lua/binding.md
@@ -68,12 +68,13 @@ local Gtk = require("astal.gtk3").Gtk
local Variable = require("astal.variable")
---@param initial table
+---@return varmap
return function(initial)
local map = initial
- local var = Variable()
+ local var = Variable.new({})
local function notify()
- local arr
+ local arr = {}
for _, value in pairs(map) do
table.insert(arr, value)
end
@@ -90,7 +91,13 @@ return function(initial)
notify() -- init
- return {
+ ---@class varmap
+ ---@field set fun(key: any, value: any): nil
+ ---@field delete fun(key: any): nil
+ ---@field get fun(): any
+ ---@field subscribe fun(callback: function): function
+ ---@overload fun(): Binding
+ return setmetatable({
set = function(key, value)
delete(key)
map[key] = value
@@ -106,7 +113,11 @@ return function(initial)
subscribe = function(callback)
return var:subscribe(callback)
end,
- }
+ }, {
+ __call = function()
+ return var()
+ end,
+ })
end
```
@@ -130,7 +141,7 @@ function MappedBox()
map.delete(id)
end)
end,
- bind(map):as(function (arr)
+ map():as(function(arr)
-- can be sorted here
return arr
end),
diff --git a/docs/guide/lua/examples.md b/docs/guide/lua/examples.md
index c2dd30c..464f917 100644
--- a/docs/guide/lua/examples.md
+++ b/docs/guide/lua/examples.md
@@ -2,3 +2,12 @@
## [Simple Bar](https://github.com/Aylur/astal/tree/main/examples/gtk3/lua/simple-bar)
![simple-bar](https://github.com/user-attachments/assets/a306c864-56b7-44c4-8820-81f424f32b9b)
+
+### [Notification Popups](https://github.com/Aylur/astal/tree/main/examples/gtk3/lua/notifications)
+![notification-popups](https://github.com/user-attachments/assets/0df0eddc-5c74-4af0-a694-48dc8ec6bb44)
+
+### [Applauncher](https://github.com/Aylur/astal/tree/main/examples/gtk3/lua/applauncher)
+![launcher](https://github.com/user-attachments/assets/2695e3bb-dff4-478a-b392-279fe638bfd3)
+
+### [Media Player](https://github.com/Aylur/astal/tree/main/examples/gtk3/lua/media-player)
+![media-player](https://github.com/user-attachments/assets/891e9706-74db-4505-bd83-c3628d7b4fd0)