diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-11-07 12:36:24 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-11-07 12:36:24 +0100 |
commit | 3898ab82c2b9714259426cd62f73289468bfa0aa (patch) | |
tree | bcf41fcddd170848780fa06b6833fcda86256956 /pager.lua | |
parent | e9a85f8048e2916f4907d80181830562f1615567 (diff) |
pager: display more information in the title
Diffstat (limited to 'pager.lua')
-rw-r--r-- | pager.lua | 44 |
1 files changed, 28 insertions, 16 deletions
@@ -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 |