Skip to content

Commit 2d7f371

Browse files
author
Robert Šiška
committed
show tooltip if the tasklist title was truncated
1 parent 725d07d commit 2d7f371

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

widget/task-list.lua

+16-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ local function list_update(w, buttons, label, data, objects)
4141
w:reset()
4242
for i, o in ipairs(objects) do
4343
local cache = data[o]
44-
local ib, cb, tb, cbm, bgb, tbm, ibm, l, ll, bg_clickable
44+
local ib, cb, tb, cbm, bgb, tbm, ibm, tt, l, ll, bg_clickable
4545
if cache then
4646
ib = cache.ib
4747
tb = cache.tb
4848
bgb = cache.bgb
4949
tbm = cache.tbm
5050
ibm = cache.ibm
51+
tt = cache.tt
5152
else
5253
ib = wibox.widget.imagebox()
5354
tb = wibox.widget.textbox()
@@ -95,12 +96,21 @@ local function list_update(w, buttons, label, data, objects)
9596

9697
l:buttons(create_buttons(buttons, o))
9798

99+
-- Tooltip to display whole title, if it was truncated
100+
tt = awful.tooltip({
101+
objects = {tb},
102+
mode = 'outside',
103+
align = 'bottom',
104+
delay_show = 1,
105+
})
106+
98107
data[o] = {
99108
ib = ib,
100109
tb = tb,
101110
bgb = bgb,
102111
tbm = tbm,
103-
ibm = ibm
112+
ibm = ibm,
113+
tt = tt
104114
}
105115
end
106116

@@ -115,6 +125,10 @@ local function list_update(w, buttons, label, data, objects)
115125
local textOnly = text:match('>(.-)<')
116126
if (textOnly:len() > 24) then
117127
text = text:gsub('>(.-)<', '>' .. textOnly:sub(1, 21) .. '...<')
128+
tt:set_text(textOnly)
129+
tt:add_to_object(tb)
130+
else
131+
tt:remove_from_object(tb)
118132
end
119133
if not tb:set_markup_silently(text) then
120134
tb:set_markup('<i>&lt;Invalid text&gt;</i>')

0 commit comments

Comments
 (0)