demo-pickers.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. return function(parent, dir)
  2. local lgi = require 'lgi'
  3. local Gtk = lgi.Gtk
  4. local window = Gtk.Window {
  5. title = "Pickers",
  6. border_width = 10,
  7. Gtk.Grid {
  8. border_width = 10,
  9. row_spacing = 3,
  10. column_spacing = 10,
  11. {
  12. left_attach = 0, top_attach = 0,
  13. Gtk.Label {
  14. label = "Color:",
  15. halign = 'START',
  16. valign = 'CENTER',
  17. hexpand = true,
  18. },
  19. },
  20. {
  21. left_attach = 1, top_attach = 0,
  22. Gtk.ColorButton {},
  23. },
  24. {
  25. left_attach = 0, top_attach = 1,
  26. Gtk.Label {
  27. label = "Font:",
  28. halign = 'START',
  29. valign = 'CENTER',
  30. hexpand = true,
  31. },
  32. },
  33. {
  34. left_attach = 1, top_attach = 1,
  35. Gtk.FontButton {},
  36. },
  37. {
  38. left_attach = 0, top_attach = 2,
  39. Gtk.Label {
  40. label = "File:",
  41. halign = 'START',
  42. valign = 'CENTER',
  43. hexpand = true,
  44. },
  45. },
  46. {
  47. left_attach = 1, top_attach = 2,
  48. Gtk.FileChooserButton {
  49. title = "Pick a File",
  50. action = 'OPEN',
  51. },
  52. },
  53. {
  54. left_attach = 0, top_attach = 3,
  55. Gtk.Label {
  56. label = "Folder:",
  57. halign = 'START',
  58. valign = 'CENTER',
  59. hexpand = true,
  60. },
  61. },
  62. {
  63. left_attach = 1, top_attach = 3,
  64. Gtk.FileChooserButton {
  65. title = "Pick a Folder",
  66. action = 'SELECT_FOLDER',
  67. },
  68. },
  69. {
  70. left_attach = 0, top_attach = 4,
  71. Gtk.Label {
  72. label = "Mail:",
  73. halign = 'START',
  74. valign = 'CENTER',
  75. hexpand = true,
  76. },
  77. },
  78. {
  79. left_attach = 1, top_attach = 4,
  80. Gtk.AppChooserButton {
  81. content_type = 'x-scheme-handler/mailto',
  82. show_dialog_item = true,
  83. },
  84. },
  85. }
  86. }
  87. window:show_all()
  88. return window
  89. end,
  90. "Pickers",
  91. table.concat {
  92. [[These widgets are mainly intended for use in preference ]],
  93. [[dialogs. They allow to select colors, fonts, files, directories ]],
  94. [[and applications.]]
  95. }