textbox: Prefix internal variables with "_"
This makes sure that textbox.text = "foo" doesn't work at all. It was never supposed to work anyway. Sorry that I break stuff again. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
650b3d6df5
commit
688b4fb628
|
@ -35,28 +35,28 @@ end
|
||||||
-- Setup a pango layout for the given textbox and cairo context
|
-- Setup a pango layout for the given textbox and cairo context
|
||||||
local function setup_layout(box, cr, width, height)
|
local function setup_layout(box, cr, width, height)
|
||||||
local layout = layout_create(cr)
|
local layout = layout_create(cr)
|
||||||
layout:set_ellipsize(box.ellipsize)
|
layout:set_ellipsize(box._ellipsize)
|
||||||
layout:set_wrap(box.wrap)
|
layout:set_wrap(box._wrap)
|
||||||
layout:set_width(oopango.units_from_number(width))
|
layout:set_width(oopango.units_from_number(width))
|
||||||
layout:set_height(oopango.units_from_number(height))
|
layout:set_height(oopango.units_from_number(height))
|
||||||
|
|
||||||
if box.markup then
|
if box._markup then
|
||||||
layout:set_markup(box.text)
|
layout:set_markup(box._text)
|
||||||
else
|
else
|
||||||
layout:set_text(box.text)
|
layout:set_text(box._text)
|
||||||
end
|
end
|
||||||
|
|
||||||
if box.font then
|
if box._font then
|
||||||
layout:set_font_description(box.font)
|
layout:set_font_description(box._font)
|
||||||
else
|
else
|
||||||
layout:set_font_description(beautiful.get_font())
|
layout:set_font_description(beautiful.get_font())
|
||||||
end
|
end
|
||||||
|
|
||||||
local ink, logical = layout:get_pixel_extents()
|
local ink, logical = layout:get_pixel_extents()
|
||||||
local offset = 0
|
local offset = 0
|
||||||
if box.valign == "center" then
|
if box._valign == "center" then
|
||||||
offset = (height - logical.height) / 2
|
offset = (height - logical.height) / 2
|
||||||
elseif box.valign == "bottom" then
|
elseif box._valign == "bottom" then
|
||||||
offset = height - logical.height
|
offset = height - logical.height
|
||||||
end
|
end
|
||||||
if offset > 0 then
|
if offset > 0 then
|
||||||
|
@ -74,7 +74,7 @@ local function get_size(box, layout, width, height)
|
||||||
height = 0
|
height = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if box.text then
|
if box._text then
|
||||||
local layout = layout
|
local layout = layout
|
||||||
|
|
||||||
if not layout then
|
if not layout then
|
||||||
|
@ -95,7 +95,7 @@ end
|
||||||
|
|
||||||
--- Draw the given textbox on the given cairo context in the given geometry
|
--- Draw the given textbox on the given cairo context in the given geometry
|
||||||
function draw(box, wibox, cr, width, height)
|
function draw(box, wibox, cr, width, height)
|
||||||
if not box.text then return end
|
if not box._text then return end
|
||||||
|
|
||||||
local layout = setup_layout(box, cr, width, height)
|
local layout = setup_layout(box, cr, width, height)
|
||||||
|
|
||||||
|
@ -118,16 +118,16 @@ end
|
||||||
--- Set a textbox' text.
|
--- Set a textbox' text.
|
||||||
-- @param text The text to set. This can contain pango markup (e.g. <b>bold</b>)
|
-- @param text The text to set. This can contain pango markup (e.g. <b>bold</b>)
|
||||||
function set_markup(box, text)
|
function set_markup(box, text)
|
||||||
box.text = text
|
box._text = text
|
||||||
box.markup = true
|
box._markup = true
|
||||||
box:emit_signal("widget::updated")
|
box:emit_signal("widget::updated")
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a textbox' text.
|
--- Set a textbox' text.
|
||||||
-- @param text The text to display. Pango markup is ignored and shown as-is.
|
-- @param text The text to display. Pango markup is ignored and shown as-is.
|
||||||
function set_text(box, text)
|
function set_text(box, text)
|
||||||
box.text = text
|
box._text = text
|
||||||
box.markup = false
|
box._markup = false
|
||||||
box:emit_signal("widget::updated")
|
box:emit_signal("widget::updated")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ end
|
||||||
function set_ellipsize(box, mode)
|
function set_ellipsize(box, mode)
|
||||||
local allowed = { none = true, start = true, middle = true, ["end"] = true }
|
local allowed = { none = true, start = true, middle = true, ["end"] = true }
|
||||||
if allowed[mode] then
|
if allowed[mode] then
|
||||||
box.ellipsize = mode
|
box._ellipsize = mode
|
||||||
box:emit_signal("widget::updated")
|
box:emit_signal("widget::updated")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -146,7 +146,7 @@ end
|
||||||
function set_wrap(box, mode)
|
function set_wrap(box, mode)
|
||||||
local allowed = { word = true, char = true, word_char = true }
|
local allowed = { word = true, char = true, word_char = true }
|
||||||
if allowed[mode] then
|
if allowed[mode] then
|
||||||
box.wrap = mode
|
box._wrap = mode
|
||||||
box:emit_signal("widget::updated")
|
box:emit_signal("widget::updated")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -156,7 +156,7 @@ end
|
||||||
function set_valign(box, mode)
|
function set_valign(box, mode)
|
||||||
local allowed = { top = true, center = true, bottom = true }
|
local allowed = { top = true, center = true, bottom = true }
|
||||||
if allowed[mode] then
|
if allowed[mode] then
|
||||||
box.valign = mode
|
box._valign = mode
|
||||||
box:emit_signal("widget::updated")
|
box:emit_signal("widget::updated")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -171,9 +171,9 @@ local function new()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ret.ellipsize = "end"
|
ret._ellipsize = "end"
|
||||||
ret.wrap = "word_char"
|
ret._wrap = "word_char"
|
||||||
ret.valign = "center"
|
ret._valign = "center"
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue