Add resident notifications support

Bug #968619 reported by Alex Anthony
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Nuvola Apps Runtime (Nuvola Player)
Fix Released
Wishlist
Unassigned

Bug Description

In GNOME Shell, the music player integration in the message tray is through libnotify resident notifications (I know about the mediaplayer extensions, but I think this is neater). This is a screenshot of how rhythmbox does it:
http://blogs.gnome.org/marina/files/2011/01/notification-rhythmbox-clipped.png
(For reference, the C code for this is at http://git.gnome.org/browse/rhythmbox/tree/plugins/notification/rb-notification-plugin.c)

Essentially, the notification acts as both notification and supplants the TrayIcon (giving integrated buttons and it can be used in shell overview)

The code change to do this is quite simple as nuvola uses libnotify and has sane actions anyway:

In player.vala, after this.notification is created (may want to do an if "persistence" and "action-icons" in Notify.get_server_caps(), but this is all ignored gracefully if they aren't supported)

this.notification.set_hint_byte("resident", 1);
this.notification.set_hint_byte("action-icons", 1);
(set_hint_byte is deprecated in place of set_hint, but the second arg of set_hint has to be a gvariant boolean and I don't know how to create that in vala)

Then somewhere add a function to update notification actions
this.notification.clear_actions();
foreach(var action in PlayerActions.all()){
    if((this.actions & action) == PlayerActions.NONE) continue;
    this.notification.add_action(action.get_icon(), action.get_label(), () => {this.trigger_action(action);});
}

Not quite sure where this wants to hook in in order to update the buttons at the right time, I just briefly looked through the source and don't really know vala. Obviously this can all be wrapped in conditional blocks. Also, seeing as PlayerActions has Play/Pause before Prev & Next it looks a bit strange, and you may want to make it ignore the QUIT action

Overall, simple to add, looks good where supported (e.g. shell), falls back gracefully if not supported.

Changed in nuvola-player:
status: New → Confirmed
importance: Undecided → Wishlist
milestone: none → 1.1
Changed in nuvola-player:
status: Confirmed → Triaged
Changed in nuvola-player:
status: Triaged → In Progress
assignee: nobody → Jiří Janoušek (fenryxo)
Revision history for this message
Jiří Janoušek (fenryxo) wrote :

Partial fix committed to lp:nuvola-player r356.

Changed in nuvola-player:
status: In Progress → Triaged
assignee: Jiří Janoušek (fenryxo) → nobody
Changed in nuvola-player:
milestone: 1.1.0 → patches-welcome
Revision history for this message
Jiří Janoušek (fenryxo) wrote :

Fix committed to lp:nuvola-player as revision 590. Testing[1] and feedback is welcome.

[1] http://nuvolaplayer.fenryxo.cz/contribute/testing.html

Changed in nuvola-player:
status: Triaged → Fix Committed
milestone: future → 2.1.0
Revision history for this message
Jiří Janoušek (fenryxo) wrote :

The fix has been released in a freshly baken Nuvola Player 2.1.0,
download it while it is still hot. Happy listening!

http://nuvolaplayer.fenryxo.cz/download.html
http://nuvolaplayer.fenryxo.cz/releases/2.1.html

I'm trying to crowd-fund my work on Nuvola Player via Gittip.
If the fix has made you happy, please consider setting up
a small recurrent donation to support further maintenance
and development. Thank you.

https://www.gittip.com/NuvolaPlayer/

Changed in nuvola-player:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.