Conversation
leolost2605
commented
Jun 29, 2023
- Works with Use GLib.ActionGroup to handle actions notifications#193
…tary/wingpanel-indicator-notifications into support-buttons-with-action-group
src/Widgets/NotificationEntry.vala
Outdated
| button_release_event.connect (() => { | ||
| unowned var action_group = get_action_group (ACTION_GROUP_PREFIX); | ||
| if (action_group.has_action (notification.default_action)) { | ||
| notification.app_info.launch_action (Notification.DEFAULT_ACTION, new GLib.AppLaunchContext ()); |
There was a problem hiding this comment.
this is wrong, notifications actions aren't desktop actions.
There was a problem hiding this comment.
Hmm I took that from the previous implementation. Maybe it's relied upon by an elementary app even though it's not in the spec? Or maybe @danirabbit can give background on that?
There was a problem hiding this comment.
I’m not sure what is meant by “notifications aren’t desktop actions” but this is meant to support https://valadoc.org/gio-2.0/GLib.Notification.set_default_action.html
There was a problem hiding this comment.
I’m not sure what is meant by “notifications aren’t desktop actions”…
a action name in the actions parameter of org.freedesktop.Notifications.Notify method aren't a "exported" action (a action in the org.gtk.Actions interface in the applications's object path), or a desktop action.
GLib.DesktopAppInfo.launch_action() is meant to launch desktop actions only (can be abused to launch exported actions because of how GLib.Application is written, but won't work for non-GLib.Application applications).
…but this is meant to support https://valadoc.org/gio-2.0/GLib.Notification.set_default_action.html
when GLib.Notification uses the org.freedesktop.Notifications interface, it will use GLib.Action.print_detailed_name() for buttons, and "default" for the default action. so we will never receive a real action that could be used with GLib.DesktopAppInfo.launch_action(), only false positives.
There was a problem hiding this comment.
It only launches the AppInfo now without an action. I think that's something we want or shouldn't we launch it at all? IMHO it's probably expected to bring the app to foreground when the notification is clicked on regardless of default action or no action.
|
Sorry @Marukesu I thought I hadn't requested a review yet |
Thinking better, i take this back. The session file store notifications by id, ids aren't meant to be persistent and are reused by the server after a restart, that makes the indicator unreliable to deal with removing/closing/activating a notifications because of colliding ids. the fact this doesn't cause much problems currently is because the indicator don't report back notification closing, neither support action activation of any type (the current default action code is broken). but once this get merged theses issues will start to be recurrent. |
Store notifications by an internal id with the format "timestamp.server id" Don't store notification actions Don't emit signals for notifications loaded from the last session Use notification_closed with UNDEFINED for closing the notificiation when an action was invoked
|
Notifications are now stored by an internal id consisting of timestamp.server_id. |
src/Widgets/NotificationsList.vala
Outdated
| try { | ||
| notification_entry.notification.app_info.launch (null, null); | ||
|
|
||
| close_popover (); | ||
| notification_entry.clear (); | ||
| close_popover (); | ||
| } catch (Error e) { | ||
| warning ("Unable to launch app: %s", e.message); | ||
| } |
There was a problem hiding this comment.
this should be in a else block and close_popover() should be called after it.
There was a problem hiding this comment.
But if it's in a else block it can't do
It only launches the AppInfo now without an action. I think that's something we want or shouldn't we launch it at all? IMHO it's probably expected to bring the app to foreground when the notification is clicked on regardless of default action or no action.
right? Do we still want it?
There was a problem hiding this comment.
We want to call GLib.AppInfo.launch() only when there's no default action, the current code always call it.
i like the idea of the deactivated buttons, i think you could drop the actions but not the label from the session file, and simply don't try to validate anything when restoring. that way we don't risk ending re-enabling a button because the new notification for the same id has a matching action name. |
The server id will be 0 and therefore the action always invalid so AFAIK there is no way we could re-enable it by accident. If you want me to do it anyway because of a bit less space used I'd be happy to update it but it'd require quite a bit more code because without we only have to handle a single way buttons are given and I don't think it's really worth it 🤷 |
d7176ca to
99ac878
Compare
|
🎉 amazing love it |