awful.widget.graph: expose properties via getters
This allows to see if a widget is stacked for example. It uses getters instead of exposing the properties directly, which should be made readonly then probably (which has drawbacks according to [1]). 1: http://lua-users.org/wiki/ReadOnlyTables Closes https://github.com/awesomeWM/awesome/pull/284.
This commit is contained in:
parent
611438a892
commit
3be423fcb3
|
@ -229,6 +229,11 @@ for _, prop in ipairs(properties) do
|
|||
return _graph
|
||||
end
|
||||
end
|
||||
if not graph["get_" .. prop] then
|
||||
graph["get_" .. prop] = function(_graph)
|
||||
return data[_graph][prop]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Create a graph widget.
|
||||
|
@ -254,6 +259,7 @@ function graph.new(args)
|
|||
|
||||
for _, prop in ipairs(properties) do
|
||||
_graph["set_" .. prop] = graph["set_" .. prop]
|
||||
_graph["get_" .. prop] = graph["get_" .. prop]
|
||||
end
|
||||
|
||||
return _graph
|
||||
|
|
Loading…
Reference in New Issue