Skip to content

Commit

Permalink
awful.widget.graph: expose properties via getters
Browse files Browse the repository at this point in the history
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 #284.
  • Loading branch information
blueyed committed Jul 10, 2015
1 parent 611438a commit 3be423f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/awful/widget/graph.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit 3be423f

Please sign in to comment.