demo-entry-buffer.lua 824 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. return function(parent, dir)
  2. local lgi = require 'lgi'
  3. local Gtk = lgi.Gtk
  4. local window = Gtk.Dialog {
  5. title = "Entry Buffer",
  6. resizable = false,
  7. on_response = Gtk.Widget.destroy,
  8. buttons = {
  9. { Gtk.STOCK_CLOSE, Gtk.ResponseType.NONE },
  10. },
  11. }
  12. local buffer = Gtk.EntryBuffer()
  13. local content = Gtk.Box {
  14. orientation = 'VERTICAL',
  15. spacing = 5,
  16. border_width = 5,
  17. Gtk.Label {
  18. label = "Entries share a buffer. "
  19. .. "Typing in one is reflected in the other.",
  20. use_markup = true,
  21. },
  22. Gtk.Entry {
  23. buffer = buffer,
  24. },
  25. Gtk.Entry {
  26. buffer = buffer,
  27. visibility = false,
  28. },
  29. }
  30. window:get_content_area():add(content)
  31. window:show_all()
  32. return window
  33. end,
  34. "Entry/Entry Buffer",
  35. table.concat {
  36. "Gtk.EntryBuffer provides the text content in a Gtk.Entry.",
  37. }