[Gambas-user] DBus - How are signal data converted to Gambas data?

Benoît Minisini g4mba5 at gmail.com
Tue Jan 30 14:47:16 CET 2018


Le 30/01/2018 à 09:56, Hans Lehmann a écrit :
> Hello, Benoît,

Hi,

Please answer to the mailing-list!

> 
> Am 30.01.2018 um 03:10 schrieb Benoît Minisini:
>> As explained in the wiki, DBusValue must be used when you have to 
>> implement a DBus method that returns several values. Which is possible 
>> in DBus, but not in Gambas.
> That's understandable.
>>
>> DBusVariant is the datatype used to implement your own datatype 
>> conversion between a DBus value and a Gambas value. 
> But just in this case a small code section would be very helpful.
> 

As far as I remember, it was created to implement the DBus tray icon 
protocol.

For example, if you have a DBus method whose return value signature is 
"ii" (two integers) :

You create a new class named, for example, "MyDBusReturnValue" that 
inherits "DBusValues", whose Signature constant returns "ii".

You define the Gambas implementation of your method as returning a 
"MyDBusReturnValue". And inside, you create a new object of that type, 
assign to its Value property an array of integers, and return that object.

The internal marshalling routine will detect that MyDBusReturnValue 
inherits DBusValues, and so will know what you want to do: it will 
convert the Gambas array to the DBus values corresponding to the "ii" 
signature.

You have an example of that, with a more complex signature, with the 
"_DbusMenuItemLayout" class in the 'gb.dbus.trayicon' component project 
source code.

Regards,

--
Benoît Minisini


More information about the User mailing list