mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
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
2 changed files with 6 additions and 7 deletions
|
@ -35,7 +35,7 @@ const char commands[] =
|
|||
" '0.8.0', require('lgi.version')))\n"
|
||||
"end\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()
|
||||
|
|
|
@ -8,6 +8,7 @@ local setmetatable = setmetatable
|
|||
local type = type
|
||||
local capi = { awesome = awesome }
|
||||
local cairo = require("lgi").cairo
|
||||
local GdkPixbuf = require("lgi").GdkPixbuf
|
||||
local color = nil
|
||||
local gdebug = require("gears.debug")
|
||||
local hierarchy = require("wibox.hierarchy")
|
||||
|
@ -36,7 +37,6 @@ end
|
|||
-- @return The loaded surface, or the replacement default
|
||||
-- @return An error message, or nil on success
|
||||
function surface.load_uncached_silently(_surface, default)
|
||||
local file
|
||||
-- On nil, return some sane default
|
||||
if not _surface then
|
||||
return get_default(default)
|
||||
|
@ -47,12 +47,11 @@ function surface.load_uncached_silently(_surface, default)
|
|||
end
|
||||
-- Strings are assumed to be file names and get loaded
|
||||
if type(_surface) == "string" then
|
||||
local err
|
||||
file = _surface
|
||||
_surface, err = capi.awesome.load_image(file)
|
||||
if not _surface then
|
||||
return get_default(default), err
|
||||
local pixbuf, err = GdkPixbuf.Pixbuf.new_from_file(_surface)
|
||||
if not pixbuf then
|
||||
return get_default(default), tostring(err)
|
||||
end
|
||||
_surface = capi.awesome.pixbuf_to_surface(pixbuf._native)
|
||||
end
|
||||
-- Everything else gets forced into a surface
|
||||
return cairo.Surface(_surface, true)
|
||||
|
|
Loading…
Reference in a new issue