summaryrefslogtreecommitdiff
path: root/lang/lua/astal/gtk3/widget.lua
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-10-15 13:25:45 +0000
committerAylur <[email protected]>2024-10-15 13:29:19 +0000
commitbafd48d3df9b43a1d49ec015eff30619d595468b (patch)
treed5c3788835ca7e50d68cd023026e7738f39f6f71 /lang/lua/astal/gtk3/widget.lua
parentfe11c037bad45697451b7264ff93fa37f1fac78f (diff)
update lua and gjs layout
installing the gjs package through meson or npm now results in the same exposed structure lua: fix rockspec docs: aur package
Diffstat (limited to 'lang/lua/astal/gtk3/widget.lua')
-rw-r--r--lang/lua/astal/gtk3/widget.lua90
1 files changed, 90 insertions, 0 deletions
diff --git a/lang/lua/astal/gtk3/widget.lua b/lang/lua/astal/gtk3/widget.lua
new file mode 100644
index 0000000..beaad6c
--- /dev/null
+++ b/lang/lua/astal/gtk3/widget.lua
@@ -0,0 +1,90 @@
+local lgi = require("lgi")
+local Astal = lgi.require("Astal", "3.0")
+local Gtk = lgi.require("Gtk", "3.0")
+local astalify = require("astal.gtk3.astalify")
+
+local Widget = {
+ astalify = astalify,
+ Box = astalify(Astal.Box),
+ Button = astalify(Astal.Button),
+ CenterBox = astalify(Astal.CenterBox),
+ CircularProgress = astalify(Astal.CircularProgress),
+ DrawingArea = astalify(Gtk.DrawingArea),
+ Entry = astalify(Gtk.Entry),
+ EventBox = astalify(Astal.EventBox),
+ -- TODO: Fixed
+ -- TODO: FlowBox
+ Icon = astalify(Astal.Icon),
+ Label = astalify(Gtk.Label),
+ LevelBar = astalify(Astal.LevelBar),
+ -- TODO: ListBox
+ Overlay = astalify(Astal.Overlay),
+ Revealer = astalify(Gtk.Revealer),
+ Scrollable = astalify(Astal.Scrollable),
+ Slider = astalify(Astal.Slider),
+ Stack = astalify(Astal.Stack),
+ Switch = astalify(Gtk.Switch),
+ Window = astalify(Astal.Window),
+}
+
+Gtk.Widget._attribute.css = {
+ get = Astal.widget_get_css,
+ set = Astal.widget_set_css,
+}
+
+Gtk.Widget._attribute.class_name = {
+ get = function(self)
+ local result = ""
+ local strings = Astal.widget_get_class_names(self)
+ for i, str in ipairs(strings) do
+ result = result .. str
+ if i < #strings then
+ result = result .. " "
+ end
+ end
+ return result
+ end,
+ set = function(self, class_name)
+ local names = {}
+ for word in class_name:gmatch("%S+") do
+ table.insert(names, word)
+ end
+ Astal.widget_set_class_names(self, names)
+ end,
+}
+
+Gtk.Widget._attribute.cursor = {
+ get = Astal.widget_get_cursor,
+ set = Astal.widget_set_cursor,
+}
+
+Gtk.Widget._attribute.click_through = {
+ get = Astal.widget_get_click_through,
+ set = Astal.widget_set_click_through,
+}
+
+local no_implicit_destroy = {}
+Gtk.Widget._attribute.no_implicit_destroy = {
+ get = function(self)
+ return no_implicit_destroy[self] or false
+ end,
+ set = function(self, v)
+ if no_implicit_destroy[self] == nil then
+ self.on_destroy = function()
+ no_implicit_destroy[self] = nil
+ end
+ end
+ no_implicit_destroy[self] = v
+ end,
+}
+
+Astal.Box._attribute.children = {
+ get = Astal.Box.get_children,
+ set = Astal.Box.set_children,
+}
+
+return setmetatable(Widget, {
+ __call = function(_, ctor)
+ return astalify(ctor)
+ end,
+})