I’m using a Gio.DBusActionGroup() to read some data from a program into another every time it changed (by using the ‘action-state-changed’ signal). The problem is that I also need to get the initial values, but when I do that just after having created the Gio.DBusActionGroup() it returns NULL. I have to use a GLib.timeout_add() to wait a little bit and only then do the read, which is quite ugly.
The documentation says to use DBusActionGroup.list_actions() first, but it returns an empty string if done immediately after creating the DBusActionGroup(); but if I wait with the GLib.timeout_add(), then it does return the right value.
Is there a way of adding a callback to know when the DBusActionGroup() is ready?
EDIT: I also tried to create the DBusActionGroup in the ‘startup’ phase of the Gtk.Application() and try to read the data in the ‘activate’ phase, but with no luck.
I already do that. The point is that I want to read the “initial value” too, not only the changes (because this will change sometimes, not continually), and there is the problem: it doesn’t matter if I have previously called list_actions() or not, calling get_action_state() without a delay returns NULL.
If you want to do that, you’ll just have to make a synchronous call to the DBus interface yourself.
The initialization of Gio.DBusActionGroup is asynchronous, so if you don’t want to wait for the initial action-added signal to be emitted you’ll just have to make a blocking call to eg. org.gtk.Actions.Describe for the GAction that you want.