Inhibit logout/shutdown when documents have unsaved changes
It is possible for an application to indicate to the desktop that the user may want to avoid ending their session. Apps such as Gedit do this so that GNOME Shell can warn the user when they attempt to shut down or log out that doing so will lose unsaved work:
It would be nice for GIMP to do the same. If the app is already using GtkApplication
then it is a matter of calling gtk_application_inhibit (..., GTK_APPLICATION_INHIBIT_LOGOUT, _("Open documents contain unsaved changes. Changes which are not saved will be permanently lost.")) when entering that state, and gtk_application_uninhibit()
when leaving it. However I see that GIMP does not use GtkApplication.
In a Flatpak or Snap context the underlying D-Bus API is this one. In the non-Flatpak case it is a method on org.gnome.SessionManager
, or org.xfce.SessionManager
, or presumably equivalents on other platforms... so the portal API or GTK's abstraction which knows many backends is preferable.