gears.surface: Use GdkPixbuf
This now does directly what previously awesome.load_image() did. Also, this commit removes the only caller of awesome.load_image(), so that function could (in theory) be removed now. Fixes: https://github.com/awesomeWM/awesome/issues/1235 Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
c5badcbe37
commit
ee944f4da8
|
@ -35,7 +35,7 @@ const char commands[] =
|
||||||
" '0.8.0', require('lgi.version')))\n"
|
" '0.8.0', require('lgi.version')))\n"
|
||||||
"end\n"
|
"end\n"
|
||||||
"lgi = require('lgi')\n"
|
"lgi = require('lgi')\n"
|
||||||
"assert(lgi.cairo, lgi.Pango, lgi.PangoCairo, lgi.GLib, lgi.Gio)\n"
|
"assert(lgi.cairo, lgi.Pango, lgi.PangoCairo, lgi.GLib, lgi.Gio, lgi.GdkPixbuf)\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|
|
@ -8,6 +8,7 @@ local setmetatable = setmetatable
|
||||||
local type = type
|
local type = type
|
||||||
local capi = { awesome = awesome }
|
local capi = { awesome = awesome }
|
||||||
local cairo = require("lgi").cairo
|
local cairo = require("lgi").cairo
|
||||||
|
local GdkPixbuf = require("lgi").GdkPixbuf
|
||||||
local color = nil
|
local color = nil
|
||||||
local gdebug = require("gears.debug")
|
local gdebug = require("gears.debug")
|
||||||
local hierarchy = require("wibox.hierarchy")
|
local hierarchy = require("wibox.hierarchy")
|
||||||
|
@ -36,7 +37,6 @@ end
|
||||||
-- @return The loaded surface, or the replacement default
|
-- @return The loaded surface, or the replacement default
|
||||||
-- @return An error message, or nil on success
|
-- @return An error message, or nil on success
|
||||||
function surface.load_uncached_silently(_surface, default)
|
function surface.load_uncached_silently(_surface, default)
|
||||||
local file
|
|
||||||
-- On nil, return some sane default
|
-- On nil, return some sane default
|
||||||
if not _surface then
|
if not _surface then
|
||||||
return get_default(default)
|
return get_default(default)
|
||||||
|
@ -47,12 +47,11 @@ function surface.load_uncached_silently(_surface, default)
|
||||||
end
|
end
|
||||||
-- Strings are assumed to be file names and get loaded
|
-- Strings are assumed to be file names and get loaded
|
||||||
if type(_surface) == "string" then
|
if type(_surface) == "string" then
|
||||||
local err
|
local pixbuf, err = GdkPixbuf.Pixbuf.new_from_file(_surface)
|
||||||
file = _surface
|
if not pixbuf then
|
||||||
_surface, err = capi.awesome.load_image(file)
|
return get_default(default), tostring(err)
|
||||||
if not _surface then
|
|
||||||
return get_default(default), err
|
|
||||||
end
|
end
|
||||||
|
_surface = capi.awesome.pixbuf_to_surface(pixbuf._native)
|
||||||
end
|
end
|
||||||
-- Everything else gets forced into a surface
|
-- Everything else gets forced into a surface
|
||||||
return cairo.Surface(_surface, true)
|
return cairo.Surface(_surface, true)
|
||||||
|
|
Loading…
Reference in New Issue