1 From e259faf29250f09fe8b851e026fab3a74c72b794 Mon Sep 17 00:00:00 2001
2 From: daniel g. siegel <dgsiegel@gnome.org>
3 Date: Wed, 14 Oct 2009 19:36:43 +0000
4 Subject: use notify-sharp
6 update muine to use notify-sharp instead of using the C API
8 diff --git a/configure.in b/configure.in
9 index 95973f7..221a8fb 100644
12 @@ -29,6 +29,7 @@ MONO_REQUIRED=1.1
13 GTKSHARP_REQUIRED=2.12.9
14 TAGLIBSHARP_REQUIRED=2.0.3
15 MONODOC_REQUIRED=1.1.9
16 +NOTIFYSHARP_REQUIRED=0.4.0
20 @@ -55,6 +56,9 @@ PKG_CHECK_MODULES(GTKSHARP,
21 PKG_CHECK_MODULES(TAGLIBSHARP,
22 taglib-sharp >= $TAGLIBSHARP_REQUIRED)
24 +PKG_CHECK_MODULES(NOTIFYSHARP,
25 + notify-sharp >= $NOTIFYSHARP_REQUIRED)
28 PKG_CHECK_MODULES(DBUS, ndesk-dbus-1.0 >= 0.4 \
29 ndesk-dbus-glib-1.0 >= 0.3, have_dbus="yes", have_dbus="no")
30 diff --git a/plugins/Makefile.am b/plugins/Makefile.am
31 index e14faa8..6aadf56 100644
32 --- a/plugins/Makefile.am
33 +++ b/plugins/Makefile.am
34 @@ -27,6 +27,7 @@ TRAY_ICON_EXTRA_CSFILES = \
36 TRAY_ICON_EXTRA_ASSEMBLIES = \
38 + $(NOTIFYSHARP_LIBS) \
41 TRAY_ICON_RESOURCES = \
42 diff --git a/plugins/TrayIcon.cs b/plugins/TrayIcon.cs
43 index 629ef9e..b1f6b56 100644
44 --- a/plugins/TrayIcon.cs
45 +++ b/plugins/TrayIcon.cs
46 @@ -26,6 +26,8 @@ using Gdk;
52 using Muine.PluginLib;
55 @@ -51,7 +53,7 @@ namespace Muine
56 private static readonly string string_notification_message_format =
57 Catalog.GetString ("by {0}");
59 - private const string GConfKeyShowNotifications = "/apps/muine/show_notifications";
60 + private const string GConfKeyShowNotifications = "/apps/muine/show_notifications";
63 private EventBox ebox;
64 @@ -61,6 +63,7 @@ namespace Muine
67 private IPlayer player;
68 + private static Notification notif;
72 @@ -284,11 +287,11 @@ namespace Muine
76 - // Handlers :: OnShowNotificationsChanged
77 - private void OnShowNotificationsChanged (object o, GConf.NotifyEventArgs args)
79 - showNotifications = (bool) args.Value;
81 + // Handlers :: OnShowNotificationsChanged
82 + private void OnShowNotificationsChanged (object o, GConf.NotifyEventArgs args)
84 + showNotifications = (bool) args.Value;
87 // Handlers :: OnSongChangedEvent
88 private void OnSongChangedEvent (ISong song)
89 @@ -321,62 +324,35 @@ namespace Muine
93 - /* Libnotify bindings */
95 - [DllImport("notify")]
96 - private static extern bool notify_init(string app_name);
98 - [DllImport("notify")]
99 - private static extern void notify_uninit();
101 - [DllImport("notify")]
102 - private static extern IntPtr notify_notification_new(string summary, string message,
103 - string icon, IntPtr widget);
105 - [DllImport("notify")]
106 - private static extern void notify_notification_set_timeout(IntPtr notification,
109 - [DllImport("notify")]
110 - private static extern void notify_notification_set_urgency(IntPtr notification,
113 - [DllImport("notify")]
114 - private static extern void notify_notification_set_icon_from_pixbuf(IntPtr notification, IntPtr icon);
116 - [DllImport("notify")]
117 - private static extern bool notify_notification_show(IntPtr notification, IntPtr error);
119 - [DllImport("gobject-2.0")]
120 - private static extern void g_object_unref(IntPtr o);
122 public static void Notify(string summary, string message,
123 Pixbuf cover, Widget widget)
125 - if (!showNotifications)
126 + if (!showNotifications)
130 - if(!notify_init("Muine"))
133 - summary = StringUtils.EscapeForPango(summary);
134 - message = StringUtils.EscapeForPango(message);
135 + summary = StringUtils.EscapeForPango(summary);
136 + message = StringUtils.EscapeForPango(message);
137 + if (cover != null) {
138 + cover = cover.ScaleSimple(42, 42, InterpType.Bilinear);
141 - IntPtr notif = notify_notification_new(summary, message, null, widget.Handle);
142 - notify_notification_set_timeout(notif, 4000);
143 - notify_notification_set_urgency(notif, 0);
144 + if (notif == null) {
146 - cover = cover.ScaleSimple(42, 42, InterpType.Bilinear);
147 - notify_notification_set_icon_from_pixbuf(notif, cover.Handle);
148 + notif = new Notification(summary, message, cover);
150 + notif = new Notification(summary, message);
153 + notif.Summary = summary;
154 + notif.Body = message;
155 + notif.IconName = "media-optical";
156 + if (cover != null) {
157 + notif.Icon = cover;
159 - notify_notification_show(notif, IntPtr.Zero);
160 - g_object_unref(notif);
163 - } catch (Exception) {
164 - showNotifications = false;
170 private void OnWindowEvent (object o, WidgetEventArgs args)
171 diff --git a/lugins/TrayIcon.dll.config b/plugins/TrayIcon.dll.config
172 --- a/plugins/TrayIcon.dll.config
173 +++ b/plugins/TrayIcon.dll.config
176 <dllmap dll="gdk-x11-2.0" target="libgdk-x11-2.0.so.0"/>
177 <dllmap dll="libX11" target="libX11.so.6"/>
178 - <dllmap dll="notify" target="libnotify.so.1"/>
179 <dllmap dll="gobject-2.0" target="libgobject-2.0.so.0"/>