After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 336248 - Notifications using libnotify
Notifications using libnotify
Status: RESOLVED FIXED
Product: muine
Classification: Other
Component: interface
trunk
Other All
: Normal normal
: ---
Assigned To: Muine Maintainers
Muine Maintainers
: 352097 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-03-27 20:21 UTC by Wouter Bolsterlee (uws)
Modified: 2008-09-28 01:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Initial patch (2.74 KB, patch)
2006-03-27 20:24 UTC, Wouter Bolsterlee (uws)
none Details | Review
Screenshot (58.96 KB, image/png)
2006-03-27 20:25 UTC, Wouter Bolsterlee (uws)
  Details
Improved patch (2.74 KB, patch)
2006-03-28 10:26 UTC, Wouter Bolsterlee (uws)
none Details | Review
Improved patch (2.76 KB, patch)
2006-03-28 10:37 UTC, Wouter Bolsterlee (uws)
none Details | Review
Even better! (3.14 KB, patch)
2006-03-28 10:41 UTC, Wouter Bolsterlee (uws)
none Details | Review
Same patch as above, but without the a/ b/ paths (3.13 KB, patch)
2006-03-28 19:12 UTC, C.M
none Details | Review
Other strings in notification bubble (4.97 KB, patch)
2006-04-03 14:42 UTC, Wouter Bolsterlee (uws)
none Details | Review
Other strings in notification bubble take 2 (3.38 KB, patch)
2006-04-03 14:44 UTC, Wouter Bolsterlee (uws)
none Details | Review
Correctly escape strings (3.47 KB, patch)
2006-04-12 12:16 UTC, Wouter Bolsterlee (uws)
none Details | Review
Shot of album cover being cut off by notification bubble. (13.29 KB, image/png)
2006-04-15 21:59 UTC, Jonah Bull
  Details
Notifications working with latest notification-daemon (12.85 KB, image/png)
2006-04-27 15:45 UTC, Jonah Bull
  Details
Update to CVS HEAD (3.98 KB, patch)
2006-09-30 11:12 UTC, Wouter Bolsterlee (uws)
none Details | Review
As above patches but with GConf key and installs the plugin (5.76 KB, patch)
2008-09-21 00:41 UTC, iain
accepted-commit_now Details | Review

Description Wouter Bolsterlee (uws) 2006-03-27 20:21:03 UTC
Muine could use libnotify to show notification bubbles when the song changes. I've created a patch that does this.
Comment 1 Wouter Bolsterlee (uws) 2006-03-27 20:24:26 UTC
Created attachment 62156 [details] [review]
Initial patch

Shows a notification bubble when the song changes.

Thanks to Sebastian Dröge for the help and the bindings code.
Comment 2 Wouter Bolsterlee (uws) 2006-03-27 20:25:20 UTC
Created attachment 62157 [details]
Screenshot

Screenshot of a notification bubble.
Comment 3 C.M 2006-03-28 04:42:05 UTC
Hey! Just a comment, it compiles fine without libnotify installed, then fails hard when you try to play a song with muine:

Unhandled Exception: System.DllNotFoundException: notify
in (wrapper managed-to-native) Muine.TrayIcon:notify_init (string)
in [0x00005] (at /usr/local/src/muine-notification/plugins/TrayIcon.cs:310) Muine.TrayIcon:Notify (System.String summary, System.String message, Gdk.Pixbuf cover, Gtk.Widget widget)
in [0x00054] (at /usr/local/src/muine-notification/plugins/TrayIcon.cs:259) Muine.TrayIcon:OnSongChangedEvent (ISong song)
in (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_ISong (Muine.PluginLib.ISong)
  .
  .

Try-Catch?

Besides that it looks great to me. Nice patch! :)
Comment 4 Wouter Bolsterlee (uws) 2006-03-28 07:26:08 UTC
I'm not really familiar with C# and Mono. Do you know how to wrap the DllImport and the method declarations in a try/catch statement?
Comment 5 C.M 2006-03-28 09:24:39 UTC
The almighty latexer said the following in #muine about the patch:
06:45 <latexer> and yeah, since it's all pinvoked stuff, you can throw the
                whole thing in a try/catch and be done with it.
06:45 <latexer> i suggest checking some bool before the try and, setting it to
                true in the catch.
06:45 <latexer> so you avoid the pinvoke overhead each time, you only do it
                once.

