[Gambas-user] Triggering org.freedesktop.DBus.Properties.PropertiesChanged

Bruce Steers bsteers4 at gmail.com
Sat Feb 11 03:08:36 CET 2023

On Fri, 10 Feb 2023 at 22:49, Bruce Steers <bsteers4 at gmail.com> wrote:

> i eventually figured out how to fire property change signals.

For the benefit of anyone searching the archives I though i could fully
explain what i needed to do to get the PropertiesChanged event to fire.

I was not straight forward and turned out to be a few different things

This was the Requirements...
Knowing the correct bus/object/interface to use when raising the signal

Here is the Method i made to send my PropertiesChanged signals

*Static Public Sub SignalPropertyChange(App As String, Name As String,
Value As Variant)  If Not $hInterface Then Return  Dim c As New Collection
c.Add(Value, Name)  DBus.Session[DBus.Name].Raise($hMyDbusObject,
"org.freedesktop.DBus.Properties.PropertiesChanged", [App, c, []])End*

*DBus.Session[DBus.Name]*    , this is my own DBus_Application
*$hMyDbusObject*  ' the Object referenced when Registering the DBusObject
with New
*App* = The Path where the Property(s) are that changed.
A single item collection is sent in my method but any number of properties
can be added.

So to send a signal that *org.mpris.MediaPlayer2.Player.Volume* has changed
i used this command...

*SignalPropertyChange("org.mpris.MediaPlayer2.Player", "Volume",

But it was more complicated than that!
I also had to add the DBus.Properties application to my bus and
signal/event to my source.

So DBus.Properties needed adding to the list of interfaces when I
Registered my interface, like so..

*  Try DBus.Session.Register($hMyDbusObject, "/org/mpris/MediaPlayer2", *
*      ["org.mpris.MediaPlayer2", "org.mpris.MediaPlayer2.Player",

And finally the last piece of the puzzle was the PropertiesChanged event
needed adding to the DBus_Object file

*Event org_freedesktop_DBus_Properties_PropertiesChanged(Name As String,
Properties As Collection, Invalidated As String[])*

THEN it finally all worked.

So that's it..
You first change the value that the DBus_Object property points to.
Then use the above (or similar) method to send the PropertiesChanged signal.

I did not know what the third "Invalidated" argument was for.
Here's a quote from the spec site so you can see if you need it..

 org.freedesktop.DBus.Properties.PropertiesChanged (STRING interface_name,
    ARRAY of DICT_ENTRY<STRING,VARIANT> changed_properties,
    ARRAY<STRING> invalidated_properties);
 where changed_properties is a dictionary containing the changed
properties with the new values and
 invalidated_properties is an array of properties that changed but the
value is not conveyed.

Wishing well
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230211/b2018172/attachment-0001.htm>

More information about the User mailing list