[Rhythmbox-devel] libnotify support [PATCH]



Hi all, this patch adds libnotify[1] support to rhythmbox.

libnotify is unreleased, and probably still far away from being ready,
but some projects already have patches[2]/plugins[3] for it available,
so here's one for rhtyhmbox :)

(patch is against anon CVS HEAD)

[1] http://svn.galago.info/trunk/libnotify/
[2] http://www.livejournal.com/users/davyd/145928.html
[3] http://dsgh.no-ip.org/gaim-libnotify/

--
Duarte H.
Index: configure.ac
===================================================================
RCS file: /cvs/gnome/rhythmbox/configure.ac,v
retrieving revision 1.145
diff -u -p -r1.145 configure.ac
--- configure.ac	18 Jun 2005 05:42:26 -0000	1.145
+++ configure.ac	24 Jun 2005 10:45:55 -0000
@@ -356,6 +356,21 @@ if test "x$with_dbus" != "xno"; then
 fi			  
 AM_CONDITIONAL(WITH_DBUS, test "x$enable_dbus" = "xyes")
 
+AC_ARG_WITH(libnotify,
+            AC_HELP_STRING([--with-libnotify],
+			   [Enable libnotify support]),,
+	      with_libnotify=auto)
+if test "x$with_libnotify" != "xno"; then
+	PKG_CHECK_MODULES(LIBNOTIFY, libnotify, enable_libnotify=yes, enable_libnotify=no)
+        if test "x$with_libnotify" = xyes && test "x$enable_libnotify" = xno; then
+	   AC_MSG_ERROR([libnotify explicitly requested but no support found])
+	fi
+        if test "x$enable_libnotify" = xyes; then
+		AC_DEFINE(WITH_LIBNOTIFY, 1, [Define if libnotify is enabled])
+	fi
+fi			  
+AM_CONDITIONAL(WITH_LIBNOTIFY, test "x$enable_libnotify" = "xyes")
+
 AM_GCONF_SOURCE_2
 
 AC_ARG_ENABLE(uninstalled-build,
@@ -491,6 +506,11 @@ if test x"$enable_dbus" = xyes; then
 else
 	AC_MSG_NOTICE([   D-BUS control/activation disabled])
 fi
+if test x"$enable_libnotify" = xyes; then
+	AC_MSG_NOTICE([** libnotify integration enabled])
+else
+	AC_MSG_NOTICE([   libnotify integration disabled])
+fi
 
 dnl if test "x$enable_audiocd" != "xyes"; then
 dnl 	AC_MSG_NOTICE([   Audio CD support is disabled])
Index: shell/Makefile.am
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/Makefile.am,v
retrieving revision 1.47
diff -u -p -r1.47 Makefile.am
--- shell/Makefile.am	19 Jun 2005 18:30:57 -0000	1.47
+++ shell/Makefile.am	24 Jun 2005 10:45:56 -0000
@@ -80,6 +80,10 @@ endif
 if WITH_DBUS
 rhythmbox_LDADD += $(top_builddir)/remote/dbus/librbdbus.la
 endif
+if WITH_LIBNOTIFY
+rhythmbox_LDADD += $(LIBNOTIFY_LIBS)
+endif
+
 
 # i hate link order problems
 rhythmbox_LDADD += $(top_builddir)/remote/librbremote.la
@@ -112,6 +116,9 @@ endif
 if WITH_DBUS
 INCLUDES += -I$(top_srcdir)/remote/dbus
 endif
+if WITH_LIBNOTIFY
+INCLUDES += $(LIBNOTIFY_CFLAGS)
+endif
 if USE_CD_BURNER
 rhythmbox_LDADD += $(LIBNAUTILUS_BURN_LIBS)
 endif
Index: shell/rb-shell.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/rb-shell.c,v
retrieving revision 1.303
diff -u -p -r1.303 rb-shell.c
--- shell/rb-shell.c	19 Jun 2005 18:30:57 -0000	1.303
+++ shell/rb-shell.c	24 Jun 2005 10:45:57 -0000
@@ -83,6 +83,10 @@
 #include "dashboard.c"
 #endif /* WITH_DASHBOARD */
 
+#ifdef WITH_LIBNOTIFY
+#include <libnotify/notify.h>
+#endif /* WITH_LIBNOTIFY */
+
 static void rb_shell_class_init (RBShellClass *klass);
 static void rb_shell_remote_proxy_init (RBRemoteProxyIface *iface);
 static void rb_shell_init (RBShell *shell);
@@ -606,6 +610,11 @@ rb_shell_init (RBShell *shell) 
 
 	eel_gconf_monitor_add (CONF_PREFIX);
 
+#ifdef WITH_LIBNOTIFY
+	if (!notify_is_initted ())
+		notify_init ("Rhythmbox");
+#endif /* WITH_LIBNOTIFY */
+
 }
 
 static void
@@ -1387,6 +1396,11 @@ rb_shell_playing_entry_changed_cb (RBShe
 #ifdef WITH_DASHBOARD
 	char *cluepacket;
 #endif
+#ifdef WITH_LIBNOTIFY
+	char *title, *icon_uri;
+	static NotifyHandle *handle;
+	NotifyIcon *icon;
+#endif
 
 	/* emit remote song_changed notification */
 	song.title = g_strdup (rb_refstring_get (entry->title));
@@ -1419,6 +1433,33 @@ rb_shell_playing_entry_changed_cb (RBShe
 	dashboard_send_raw_cluepacket (cluepacket);
 	g_free (cluepacket);
 #endif /* WITH_DASHBOARD */
+
+#ifdef WITH_LIBNOTIFY
+	title = g_strdup_printf ("%s - %s", song.artist, song.title);
+	icon_uri = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP, "rhythmbox.png", TRUE, NULL);
+
+	if (icon_uri)
+		icon = notify_icon_new_from_uri(icon_uri);
+	else
+		icon = NULL;
+
+	/* Show popup via libnotify */
+	handle = notify_send_notification (handle,
+			"song",
+			NOTIFY_URGENCY_LOW,
+			title,
+			NULL,
+			icon,
+			TRUE, 0,
+			NULL, 0);
+
+	g_free (title);
+	if (icon_uri)
+		g_free (icon_uri);
+	if (icon)
+		g_free (icon);
+#endif /* WITH_LIBNOTIFY */
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]