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.
37 lines
1001 B
37 lines
1001 B
local awful = require("awful")
|
|
local awmtk = require("awmtk")
|
|
local wibox = require("wibox")
|
|
|
|
return function(widget,list,max_elements)
|
|
if not tostring(widget):match("wibox.layout") then
|
|
error("Cannot attach pager to widget that isn't a layout")
|
|
end
|
|
local new_pager = {
|
|
page = widget,
|
|
list = list,
|
|
index = 0,
|
|
max = max_elements
|
|
}
|
|
function new_pager:update()
|
|
self.page:reset()
|
|
for i = 1+(self.max*self.index),self.max+(self.max*self.index) do
|
|
if self.list[i] then
|
|
self.page:add(self.list[i])
|
|
end
|
|
end
|
|
end
|
|
function new_pager:next()
|
|
if #list >= (self.index+1)*self.max then
|
|
self.index = self.index + 1
|
|
new_pager:update()
|
|
end
|
|
end
|
|
function new_pager:prev()
|
|
if self.index > 0 then
|
|
self.index = self.index - 1
|
|
new_pager:update()
|
|
end
|
|
end
|
|
new_pager:update()
|
|
return new_pager
|
|
end
|