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")
|
2010-10-06 14:30:00 +02:00
|
|
|
local imagebox = require("wibox.widget.imagebox")
|
2009-05-18 16:32:05 +02:00
|
|
|
|
|
|
|
--- Layoutbox widget.
|
2012-06-14 01:08:27 +02:00
|
|
|
-- awful.widget.layoutbox
|
|
|
|
local layoutbox = { mt = {} }
|
2009-05-18 16:32:05 +02:00
|
|
|
|
|
|
|
local function update(w, screen)
|
|
|
|
local layout = layout.getname(layout.get(screen))
|
2010-10-06 14:30:00 +02:00
|
|
|
w:set_image(layout and beautiful["layout_" .. layout])
|
2009-05-18 16:32:05 +02:00
|
|
|
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.
|
|
|
|
-- @return An imagebox widget configured as a layoutbox.
|
2012-06-14 01:08:27 +02:00
|
|
|
function layoutbox.new(screen)
|
2009-05-18 16:32:05 +02:00
|
|
|
local screen = screen or 1
|
2010-10-06 14:30:00 +02:00
|
|
|
local w = imagebox()
|
2009-05-18 16:32:05 +02:00
|
|
|
update(w, screen)
|
2009-08-11 11:30:04 +02:00
|
|
|
|
2012-10-20 17:33:32 +02:00
|
|
|
local function update_on_tag_selection(t)
|
|
|
|
return update(w, tag.getscreen(t))
|
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
|
|
|
|
|
2012-06-14 01:08:27 +02:00
|
|
|
function layoutbox.mt:__call(...)
|
|
|
|
return layoutbox.new(...)
|
|
|
|
end
|
|
|
|
|
|
|
|
return setmetatable(layoutbox, layoutbox.mt)
|
2009-05-18 16:32:05 +02:00
|
|
|
|
2011-09-11 16:50:01 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|