[gnotification] improve "no buttons" handling
Submitted by Allison (desrt)
Link to original bug (#778077)
Description
The GNotification experience on Unity is currently quite bad. That's caused by the fact that Unity supports actions, but doesn't advertise that it does. What's worse: when an action is sent, the result is that an ugly popup dialog is displayed instead of a notification.
The logic that we followed when we wrote the code originally is thus: the notification spec strongly implies that features that are not supported in a given implementation will be ignored by that implementation, so we unconditionally send the actions, assuming that the Unity implementation (which advertises not recognising 'actions') will ignore them. We could check for 'actions' being supported and decide not to send them, but the outcome would be the same in any case, at least in theory.
So we save some effort and skip the check (which would be an additional blocking or async dbus call inside of an API that is supposed to be non-blocking).
The original "solution" to this problem was supposed to be for Ubuntu to carry a patch to their GTK version to drop the actions in case an app was running under Unity. That made sense, since this is (as far as any of us know) a problem that only exists on Ubuntu.
I was chatting with hughsie about this today, however, and he raised two interesting points:
-
flatpak exists now, and we must assume that upstream GTK versions will run on Ubuntu systems. Any fix for this issue must therefore be upstream
-
gnome-shell, under some conditions, displays older notifications in a list without buttons. The application may want to provide an alternate text to be used for the "buttons are not shown" case for this reason as well.
For this reason, we might consider adding something like g_notification_set_nobuttons_text() which would provide an alternate blurb that can be sent to the shell to be displayed in the no-buttons case and can also be used when running on Unity.
We could also just have a simple check for Unity, and drop actions unconditionally (again, flatpak causes this to start making sense upstream). imho, action text should always read like "You've got mail." with options like "Read", "Spam", "Archive" and never like "Do you want to read your new message?" "Yes"/"No". I therefore have a hard time thinking about a case where the message text would have to be different depending on if buttons are there or not. Given that, adding _set_nobuttons_text() would be weird.
Looking for designer/larsu input.