summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/gjs/src/variable.ts4
-rw-r--r--core/lua/astal/binding.lua20
-rw-r--r--core/lua/astal/process.lua4
-rw-r--r--core/lua/astal/variable.lua4
-rw-r--r--core/lua/test.lua8
5 files changed, 20 insertions, 20 deletions
diff --git a/core/gjs/src/variable.ts b/core/gjs/src/variable.ts
index 9528ffe..84f8cc5 100644
--- a/core/gjs/src/variable.ts
+++ b/core/gjs/src/variable.ts
@@ -1,6 +1,6 @@
import Binding, { type Connectable } from "./binding.js"
import { Astal } from "./imports.js"
-import { interval } from "./time.js"
+import { interval, idle } from "./time.js"
import { execAsync, subprocess } from "./process.js"
class VariableWrapper<T> extends Function {
@@ -101,7 +101,7 @@ class VariableWrapper<T> extends Function {
drop() {
this.variable.emit("dropped")
- this.variable.run_dispose()
+ idle(() => this.variable.run_dispose())
}
onDropped(callback: () => void) {
diff --git a/core/lua/astal/binding.lua b/core/lua/astal/binding.lua
index 50509d1..ba1e6e4 100644
--- a/core/lua/astal/binding.lua
+++ b/core/lua/astal/binding.lua
@@ -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
diff --git a/core/lua/astal/process.lua b/core/lua/astal/process.lua
index 3d10f8b..6f73613 100644
--- a/core/lua/astal/process.lua
+++ b/core/lua/astal/process.lua
@@ -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
diff --git a/core/lua/astal/variable.lua b/core/lua/astal/variable.lua
index 1e894b5..02d6b45 100644
--- a/core/lua/astal/variable.lua
+++ b/core/lua/astal/variable.lua
@@ -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
diff --git a/core/lua/test.lua b/core/lua/test.lua
deleted file mode 100644
index f5123a3..0000000
--- a/core/lua/test.lua
+++ /dev/null
@@ -1,8 +0,0 @@
-local App = require("astal.application")
-
-App:start({
- instance_name = "test",
- main = function()
- App:quit(1)
- end,
-})