summaryrefslogtreecommitdiff
path: root/pager.lua
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-11-07 12:36:24 +0100
committerAnton Khirnov <anton@khirnov.net>2020-11-07 12:36:24 +0100
commit3898ab82c2b9714259426cd62f73289468bfa0aa (patch)
treebcf41fcddd170848780fa06b6833fcda86256956 /pager.lua
parente9a85f8048e2916f4907d80181830562f1615567 (diff)
pager: display more information in the title
Diffstat (limited to 'pager.lua')
-rw-r--r--pager.lua44
1 files changed, 28 insertions, 16 deletions
diff --git a/pager.lua b/pager.lua
index bcd2052..191ad74 100644
--- a/pager.lua
+++ b/pager.lua
@@ -86,24 +86,33 @@ function PagerDesk:new(desktop, screen, width, height)
local ret = setmetatable({}, self)
self.__index = self
- local nb_pages = #desktop.pages
- local page_height = height / nb_pages
+ local title_desk = wibox.widget.textbox()
+
+ local function set_title(desktop)
+ title_desk:set_text(string.format("[%d] %s", desktop.idx, desktop.name))
+ end
+
+ desktop:connect_signal("desktop:name", set_title)
+ set_title(desktop)
+
+ local title_page = wibox.widget.textbox()
+
+ local title_bar = wibox.layout.ratio.horizontal()
+ title_bar:set_spacing(10)
+ title_bar:set_spacing_widget(wibox.widget.separator())
+ title_bar:add(title_desk, title_page)
+ title_bar:set_ratio(1, 0.75)
- local title = wibox.widget.textbox()
- title:set_align("center")
local title_bg = beautiful.bg_focus or "#ffffff"
local title_fg = beautiful.fg_focus or "#000000"
- local title_container = wibox.container.background(title, title_bg)
+ local title_container = wibox.container.background(title_bar, title_bg)
title_container:set_fg(title_fg)
- desktop:connect_signal("desktop:name",
- function(desktop, name)
- title:set_text(name)
- end)
- title:set_text(desktop.name)
-
ret.widget = wibox.layout.fixed.vertical(title_container)
+ local nb_pages = #desktop.pages
+ local page_height = height / nb_pages
+
ret.pages = {}
for i = 1, nb_pages do
local page = desktop.pages[i]
@@ -112,22 +121,25 @@ function PagerDesk:new(desktop, screen, width, height)
end
desktop:connect_signal("page:view",
- function(desktop, s, page_idx) ret:_set_active(s, page_idx) end)
+ function(desktop, s, page_idx)
+ ret:_set_active(s, page_idx)
+ title_page:set_text(string.format("%d", page_idx))
+ end)
ret.desktop = desktop
ret.screen = screen
- ret.active_page = nil
+ ret.active_page_idx = nil
return ret
end
function PagerDesk:_set_active(screen, page_idx)
if self.screen == screen then
- if self.active_page then
- self.active_page:set_active(false)
+ if self.active_page_idx then
+ self.pages[self.active_page_idx]:set_active(false)
end
self.pages[page_idx]:set_active(true)
- self.active_page = self.pages[page_idx]
+ self.active_page_idx = page_idx
end
end