Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37894897
en ru br
ALT Linux repos
5.0: 0.8.10-alt2
4.1: 0.8.8-alt2
4.0: 0.8.6-alt1

Group :: Sound
RPM: muine

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: muine-0.8.8-libnotify.patch
Download


--- muine-0.8.8/plugins/TrayIcon.cs.libnotify	2007-10-16 06:53:43.000000000 +0200
+++ muine-0.8.8/plugins/TrayIcon.cs	2007-10-21 13:12:01.000000000 +0200
@@ -18,6 +18,7 @@
  */
 
 using System;
+using System.Runtime.InteropServices;
 
 using Gtk;
 using Gdk;
@@ -39,6 +40,16 @@ namespace Muine
 		private static readonly string string_tooltip_format = 
 			Catalog.GetString ("{0} - {1}");
 
+		// Strings :: Notification Format
+		//	song artists - song title
+		private static readonly string string_notification_summary_format = 
+			Catalog.GetString ("Now playing: {0}");
+
+		// Strings :: Notification Format
+		//	Album name
+		private static readonly string string_notification_message_format = 
+			Catalog.GetString ("by {0}");
+
 		// Widgets
 		private Plug icon;
 		private EventBox ebox;
@@ -54,6 +65,8 @@ namespace Muine
 		private int menu_y;
 		
 		private string tooltip = String.Empty; 
+		
+		private static bool showNotifications = true;
 
 		private bool playing = false;
 
@@ -243,6 +256,16 @@ namespace Muine
 			tooltip = (song == null) ? null : CreateTooltip (song);
 
 			UpdateTooltip ();
+
+			if (showNotifications && (song != null)) {
+				Notify(
+						String.Format(string_notification_summary_format, song.Title),
+						String.Format(
+							string_notification_message_format,
+							StringUtils.JoinHumanReadable (song.Artists)),
+						song.CoverImage,
+						ebox);
+			}
 		}
 
 		// Handlers :: OnStateChangedEvent
@@ -257,5 +280,64 @@ namespace Muine
 
 			UpdateImage ();
 		}
+
+
+		/* Libnotify bindings */
+
+		[DllImport("notify")]
+		private static extern bool notify_init(string app_name);
+
+		[DllImport("notify")]
+		private static extern void notify_uninit();
+
+		[DllImport("notify")]
+		private static extern IntPtr notify_notification_new(string summary, string message,
+				string icon, IntPtr widget);
+
+		[DllImport("notify")]
+		private static extern void notify_notification_set_timeout(IntPtr notification,
+				int timeout);
+		
+		[DllImport("notify")]
+		private static extern void notify_notification_set_urgency(IntPtr notification,
+				int urgency);
+
+		[DllImport("notify")]
+		private static extern void notify_notification_set_icon_from_pixbuf(IntPtr notification, IntPtr icon);
+
+		[DllImport("notify")]
+		private static extern bool notify_notification_show(IntPtr notification, IntPtr error);
+
+		[DllImport("gobject-2.0")]
+		private static extern void g_object_unref(IntPtr o);
+
+		public static void Notify(string summary, string message,
+				Pixbuf cover, Widget widget)
+		{
+			if (!showNotifications)
+				return;
+
+			try {
+				if(!notify_init("Muine"))
+					return;
+
+				summary = StringUtils.EscapeForPango(summary);
+				message = StringUtils.EscapeForPango(message);
+
+				IntPtr notif = notify_notification_new(summary, message, null, widget.Handle);
+				notify_notification_set_timeout(notif, 4000);
+				notify_notification_set_urgency(notif, 0);
+				if (cover != null) {
+					cover = cover.ScaleSimple(42, 42, InterpType.Bilinear);
+					notify_notification_set_icon_from_pixbuf(notif, cover.Handle);
+				}
+				notify_notification_show(notif, IntPtr.Zero);
+				g_object_unref(notif);
+				notify_uninit();
+
+			} catch (Exception) {
+				showNotifications = false;
+			}
+		}
 	}
 }
--- muine-0.8.8/plugins/TrayIcon.dll.config.libnotify	2007-10-16 06:20:11.000000000 +0200
+++ muine-0.8.8/plugins/TrayIcon.dll.config	2007-10-21 13:11:42.000000000 +0200
@@ -1,4 +1,6 @@
 <configuration>
   <dllmap dll="gdk-x11-2.0" target="libgdk-x11-2.0.so.0"/>
   <dllmap dll="libX11" target="libX11.so.6"/>
+  <dllmap dll="notify" target="libnotify.so.1"/>
+  <dllmap dll="gobject-2.0" target="libgobject-2.0.so.0"/>
 </configuration>
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin