awful.widget.layoutbox: add tooltip with the layout's name
Closes https://github.com/awesomeWM/awesome/pull/322.
This commit is contained in:
parent
355e4696ba
commit
b08d3caba8
|
@ -11,14 +11,16 @@ local setmetatable = setmetatable
|
|||
local ipairs = ipairs
|
||||
local button = require("awful.button")
|
||||
local layout = require("awful.layout")
|
||||
local tooltip = require("awful.tooltip")
|
||||
local tag = require("awful.tag")
|
||||
local beautiful = require("beautiful")
|
||||
local imagebox = require("wibox.widget.imagebox")
|
||||
|
||||
local layoutbox = { mt = {} }
|
||||
|
||||
local function update(w, screen)
|
||||
local function update(w, screen, tooltip)
|
||||
local layout = layout.getname(layout.get(screen))
|
||||
tooltip:set_text(layout or "[no name]")
|
||||
w:set_image(layout and beautiful["layout_" .. layout])
|
||||
end
|
||||
|
||||
|
@ -29,10 +31,12 @@ end
|
|||
function layoutbox.new(screen)
|
||||
local screen = screen or 1
|
||||
local w = imagebox()
|
||||
update(w, screen)
|
||||
local tooltip = tooltip({ objects = {w}, delay_show = 1 })
|
||||
|
||||
update(w, screen, tooltip)
|
||||
|
||||
local function update_on_tag_selection(t)
|
||||
return update(w, tag.getscreen(t))
|
||||
return update(w, tag.getscreen(t), tooltip)
|
||||
end
|
||||
|
||||
tag.attached_connect_signal(screen, "property::selected", update_on_tag_selection)
|
||||
|
|
Loading…
Reference in New Issue