I'm no good with the pinvoke stuff either, but I guess he meant doing something like:

  private Boolean notifyDllMissing = false; // Assume it works


    // In the song changed part:
    if (!notifyDllMissing && song != null) {
       Notify(....
    }


  // In notify
  public static void Notify(string summary, string message,
                            Pixbuf cover, Widget widget)
      {
      Try {
           if(notify_init("Muine"))
           { 
               /* Show the notification */
           }
      } Catch(DllNotFoundException) {
          notifyDllMissing = true;  // The dll is missing
      }
  }

I could be wrong of course, can't test until I get home from work.
/Claes
Comment 6 Wouter Bolsterlee (uws) 2006-03-28 10:26:18 UTC
Created attachment 62189 [details] [review]
Improved patch

This improved patch drastically reduces the PInvoke overhead by only trying to initialize once.

Thanks for the comments, I think it's even better now :)
Comment 7 Wouter Bolsterlee (uws) 2006-03-28 10:37:51 UTC
Created attachment 62190 [details] [review]
Improved patch

Don't crash if libnotify was not found.
Comment 8 Wouter Bolsterlee (uws) 2006-03-28 10:41:55 UTC
Created attachment 62191 [details] [review]
Even better!

This patch is almost the same as the previous version, but adds two <dllmap> entries to TrayIcon.dll.config (libnotify and libgobject-2.0)
Comment 9 C.M 2006-03-28 19:12:10 UTC
Created attachment 62236 [details] [review]
Same patch as above, but without the a/ b/ paths

The patch above had some strange dirs that I removed. Otherwise it seems good.

Would it be possible to delay the notification a few seconds? With the current one, if you skip forward a few songs, the notification popup is showing all the time, even if the song hasn't actually started to play.
/Claes
Comment 10 Götz Waschk 2006-03-29 07:27:02 UTC
The patch from #8 is working fine here (Mandriva Cooker, libnotify 0.3.2, notification-daemon 0.3.4).
Comment 11 Wouter Bolsterlee (uws) 2006-04-03 14:30:18 UTC
I've been using Muine with notifications for a while now. The current patch shows:

>  Wolfgang Amadeus Mozart - Benedictus
>  Requiem

My local version shows:

>  Now playing: Benedictus
>  by Wolfgang Amadeus Mozart

This looks very friendly to me and I think it's better than the original version (despite the album name not being shown)
Comment 12 Wouter Bolsterlee (uws) 2006-04-03 14:42:31 UTC
Created attachment 62673 [details] [review]
Other strings in notification bubble

This is the patch with the strings from my comment #11. Fiddle with patch -p1/-p0 to trim the a/ and b/ parts (those are added by bazaar-ng)
Comment 13 Wouter Bolsterlee (uws) 2006-04-03 14:44:07 UTC
Created attachment 62674 [details] [review]
Other strings in notification bubble take 2

Woops, there was a spurious |colordiff pipe in my patch :P
Comment 14 Wouter Bolsterlee (uws) 2006-04-07 15:40:53 UTC
I found another issue: titles with an ampersand (&) are not displayed. I guesss some sort of escaping (XML entities?) should be done before passing the string to the notification API.
Comment 15 Wouter Bolsterlee (uws) 2006-04-07 15:50:50 UTC
17:45:32 <@latexer> uws: you probably need to use GLib.Markup.EscapeText on the string first.
Comment 16 Wouter Bolsterlee (uws) 2006-04-12 12:16:12 UTC
Created attachment 63306 [details] [review]
Correctly escape strings

Updated the patch to correctly escape the strings before passing them to libnotify.
Comment 17 Jonah Bull 2006-04-15 21:59:53 UTC
Created attachment 63609 [details]
Shot of album cover being cut off by notification bubble.
Comment 18 Jonah Bull 2006-04-15 22:02:08 UTC
Comment on attachment 63609 [details]
Shot of album cover being cut off by notification bubble.

I'm a fan of this patch, but as you can see in the attached ss, it cuts off the bottom of the album cover.  I'm running Ubuntu Dapper with libnotify 0.3.2 and notification-daemon 0.3.4.
Comment 19 Wouter Bolsterlee (uws) 2006-04-18 22:26:48 UTC
Wow, you actually see a cover! I've never managed to get one to show in one of my bubbles... I can't seem to figure out why, though.

About the cover being cut off: I think it's a libnotify bug, since we have no control over the size of the bubble. I think the notification bubble should somehow respect the size of the pixbuf passed to it.
Comment 20 Christian Hammond 2006-04-19 19:10:37 UTC
(In reply to comment #18)
> (From update of attachment 63609 [details] [edit])
> I'm a fan of this patch, but as you can see in the attached ss, it cuts off the
> bottom of the album cover.  I'm running Ubuntu Dapper with libnotify 0.3.2 and
> notification-daemon 0.3.4.
> 

It is a notification-daemon bug, and I'll be fixing it for the next release. I've just been pretty busy with work stuff and a Galago release lately, but I'll soon be getting back to notification-daemon and releasing a new version with several fixes.
Comment 21 Wouter Bolsterlee (uws) 2006-04-19 19:22:57 UTC
Ok. Great to know you're working on it.

Christian, any clue why I cannot any pixbuf to show up in my bubbles? It works for other people (see comment #17) and I made sure the pixbuf != null.
Comment 22 Christian Hammond 2006-04-19 21:18:05 UTC
(In reply to comment #21)
> Christian, any clue why I cannot any pixbuf to show up in my bubbles? It works
> for other people (see comment #17) and I made sure the pixbuf != null.
> 

Are you using the Standard theme, or the Bubble theme? If Bubble, try switching to Standard. I may be removing Bubble soon, since it's fundamentally broken.

Also, what version of D-BUS are you using?
Comment 23 Wouter Bolsterlee (uws) 2006-04-19 23:15:23 UTC
I am using the standard theme. D-Bus version is 0.61, but I run DBUS HEAD too sometimes.
Comment 24 Wouter Bolsterlee (uws) 2006-04-27 08:55:08 UTC
The NEWS file for notification-daemon version 0.3.5 claims to fix the image cut-off:

	* Fixed a problem where icons were being clipped in notifications.
	  Patch by M.S. (Bug #21)

Jonah, can you please test this?
Comment 25 Jonah Bull 2006-04-27 15:45:31 UTC
Created attachment 64405 [details]
Notifications working with latest notification-daemon

Wouter:  The latest version of notification-daemon does indeed fix the cut-off problem.  There might still be some alignment issues, but those I'd consider purely cosmetic.  Cheers.
Comment 26 Wouter Bolsterlee (uws) 2006-05-20 13:30:24 UTC
It seems mandriva has shipped muine with the last patch applied (see http://cvs.mandriva.com/cgi-bin/cvsweb.cgi/contrib-SPECS/muine/ for details).

If I add support for a hidden gconf key that defaults to "off", will the maintainers consider the notification for inclusion?
Comment 27 Wouter Bolsterlee (uws) 2006-06-19 14:30:35 UTC
Ping...?
Comment 28 Andrei Yurkevich 2006-06-20 16:29:12 UTC
I suppose it is not a good idea to ship this as an integral part of muine - first, it adds a bunch of dependancies (libnotify, notification-manager et al.) as well as it would certainly annoy many people - I for one know what songs are playing ;) However, it would be sweet if this feature gets implemented as a plugin.
Comment 29 Wouter Bolsterlee (uws) 2006-07-30 21:35:40 UTC
Andrei, the trayicon already is a plugin and this code patches that plugin. So it's totally optional (and not even installed by default). My comment #26 is still unanswered, though...

Regarding the libnotify dependencies: it's not a hard dependency, but merely a "recommends" (in Debian lingo). The libnotify detection is done at runtime and the functionality is just disabled if it's not found.
Comment 30 Wouter Bolsterlee (uws) 2006-09-29 15:35:37 UTC
*** Bug 352097 has been marked as a duplicate of this bug. ***
Comment 31 Wouter Bolsterlee (uws) 2006-09-29 15:36:47 UTC
Osmo Salomaa in bug #352097:

> It would be useful if the tray icon tooltip would
> display album cover art. Technically that would show
> a window instead of a normal tooltip when the mouse
> pointer hovers over the tray icon.

I'm not sure if this is a good idea...
Comment 32 Wouter Bolsterlee (uws) 2006-09-30 11:12:15 UTC
Created attachment 73696 [details] [review]
Update to CVS HEAD

This is the same patch, applying cleanly against current CVS HEAD.
Comment 33 Wouter Bolsterlee (uws) 2006-11-14 14:04:55 UTC
Changing component. Filter "uws doing muine component triaging" to get rid of the spam. Thanks!
Comment 34 Diego Escalante Urrelo (not reading bugmail) 2006-12-25 09:37:30 UTC
go go uws!
Comment 35 Wouter Bolsterlee (uws) 2006-12-25 13:34:10 UTC
This is probably not be muine default behaviour. I'm still waiting for answer to my question in comment #26.
Comment 36 Peter Johanson 2007-01-26 06:28:24 UTC
Hey Wouter,

Sorry for the delay in getting back to you. I am all for getting this in, once we get a gconf key, defaulted to false, for enabling/disabling the feature. Thanks for the patience and hard work!
Comment 37 Luis Medinas 2007-08-04 05:02:10 UTC
any news on this ?
Comment 38 Wouter Bolsterlee (uws) 2007-08-06 07:44:29 UTC
I'm slacking, but if there's any interest I'll try to come up with an updated patch that has the Gconf stuff as well.
Comment 39 Diego Escalante Urrelo (not reading bugmail) 2007-08-06 09:05:59 UTC
Is muine maintained?
Comment 40 Luis Medinas 2007-08-06 11:35:20 UTC
Wouter: yeah update your patch and get it going to svn.
Diego: I don't know but at least some of us are trying :).
Comment 41 Diego Escalante Urrelo (not reading bugmail) 2007-08-06 11:50:52 UTC
In that case also check bug #308208.
Comment 42 Wouter Bolsterlee (uws) 2007-08-06 11:54:15 UTC
(In reply to comment #39)
> Is muine maintained?

Basically not.
Comment 43 iain 2008-09-21 00:39:53 UTC
(In reply to comment #38)
> I'm slacking, but if there's any interest I'll try to come up with an updated
> patch that has the Gconf stuff as well.

Done :)
See attachment.

Patch add GConf key (off by default) and actually installs the tray icon plugin :)
Comment 44 iain 2008-09-21 00:41:07 UTC
Created attachment 119061 [details] [review]
As above patches but with GConf key and installs the plugin
Comment 45 Wouter Bolsterlee (uws) 2008-09-22 16:06:41 UTC
Haven't tested it, but just let's do it. Please commit your patch with a decent ChangeLog message.

Thanks for the work!
Comment 46 iain 2008-09-28 01:54:54 UTC
Committed to trunk...