gears.object.properties: Implement read-only properties

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-06-04 15:56:52 +02:00
parent cdf16d4660
commit 2d511e2ab5
3 changed files with 9 additions and 14 deletions

View File

@ -311,8 +311,6 @@ function screen.object.get_clients(s)
return vcls return vcls
end end
function screen.object.set_clients() end
--- Get the list of the clients assigned to the screen but not currently --- Get the list of the clients assigned to the screen but not currently
-- visible. -- visible.
-- --
@ -335,8 +333,6 @@ function screen.object.get_hidden_clients(s)
return vcls return vcls
end end
function screen.object.set_hidden_clients() end
--- Get all clients assigned to the screen. --- Get all clients assigned to the screen.
-- --
-- @property all_clients -- @property all_clients
@ -349,8 +345,6 @@ function screen.object.get_all_clients(s)
return capi.client.get(s, true) return capi.client.get(s, true)
end end
function screen.object.set_all_clients() end
--- Get the list of the screen tiled clients. --- Get the list of the screen tiled clients.
-- --
-- Same as s.clients, but excluding: -- Same as s.clients, but excluding:
@ -377,8 +371,6 @@ function screen.object.get_tiled_clients(s)
return tclients return tclients
end end
function screen.object.set_tiled_clients() end
--- Call a function for each existing and created-in-the-future screen. --- Call a function for each existing and created-in-the-future screen.
-- @function awful.screen.connect_for_each_screen -- @function awful.screen.connect_for_each_screen
-- @tparam function func The function to call. -- @tparam function func The function to call.
@ -425,8 +417,6 @@ function screen.object.get_tags(s, unordered)
return tags return tags
end end
function screen.object.set_tags() end
--- A list of all selected tags on the screen. --- A list of all selected tags on the screen.
-- @property selected_tags -- @property selected_tags
-- @param table -- @param table
@ -446,8 +436,6 @@ function screen.object.get_selected_tags(s)
return vtags return vtags
end end
function screen.object.set_selected_tags() end
--- The first selected tag. --- The first selected tag.
-- @property selected_tag -- @property selected_tag
-- @param table -- @param table
@ -459,8 +447,6 @@ function screen.object.get_selected_tag(s)
return screen.object.get_selected_tags(s)[1] return screen.object.get_selected_tags(s)[1]
end end
function screen.object.set_selected_tag() end
--- When the tag history changed. --- When the tag history changed.
-- @signal tag::history::update -- @signal tag::history::update

View File

@ -83,6 +83,11 @@ function object.capi_index_fallback(class, args)
return args.setter_fallback(cobj, prop, value) return args.setter_fallback(cobj, prop, value)
end end
-- If a getter exists but not a setter, then the property is read-only
if args.getter_class and args.getter_class[getter_prefix..prop] then
return
end
local fallback = properties[cobj] or cobj_register(cobj) local fallback = properties[cobj] or cobj_register(cobj)
-- Use the fallback property table -- Use the fallback property table

View File

@ -40,4 +40,8 @@ local w = wibox()
w.foo = "bar" w.foo = "bar"
assert(w.foo == "bar") assert(w.foo == "bar")
-- Test if read-only properties really are read-only
screen[1].clients = 42
assert(screen[1].clients ~= 42)
require("_runner").run_steps({ function() return true end }) require("_runner").run_steps({ function() return true end })