/usr/share/doc/lua-lgi-dev/samples/mxwidgets.lua is in lua-lgi-dev 0.7.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | #! /usr/bin/env lua
--
-- Basic MX sample, adapted from Vala code from
-- http://live.gnome.org/Vala/MxSample
--
local lgi = require('lgi')
local GObject = lgi.GObject
local Mx = lgi.require('Mx', '1.0')
local Clutter = lgi.require('Clutter', '1.0')
local app = Mx.Application { application_name = "MX Widget Factory" }
local window = app:create_window()
window.clutter_stage:set_size(500, 300)
local hbox = Mx.BoxLayout()
window.toolbar:add_actor(hbox)
local button = Mx.Button {
label = "Click me",
tooltip_text = "Please click this button!",
on_clicked = function(self) self.label = "Thank you!" end
}
local combo = Mx.ComboBox()
for _, name in ipairs { "Africa", "Antarctica", "Asia", "Australia", "Europe",
"North America", "South America" } do
combo:append_text(name)
end
combo.index = 0
function combo.on_notify:index()
print(("Selected continent: %s"):format(self.active_text))
end
hbox:add(button, combo)
local table = Mx.Table { column_spacing = 24, row_spacing = 24 }
local button = Mx.Button { label = "Button" }
table:add_actor(button, 0, 0)
table.meta[button].y_fill = false
local entry = Mx.Entry { text = "Entry" }
table:add_actor(entry, 0, 1)
table.meta[entry].y_fill = false
local combo = Mx.ComboBox { active_text = "Combo Box" }
combo:append_text("Hello")
combo:append_text("Dave")
table:add_actor(combo, 0, 2)
table.meta[entry].y_fill = false
local scrollbar = Mx.ScrollBar {
adjustment = Mx.Adjustment {
lower = 0, upper = 10,
page_increment = 1, page_size = 1
},
height = 22
}
table:add_actor(scrollbar, 1, 0)
table.meta[entry].y_fill = false
local progressbar = Mx.ProgressBar { progress = 0.7 }
table:add_actor(progressbar, 1, 1)
table.meta[progressbar].y_fill = false
local slider = Mx.Slider()
table:add_actor(slider, 1, 2)
table.meta[slider].y_fill = false
function slider.on_notify:value()
progressbar.progress = slider.value
end
local pathbar = Mx.PathBar()
for _, path in ipairs { "", "Path", "Bar" } do pathbar:push(path) end
table:add_actor(pathbar, 2, 0)
local expander = Mx.Expander { label = "Expander" }
table:add_actor(expander, 2, 1)
table.meta[expander].y_fill = false
expander:add_actor(Mx.Label { text = "Hello" })
local toggle = Mx.Toggle()
table:add_actor(toggle, 2, 2)
table.meta[toggle].y_fill = false
local togglebutton = Mx.Button { label = "Toggle", is_toggle = true }
table:add_actor(togglebutton, 3, 0)
table.meta[togglebutton].y_fill = false
local checkbutton = Mx.Button { is_toggle = true }
checkbutton:set_style_class('check-box')
table:add_actor(checkbutton, 3, 1)
table.meta[checkbutton].y_fill = false
table.meta[checkbutton].x_fill = false
-- Just for fun, create binding between both kinds of toggles.
togglebutton:bind_property('toggled', checkbutton, 'toggled',
GObject.BindingFlags.BIDIRECTIONAL)
scrollbar = Mx.ScrollBar {
adjustment = Mx.Adjustment {
lower = 0, upper = 10,
page_increment = 1, page_size = 1,
},
orientation = Mx.Orientation.VERTICAL,
width = 22
}
table:add_actor(scrollbar, 0, 3)
table.meta[scrollbar].row_span = 3
window.child = Mx.Frame { child = table }
window.clutter_stage:show()
app:run()
|