Update lib/wibox/widget/imagebox.lua
Co-authored-by: Aire-One <aireone@aireone.xyz>
This commit is contained in:
parent
7806763667
commit
7b8426bd24
|
@ -51,8 +51,9 @@ local imagebox = { mt = {} }
|
||||||
local rsvg_handle_cache = setmetatable({}, { __mode = 'k' })
|
local rsvg_handle_cache = setmetatable({}, { __mode = 'k' })
|
||||||
|
|
||||||
---Load rsvg handle form image file
|
---Load rsvg handle form image file
|
||||||
---@tparam string file Path to svg file.
|
-- @tparam string file Path to svg file.
|
||||||
---@return Rsvg handle
|
-- @return Rsvg handle
|
||||||
|
-- @treturn table A table where cached data can be stored.
|
||||||
local function load_rsvg_handle(file)
|
local function load_rsvg_handle(file)
|
||||||
if not Rsvg then return end
|
if not Rsvg then return end
|
||||||
|
|
||||||
|
@ -79,8 +80,8 @@ end
|
||||||
|
|
||||||
---Apply cairo surface for given imagebox widget
|
---Apply cairo surface for given imagebox widget
|
||||||
local function set_surface(ib, surf)
|
local function set_surface(ib, surf)
|
||||||
local is_surd_valid = surf.width > 0 and surf.height > 0
|
local is_surf_valid = surf.width > 0 and surf.height > 0
|
||||||
if not is_surd_valid then return end
|
if not is_surf_valid then return false end
|
||||||
|
|
||||||
ib._private.default = { width = surf.width, height = surf.height }
|
ib._private.default = { width = surf.width, height = surf.height }
|
||||||
ib._private.handle = nil
|
ib._private.handle = nil
|
||||||
|
@ -92,7 +93,7 @@ end
|
||||||
local function set_handle(ib, handle, cache)
|
local function set_handle(ib, handle, cache)
|
||||||
local dim = handle:get_dimensions()
|
local dim = handle:get_dimensions()
|
||||||
local is_handle_valid = dim.width > 0 and dim.height > 0
|
local is_handle_valid = dim.width > 0 and dim.height > 0
|
||||||
if not is_handle_valid then return end
|
if not is_handle_valid then return false end
|
||||||
|
|
||||||
ib._private.default = { width = dim.width, height = dim.height }
|
ib._private.default = { width = dim.width, height = dim.height }
|
||||||
ib._private.handle = handle
|
ib._private.handle = handle
|
||||||
|
@ -303,7 +304,7 @@ end
|
||||||
-- * `nil`: Unset the image.
|
-- * `nil`: Unset the image.
|
||||||
--
|
--
|
||||||
-- @property image
|
-- @property image
|
||||||
-- @tparam image image The image to render. test
|
-- @tparam image image The image to render.
|
||||||
-- @propemits false false
|
-- @propemits false false
|
||||||
|
|
||||||
--- Set the `imagebox` image.
|
--- Set the `imagebox` image.
|
||||||
|
@ -321,7 +322,7 @@ function imagebox:set_image(image)
|
||||||
local setup_succeed
|
local setup_succeed
|
||||||
|
|
||||||
-- Keep the original to prevent the cache from being GCed.
|
-- Keep the original to prevent the cache from being GCed.
|
||||||
self._private.original_iamge = image
|
self._private.original_image = image
|
||||||
|
|
||||||
if type(image) == "userdata" and not (Rsvg and Rsvg.Handle:is_type_of(image)) then
|
if type(image) == "userdata" and not (Rsvg and Rsvg.Handle:is_type_of(image)) then
|
||||||
-- This function is not documented to handle userdata objects, but
|
-- This function is not documented to handle userdata objects, but
|
||||||
|
|
Loading…
Reference in New Issue