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

View File

@ -83,6 +83,11 @@ function object.capi_index_fallback(class, args)
return args.setter_fallback(cobj, prop, value)
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)
-- Use the fallback property table

View File

@ -40,4 +40,8 @@ local w = wibox()
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 })