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
|
return function(parent, dir)
local lgi = require 'lgi'
local Gtk = lgi.Gtk
local window = Gtk.Dialog {
title = "Gtk.Spinner",
transient_for = parent,
buttons = {
{ Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE },
},
resizable = false,
on_response = Gtk.Widget.destroy,
}
window:get_content_area():add(
Gtk.Box {
orientation = 'VERTICAL',
border_width = 5,
spacing = 5,
Gtk.Box {
orientation = 'HORIZONTAL',
spacing = 5,
Gtk.Spinner {
id = 'sensitive',
active = true,
},
Gtk.Entry {},
},
Gtk.Box {
orientation = 'HORIZONTAL',
spacing = 5,
Gtk.Spinner {
id = 'insensitive',
sensitive = false,
active = true,
},
Gtk.Entry {},
},
Gtk.Button {
id = 'play',
label = Gtk.STOCK_MEDIA_PLAY,
use_stock = true,
},
Gtk.Button {
id = 'stop',
label = Gtk.STOCK_MEDIA_STOP,
use_stock = true,
},
})
function window.child.play:on_clicked()
window.child.sensitive.active = true
window.child.insensitive.active = true
end
function window.child.stop:on_clicked()
window.child.sensitive.active = false
window.child.insensitive.active = false
end
window:show_all()
return window
end,
"Spinner",
table.concat {
[[Gtk.Spinner allows to show that background activity is on-going.]]
}
|