Fix errors from missing themes

This patch gets rid of lots of errors that happen when beautiful.init() is not
called in the config. Most of them were missing default values.

Thanks to panthar for reporting this.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2012-11-27 22:55:42 +01:00
parent b7eb233aee
commit c50d62749b
4 changed files with 14 additions and 3 deletions

View File

@ -8,6 +8,7 @@ local setmetatable = setmetatable
local type = type local type = type
local button = require("awful.button") local button = require("awful.button")
local imagebox = require("wibox.widget.imagebox") local imagebox = require("wibox.widget.imagebox")
local widget = require("wibox.widget.base")
local surface = require("gears.surface") local surface = require("gears.surface")
local cairo = require("lgi").cairo local cairo = require("lgi").cairo
local capi = { mouse = mouse } local capi = { mouse = mouse }
@ -20,7 +21,9 @@ local button = { mt = {} }
-- @param args Widget arguments. "image" is the image to display. -- @param args Widget arguments. "image" is the image to display.
-- @return A textbox widget configured as a button. -- @return A textbox widget configured as a button.
function button.new(args) function button.new(args)
if not args or not args.image then return end if not args or not args.image then
return widget.empty_widget()
end
local img_release = surface.load(args.image) local img_release = surface.load(args.image)
local img_press = cairo.ImageSurface(cairo.Format.ARGB32, img_release.width, img_release.height) local img_press = cairo.ImageSurface(cairo.Format.ARGB32, img_release.width, img_release.height)
local cr = cairo.Context(img_press) local cr = cairo.Context(img_press)

View File

@ -28,7 +28,7 @@ local capi =
local beautiful = { mt = {} } local beautiful = { mt = {} }
-- Local data -- Local data
local theme local theme = {}
local descs = setmetatable({}, { __mode = 'k' }) local descs = setmetatable({}, { __mode = 'k' })
local fonts = setmetatable({}, { __mode = 'v' }) local fonts = setmetatable({}, { __mode = 'v' })
local active_font local active_font

View File

@ -97,6 +97,14 @@ function base.make_widget(proxy)
return ret return ret
end end
--- Generate an empty widget which takes no space and displays nothing
function base.empty_widget()
local widget = base.make_widget()
widget.draw = function() end
widget.fit = function() return 0, 0 end
return widget
end
--- Do some sanity checking on widget. This function raises a lua error if --- Do some sanity checking on widget. This function raises a lua error if
-- widget is not a valid widget. -- widget is not a valid widget.
function base.check_widget(widget) function base.check_widget(widget)

View File

@ -21,7 +21,7 @@ local base_size = nil
function systray:draw(wibox, cr, width, height) function systray:draw(wibox, cr, width, height)
local x, y, width, height = lbase.rect_to_device_geometry(cr, 0, 0, width, height) local x, y, width, height = lbase.rect_to_device_geometry(cr, 0, 0, width, height)
local num_entries = capi.awesome.systray() local num_entries = capi.awesome.systray()
local bg = beautiful.bg_systray or beautiful.bg_normal local bg = beautiful.bg_systray or beautiful.bg_normal or "#000000"
local in_dir, ortho, base local in_dir, ortho, base
if horizontal then if horizontal then