wibox.drawable: add __tostring meta method
This commit is contained in:
parent
fa6b7c390f
commit
430e8664be
|
@ -75,7 +75,7 @@ local function new(c, args)
|
||||||
|
|
||||||
local ret
|
local ret
|
||||||
if not bars[position] then
|
if not bars[position] then
|
||||||
ret = drawable(d, nil)
|
ret = drawable(d, nil, "awful.titlebar")
|
||||||
local function update_colors()
|
local function update_colors()
|
||||||
local args = bars[position].args
|
local args = bars[position].args
|
||||||
ret:set_bg(get_color("bg", c, args))
|
ret:set_bg(get_color("bg", c, args))
|
||||||
|
|
|
@ -229,7 +229,7 @@ local function setup_signals(_drawable)
|
||||||
clone_signal("property::y")
|
clone_signal("property::y")
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawable.new(d, widget_arg)
|
function drawable.new(d, widget_arg, drawable_name)
|
||||||
local ret = object()
|
local ret = object()
|
||||||
ret.drawable = d
|
ret.drawable = d
|
||||||
ret.widget_arg = widget_arg or ret
|
ret.widget_arg = widget_arg or ret
|
||||||
|
@ -287,6 +287,15 @@ function drawable.new(d, widget_arg)
|
||||||
d:connect_signal("mouse::move", function(_, x, y) handle_motion(ret, x, y) end)
|
d:connect_signal("mouse::move", function(_, x, y) handle_motion(ret, x, y) end)
|
||||||
d:connect_signal("mouse::leave", function() handle_leave(ret) end)
|
d:connect_signal("mouse::leave", function() handle_leave(ret) end)
|
||||||
|
|
||||||
|
-- Add __tostring method to metatable.
|
||||||
|
ret.drawable_name = drawable_name or object.modulename(3)
|
||||||
|
local mt = {}
|
||||||
|
local orig_string = tostring(ret)
|
||||||
|
mt.__tostring = function(o)
|
||||||
|
return string.format("%s (%s)", ret.drawable_name, orig_string)
|
||||||
|
end
|
||||||
|
ret = setmetatable(ret, mt)
|
||||||
|
|
||||||
-- Make sure the drawable is drawn at least once
|
-- Make sure the drawable is drawn at least once
|
||||||
ret.draw()
|
ret.draw()
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,8 @@ local function new(args)
|
||||||
local ret = object()
|
local ret = object()
|
||||||
local w = capi.drawin(args)
|
local w = capi.drawin(args)
|
||||||
ret.drawin = w
|
ret.drawin = w
|
||||||
ret._drawable = wibox.drawable(w.drawable, ret)
|
ret._drawable = wibox.drawable(w.drawable, ret,
|
||||||
|
"wibox drawable (" .. object.modulename(3) .. ")")
|
||||||
|
|
||||||
for k, v in pairs(wibox) do
|
for k, v in pairs(wibox) do
|
||||||
if type(v) == "function" then
|
if type(v) == "function" then
|
||||||
|
|
Loading…
Reference in New Issue