demo-spinner.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. return function(parent, dir)
  2. local lgi = require 'lgi'
  3. local Gtk = lgi.Gtk
  4. local window = Gtk.Dialog {
  5. title = "Gtk.Spinner",
  6. transient_for = parent,
  7. buttons = {
  8. { Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE },
  9. },
  10. resizable = false,
  11. on_response = Gtk.Widget.destroy,
  12. }
  13. window:get_content_area():add(
  14. Gtk.Box {
  15. orientation = 'VERTICAL',
  16. border_width = 5,
  17. spacing = 5,
  18. Gtk.Box {
  19. orientation = 'HORIZONTAL',
  20. spacing = 5,
  21. Gtk.Spinner {
  22. id = 'sensitive',
  23. active = true,
  24. },
  25. Gtk.Entry {},
  26. },
  27. Gtk.Box {
  28. orientation = 'HORIZONTAL',
  29. spacing = 5,
  30. Gtk.Spinner {
  31. id = 'insensitive',
  32. sensitive = false,
  33. active = true,
  34. },
  35. Gtk.Entry {},
  36. },
  37. Gtk.Button {
  38. id = 'play',
  39. label = Gtk.STOCK_MEDIA_PLAY,
  40. use_stock = true,
  41. },
  42. Gtk.Button {
  43. id = 'stop',
  44. label = Gtk.STOCK_MEDIA_STOP,
  45. use_stock = true,
  46. },
  47. })
  48. function window.child.play:on_clicked()
  49. window.child.sensitive.active = true
  50. window.child.insensitive.active = true
  51. end
  52. function window.child.stop:on_clicked()
  53. window.child.sensitive.active = false
  54. window.child.insensitive.active = false
  55. end
  56. window:show_all()
  57. return window
  58. end,
  59. "Spinner",
  60. table.concat {
  61. [[Gtk.Spinner allows to show that background activity is on-going.]]
  62. }