desktop.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/lua
  2. lgi = require 'lgi'
  3. gtk = lgi.Gtk
  4. glib = lgi.GLib
  5. gdk = lgi.Gdk
  6. gobject = lgi.GObject
  7. pixbuf = lgi.GdkPixbuf
  8. gtk.init()
  9. local window = gtk.Window {
  10. title = 'window', default_width = 400, default_height = 300,
  11. on_destroy = gtk.main_quit
  12. }
  13. if tonumber(gtk._version) >= 3 then
  14. window.has_resize_grip = true
  15. end
  16. -- -- create a gtk icon view and add icons to it
  17. -- local icon_view = gtk.IconView
  18. -- -- icon_view:set_column_spacing (10)
  19. -- -- icon_view:set_row_spacing (10)
  20. icon_view = gtk.IconView
  21. {
  22. column_spacing = 10,
  23. row_spacing = 10
  24. }
  25. -- create store
  26. store = gtk.ListStore (gdk.Pixbuf, gobject.TYPE_STRING)
  27. icon_view:set_model (store) --icon_view:set_model ( model = node )
  28. path = "/home/joshua/.config/awesome/icons/Faenza/apps/96/"
  29. pix = pixbuf.Pixbuf.new_from_file ( path .. "libreoffice-writer.png" )
  30. store:append(pix, "writer")
  31. -- create a grid and add stuff to it.
  32. local grid = gtk.Grid ()
  33. grid:attach (icon_view, 0, 0, 1, 1)
  34. window:add (grid)
  35. -- show the window and start the loop
  36. window:show_all()
  37. gtk.main()
  38. -- function MainWin.new()
  39. -- local self = {}
  40. -- setmetatable (self, MainWin)
  41. -- self.w = gtk.window_new (gtk.Window_TOPLEVEL)
  42. -- self.w:connect ('destroy', gtk.main_quit)
  43. -- self.w:set_default_size (200, 250)
  44. -- self.w:set_title ("Icon View Demo")
  45. -- local sw = gtk.scrolled_window_new (nil, nil)
  46. -- sw:set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
  47. -- self.w:add(sw)
  48. -- self.icon_view = gtk.icon_view_new ()
  49. -- sw.add(self.icon_view)
  50. -- -- create store
  51. -- self.store = gtk.list_store_new (3, glib.TYPE_INT, glib.TYPE_STRING,
  52. -- gdk.pixbuf_get_type())
  53. -- self.icon_view:set_model (self.store)
  54. -- self.icon_view:set_text_column (1)
  55. -- self.icon_view:set_pixbuf_column (2)
  56. -- -- insert some items
  57. -- local iter = gtk.new "GtkTreeIter"
  58. -- local pix
  59. -- local names = { 'quit', 'open', 'redo', 'refresh', 'stop', 'save', 'save-as', 'select-color',
  60. -- 'yes', 'no', 'zoom-fit' }
  61. -- for i, name in ipairs(names) do
  62. -- self.store:append(iter)
  63. -- pix = self.icon_view:render_icon('gtk-' .. name, gtk.ICON_SIZE_DIALOG, "")
  64. -- self.store:set(iter, 0, i, 1, name, 2, pix, -1)
  65. -- end
  66. -- self.w:show_all()
  67. -- return self
  68. -- end