From 3be423fcb3c0b99d3886c57c237bde82b990cd98 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 4 Jul 2015 20:10:39 +0200 Subject: [PATCH] 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. --- lib/awful/widget/graph.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/awful/widget/graph.lua b/lib/awful/widget/graph.lua index 286219d7..be958724 100644 --- a/lib/awful/widget/graph.lua +++ b/lib/awful/widget/graph.lua @@ -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