Reno is the second iteration of the AWMTK-powered AwesomeWM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.6 KiB

2 years ago
2 years ago
  1. -- This file is part of Reno desktop.
  2. --
  3. -- Reno desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  4. --
  5. -- Reno desktop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  6. --
  7. -- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>.
  8. local awful = require("awful")
  9. local wibox = require("wibox")
  10. return function(widget,list,max_elements)
  11. if not tostring(widget):match("wibox.layout") then
  12. error("Cannot attach pager to widget that isn't a layout")
  13. end
  14. local new_pager = {
  15. page = widget,
  16. list = list,
  17. index = 0,
  18. max = max_elements
  19. }
  20. function new_pager:update()
  21. self.page:reset()
  22. for i = 1+(self.max*self.index),self.max+(self.max*self.index) do
  23. if self.list[i] then
  24. self.page:add(self.list[i])
  25. end
  26. end
  27. end
  28. function new_pager:next()
  29. if #list > (self.index+1)*self.max then
  30. self.index = self.index + 1
  31. new_pager:update()
  32. end
  33. end
  34. function new_pager:prev()
  35. if self.index > 0 then
  36. self.index = self.index - 1
  37. new_pager:update()
  38. end
  39. end
  40. new_pager:update()
  41. return new_pager
  42. end