demo-builder.lua 614 B

12345678910111213141516171819202122232425262728293031323334
  1. return function(parent, dir)
  2. local lgi = require 'lgi'
  3. local Gtk = lgi.Gtk
  4. local assert = lgi.assert
  5. local builder = Gtk.Builder()
  6. assert(builder:add_from_file(dir:get_child('demo.ui'):get_path()))
  7. local ui = builder.objects
  8. -- Get top-level window from the builder.
  9. local window = ui.window1
  10. -- Connect 'Quit' and 'About' actions.
  11. function ui.Quit:on_activate()
  12. window:destroy()
  13. end
  14. function ui.About:on_activate()
  15. ui.aboutdialog1:run()
  16. ui.aboutdialog1:hide()
  17. end
  18. window:show_all()
  19. return window
  20. end,
  21. "Builder",
  22. table.concat {
  23. [[Demonstrates an interface loaded from a XML description.]],
  24. }