updated on Sat Jan 21 04:00:54 UTC 2012
[aur-mirror.git] / muine / use-notify-sharp.patch
blobdf749696c2e9ef31989b7321f8461419b4a776e4
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
7 ---
8 diff --git a/configure.in b/configure.in
9 index 95973f7..221a8fb 100644
10 --- a/configure.in
11 +++ b/configure.in
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
18 dnl Pkgconfig
19 PKG_PROG_PKG_CONFIG
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)
27 dnl ndesk-dbus
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 = \
37 $(GTKSHARP_LIBS) \
38 + $(NOTIFYSHARP_LIBS) \
39 -r:Mono.Posix
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;
48 using Mono.Unix;
50 +using Notifications;
52 using Muine.PluginLib;
54 namespace Muine
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";
61 // Widgets
62 private Plug icon;
63 private EventBox ebox;
64 @@ -61,6 +63,7 @@ namespace Muine
66 // Objects
67 private IPlayer player;
68 + private static Notification notif;
70 // Variables
71 private int menu_x;
72 @@ -284,11 +287,11 @@ namespace Muine
73 Init ();
76 - // Handlers :: OnShowNotificationsChanged
77 - private void OnShowNotificationsChanged (object o, GConf.NotifyEventArgs args)
78 - {
79 - showNotifications = (bool) args.Value;
80 - }
81 + // Handlers :: OnShowNotificationsChanged
82 + private void OnShowNotificationsChanged (object o, GConf.NotifyEventArgs args)
83 + {
84 + showNotifications = (bool) args.Value;
85 + }
87 // Handlers :: OnSongChangedEvent
88 private void OnSongChangedEvent (ISong song)
89 @@ -321,62 +324,35 @@ namespace Muine
90 UpdateImage ();
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,
107 - int timeout);
109 - [DllImport("notify")]
110 - private static extern void notify_notification_set_urgency(IntPtr notification,
111 - int urgency);
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)
127 return;
129 - try {
130 - if(!notify_init("Muine"))
131 - return;
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) {
145 if (cover != 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);
149 + } else {
150 + notif = new Notification(summary, message);
152 + } else {
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);
161 - notify_uninit();
163 - } catch (Exception) {
164 - showNotifications = false;
167 + notif.Show();
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
174 @@ -1,6 +1,5 @@
175 <configuration>
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"/>
180 </configuration>
182 cgit v0.9