1 ---------------------------------------------------------------------------
2 -- @author Uli Schlachter
3 -- @copyright 2010 Uli Schlachter
4 -- @release @AWESOME_VERSION@
5 ---------------------------------------------------------------------------
7 local wbase
= require("wibox.widget.base")
8 local lbase
= require("wibox.layout.base")
9 local beautiful
= require("beautiful")
10 local capi
= { awesome
= awesome
}
11 local setmetatable
= setmetatable
14 -- wibox.widget.systray
15 local systray
= { mt
= {} }
17 local created_systray
= false
18 local horizontal
= true
21 function systray
.draw(box
, wibox
, cr
, width
, height
)
22 local x
, y
, width
, height
= lbase
.rect_to_device_geometry(cr
, 0, 0, width
, height
)
23 local num_entries
= capi
.awesome
.systray()
24 local bg
= beautiful
.bg_systray
or beautiful
.bg_normal
26 local in_dir
, ortho
, base
28 in_dir
, ortho
= width
, height
30 ortho
, in_dir
= width
, height
32 if ortho
* num_entries
<= in_dir
then
35 base
= in_dir
/ num_entries
37 capi
.awesome
.systray(wibox
.drawin
, x
, y
, base
, horizontal
, bg
)
40 function systray
.fit(box
, width
, height
)
41 local num_entries
= capi
.awesome
.systray()
42 local base
= base_size
44 if width
< height
then
51 return base
* num_entries
, base
53 return base
, base
* num_entries
57 local ret
= wbase
.make_widget()
59 if created_systray
then
60 error("More than one systray created!")
62 created_systray
= true
65 ret
.draw
= systray
.draw
66 ret
.set_base_size
= function(_
, size
) base_size
= size
end
67 ret
.set_horizontal
= function(_
, horiz
) horizontal
= horiz
end
69 capi
.awesome
.connect_signal("systray::update", function()
70 ret
:emit_signal("widget::updated")
76 function systray
.mt
:__call(...)
80 return setmetatable(systray
, systray
.mt
)
82 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80