2009-05-18 16:32:05 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2009 Julien Danjou
|
|
|
|
-- @release @AWESOME_VERSION@
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
local setmetatable = setmetatable
|
2009-08-11 15:27:31 +02:00
|
|
|
local ipairs = ipairs
|
2009-05-18 16:32:05 +02:00
|
|
|
local button = require("awful.button")
|
|
|
|
local layout = require("awful.layout")
|
2009-08-18 16:44:14 +02:00
|
|
|
local tag = require("awful.tag")
|
2009-05-18 16:32:05 +02:00
|
|
|
local beautiful = require("beautiful")
|
|
|
|
local capi = { image = image,
|
2009-08-11 11:30:04 +02:00
|
|
|
screen = screen,
|
2009-05-18 16:32:05 +02:00
|
|
|
widget = widget }
|
|
|
|
|
|
|
|
--- Layoutbox widget.
|
|
|
|
module("awful.widget.layoutbox")
|
|
|
|
|
|
|
|
local function update(w, screen)
|
|
|
|
local layout = layout.getname(layout.get(screen))
|
|
|
|
if layout and beautiful["layout_" ..layout] then
|
|
|
|
w.image = capi.image(beautiful["layout_" ..layout])
|
|
|
|
else
|
|
|
|
w.image = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Create a layoutbox widget. It draws a picture with the current layout
|
|
|
|
-- symbol of the current tag.
|
|
|
|
-- @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.
|
|
|
|
function new(screen, args)
|
|
|
|
local screen = screen or 1
|
|
|
|
local args = args or {}
|
|
|
|
args.type = "imagebox"
|
|
|
|
local w = capi.widget(args)
|
|
|
|
update(w, screen)
|
2009-08-11 11:30:04 +02:00
|
|
|
|
|
|
|
local function update_on_tag_selection(tag)
|
2009-08-11 15:27:31 +02:00
|
|
|
return update(w, tag.screen)
|
2009-08-11 11:30:04 +02:00
|
|
|
end
|
|
|
|
|
2009-10-09 20:39:55 +02:00
|
|
|
tag.attached_connect_signal(screen, "property::selected", update_on_tag_selection)
|
|
|
|
tag.attached_connect_signal(screen, "property::layout", update_on_tag_selection)
|
2009-08-18 16:44:14 +02:00
|
|
|
|
2009-05-18 16:32:05 +02:00
|
|
|
return w
|
|
|
|
end
|
|
|
|
|
|
|
|
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|