I’m working on launching a GTK application using DBus and have followed this guide: GNOME DBus Application Launching. I have set up a service file and configured the desktop to support DBus launching.
My application, MyApp, is successfully launched using the following DBus command:
Although MyApp launches correctly, I am struggling to access the payload { 'token': <'example_data'> } within the application. The method org.freedesktop.Application.Activate (as shown) allows an argument called platform_data, which I assume should let me pass and retrieve this payload.
Is there a specific method or process to access platform_data inside the application once it has been activated via DBus? Any guidance or examples would be greatly appreciated!
Regardless of which of these entry points is used to start the application, GApplication passes some ‘platform data’ from the launching instance to the primary instance, in the form of a GVariant dictionary mapping strings to variants. To use platform data, override the Gio.ApplicationClass.before_emit or Gio.ApplicationClass.after_emit virtual functions in your GApplication subclass.
Thanks for the reply.
I also found that piece of info. I tried printing the platform data in my before_emit and after_emit function in my gtk.application class but no luck. The question now is when are those functions getting called? Are they called when the gtk app gets activated? Their function name implies they get called automatically before/after a signal, what is that signal?
As you can see from the linked code, before_emit() and after_emit() are called when before and after emitting the activate signal respectively. I just tested it in Python with PyGObject and it works fine: