extended_calendar.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. -- @ author Cédric Le Moigne
  2. local helpers = require("blingbling.helpers")
  3. local superproperties = require("blingbling.superproperties")
  4. local calendar = require("blingbling.calendar")
  5. local wibox = require("wibox")
  6. local grid = require("blingbling.grid")
  7. local text_box = require("blingbling.text_box")
  8. local ext_calendar = { mt = {} }
  9. local data = setmetatable({}, { __mode = "k" })
  10. local properties = { "info_cell_style", "link_to_external_calendar",
  11. "days_mouse_enter", "days_mouse_leave"}
  12. function ext_calendar.new(args)
  13. local args = args or {}
  14. local _calendar = wibox(args)
  15. data[_calendar] = {}
  16. args.focus_days = true
  17. local events_content = text_box({text = ""})
  18. args.focus_days_enter_callback = {cb = args.days_mouse_enter or function() end, data = events_content}
  19. args.focus_days_leave_callback = {cb = args.days_mouse_leave or function() end, data = events_content}
  20. data[_calendar].calendar = calendar(args)
  21. data[_calendar].grid = grid()
  22. local title = text_box({text = os.date('%a %b %d, %H:%M')})
  23. data[_calendar].grid:add_child(title, 1, 1, 2, 1)
  24. data[_calendar].grid:add_child(data[_calendar].calendar, 1, 2, 1, 8)
  25. local events_label = text_box({text = "Events :"})
  26. data[_calendar].grid:add_child(events_label, 2, 2, 1, 1)
  27. data[_calendar].grid:add_child(events_content, 2, 3, 1, 7)
  28. _calendar.visible = true
  29. _calendar:set_widget(data[_calendar].grid)
  30. _calendar.visible = true
  31. return _calendar
  32. end
  33. function ext_calendar.mt:__call(...)
  34. return ext_calendar.new(...)
  35. end
  36. return setmetatable(ext_calendar, ext_calendar.mt)