Application activated twice when made D-Bus activatable


I’m trying to make my GTK application D-Bus activatable, but I’m facing a strange issue: the application is activated twice, resulting in two windows being opened. However, depending on how I launch it, the behavior is different:

  • When launching from the app grid, two windows are opened, but the icon doesn’t immediately appear in the dash, and the loading cursor continues spinning until then. When closing the windows before the icon appears and trying to run the app again, it is still marked as being launched.
  • With gapplication launch [app-id], two windows are opened, and the icon in the dash appears and disappears correctly.
  • When activating from D-Feet, everything works as expected. Only one window opens, and the icon in the dash appears and disappears correctly.

These are my .desktop and .service files:

[Desktop Entry]
Name=Metadata Cleaner
Exec=metadata-cleaner %F
[D-BUS Service]

I’m at a loss as to what is causing it, do you have any pointers I can look at?

The exec line should pass --gapplication-service. Otherwise your activate() method is called when the D-Bus demon activates the service, and then again for the org.gtk.Application.Activate() call that triggered D-Bus activation in the first place.


Thank you Florian! Indeed, with --gapplication-service, only one window opens.

However, when launching from the app grid, the icon issue remains: it appears in the dash after ~15 seconds and the loading cursor spins until then, and if I close the application before, it still appears as launched in the app grid.

That’s probably this GTK issue.

Oh I see, nothing I can do then. Thank you again!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.