Merge pull request #5 from Aylur/nix/lua-builder

lua example, nix builder
This commit is contained in:
Aylur
2024-09-12 00:40:04 +02:00
committed by GitHub
18 changed files with 534 additions and 83 deletions
+13 -7
View File
@@ -29,10 +29,13 @@ function Binding:__tostring()
end
function Binding:get()
if self.property ~= nil and GObject.Object:is_type_of(self.emitter) then
return self.transformFn(self.emitter[self.property])
end
if type(self.emitter.get) == "function" then
return self.transformFn(self.emitter:get())
end
return self.transformFn(self.emitter[self.property])
error("can not get: Not a GObject or a Variable " + self)
end
---@param transform fun(value: any): any
@@ -48,17 +51,20 @@ end
---@param callback fun(value: any)
---@return function
function Binding:subscribe(callback)
if self.property ~= nil and GObject.Object:is_type_of(self.emitter) then
local id = self.emitter.on_notify:connect(function()
callback(self:get())
end, self.property, false)
return function()
GObject.signal_handler_disconnect(self.emitter, id)
end
end
if type(self.emitter.subscribe) == "function" then
return self.emitter:subscribe(function()
callback(self:get())
end)
end
local id = self.emitter.on_notify:connect(function()
callback(self:get())
end, self.property, false)
return function()
GObject.signal_handler_disconnect(self.emitter, id)
end
error("can not subscribe: Not a GObject or a Variable " + self)
end
Binding.__index = Binding
+2 -2
View File
@@ -72,7 +72,7 @@ function M.exec_async(commandline, on_stdout, on_stderr)
local out, err = defualt_proc_args(on_stdout, on_stderr)
if type(commandline) == "table" then
Astal.Process.exec_asyncv(commandline, function(_, res)
local stdout, fail = Astal.exec_asyncv_finish(res)
local stdout, fail = Astal.Process.exec_asyncv_finish(res)
if fail ~= nil then
err(fail)
else
@@ -81,7 +81,7 @@ function M.exec_async(commandline, on_stdout, on_stderr)
end)
else
Astal.Process.exec_async(commandline, function(_, res)
local stdout, fail = Astal.exec_finish(res)
local stdout, fail = Astal.Process.exec_finish(res)
if fail ~= nil then
err(fail)
else
+3 -1
View File
@@ -123,7 +123,9 @@ end
function Variable:drop()
self.variable.emit_dropped()
self.variable.run_dispose()
Astal.Time.idle(GObject.Closure(function()
self.variable.run_dispose()
end))
end
---@param callback function
-8
View File
@@ -1,8 +0,0 @@
local App = require("astal.application")
App:start({
instance_name = "test",
main = function()
App:quit(1)
end,
})