awful.widget.layoutbox: Port to new widget system

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-10-06 14:30:00 +02:00
parent 3b9150f05a
commit 0cb3569e3e
1 changed files with 5 additions and 12 deletions

View File

@ -10,31 +10,24 @@ local button = require("awful.button")
local layout = require("awful.layout") local layout = require("awful.layout")
local tag = require("awful.tag") local tag = require("awful.tag")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local capi = { oocairo = oocairo, local imagebox = require("wibox.widget.imagebox")
widget = widget } local capi = { oocairo = oocairo }
--- Layoutbox widget. --- Layoutbox widget.
module("awful.widget.layoutbox") module("awful.widget.layoutbox")
local function update(w, screen) local function update(w, screen)
local layout = layout.getname(layout.get(screen)) local layout = layout.getname(layout.get(screen))
if layout and beautiful["layout_" ..layout] then w:set_image(layout and beautiful["layout_" .. layout])
w.image = capi.oocairo.image_surface_create_from_png(beautiful["layout_" ..layout])
else
w.image = nil
end
end end
--- Create a layoutbox widget. It draws a picture with the current layout --- Create a layoutbox widget. It draws a picture with the current layout
-- symbol of the current tag. -- symbol of the current tag.
-- @param screen The screen number that the layout will be represented for. -- @param screen The screen number that the layout will be represented for.
-- @param args Standard arguments for an imagebox widget.
-- @return An imagebox widget configured as a layoutbox. -- @return An imagebox widget configured as a layoutbox.
function new(screen, args) function new(screen)
local screen = screen or 1 local screen = screen or 1
local args = args or {} local w = imagebox()
args.type = "imagebox"
local w = capi.widget(args)
update(w, screen) update(w, screen)
local function update_on_tag_selection(tag) local function update_on_tag_selection(tag)