awful.titlebar: replace hooks by signals
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
85b3dedb60
commit
974272ee4d
|
@ -19,7 +19,6 @@ local capi =
|
||||||
}
|
}
|
||||||
local abutton = require("awful.button")
|
local abutton = require("awful.button")
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local hooks = require("awful.hooks")
|
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
local widget = require("awful.widget")
|
local widget = require("awful.widget")
|
||||||
local mouse = require("awful.mouse")
|
local mouse = require("awful.mouse")
|
||||||
|
@ -124,25 +123,24 @@ function add(c, args)
|
||||||
|
|
||||||
c.titlebar = tb
|
c.titlebar = tb
|
||||||
|
|
||||||
|
c:add_signal("property::icon", update)
|
||||||
|
c:add_signal("property::name", update)
|
||||||
update(c)
|
update(c)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Update a titlebar. This should be called in some hooks.
|
--- Update a titlebar. This should be called in some hooks.
|
||||||
-- @param c The client to update.
|
-- @param c The client to update.
|
||||||
-- @param prop The property name which has changed.
|
-- @param prop The property name which has changed.
|
||||||
function update(c, prop)
|
function update(c)
|
||||||
if type(c) == "client" and c.titlebar and data[c] then
|
if c.titlebar and data[c] then
|
||||||
local widgets = c.titlebar.widgets
|
local widgets = c.titlebar.widgets
|
||||||
if prop == "name" then
|
|
||||||
if widgets[2].title then
|
if widgets[2].title then
|
||||||
widgets[2].title.text = "<span font_desc='" .. data[c].font ..
|
widgets[2].title.text = "<span font_desc='" .. data[c].font ..
|
||||||
"'> ".. util.escape(c.name) .. " </span>"
|
"'> ".. util.escape(c.name) .. " </span>"
|
||||||
end
|
end
|
||||||
elseif prop == "icon" then
|
|
||||||
if widgets[2].appicon then
|
if widgets[2].appicon then
|
||||||
widgets[2].appicon.image = c.icon
|
widgets[2].appicon.image = c.icon
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if capi.client.focus == c then
|
if capi.client.focus == c then
|
||||||
c.titlebar.fg = data[c].fg_focus
|
c.titlebar.fg = data[c].fg_focus
|
||||||
c.titlebar.bg = data[c].bg_focus
|
c.titlebar.bg = data[c].bg_focus
|
||||||
|
@ -411,6 +409,5 @@ button_groups = { close_buttons,
|
||||||
-- Register standards hooks
|
-- Register standards hooks
|
||||||
capi.client.add_signal("focus", update)
|
capi.client.add_signal("focus", update)
|
||||||
capi.client.add_signal("unfocus", update)
|
capi.client.add_signal("unfocus", update)
|
||||||
hooks.property.register(update)
|
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue