Skip to content

extend set_property? #3

@terminar

Description

@terminar

In _proxy.lua, the getter's and setter's are not as intuitive as they should be.

get_property returns some sort of Lua'ized version of the result where some of the GVariants are translated to plain Lua.
set_property does nothing like auto conversion to GVariant.

Maybe a minimum solution would be something like:

local function set_property(proxy, name, opts)
  local variant_value
  local vtype = type(opts)
  if vtype == "userdata" and tostring(opts):find("GLib%.Variant$") then
    variant_value = opts
  elseif vtype == "table" and opts.signature and opts.value then
    variant_value = GVariant(opts.signature, opts.value)
  else
    error("Wrong parameter, should be table with { .signature and .value } or GVariant")
  end
  proxy._proxy:set_cached_property(name, variant_value)
end

This may report a correct error and also accepts GVariants if they are passed.
It may also be nice to have a converter for the basic types (number, string) but that's just an idea.

What do you think?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions