]> granicus.if.org Git - transmission/commitdiff
(trunk gtk) #2597: add an optional "download complete" sound to the gtk client
authorCharles Kerr <charles@transmissionbt.com>
Sun, 22 Nov 2009 18:55:24 +0000 (18:55 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Sun, 22 Nov 2009 18:55:24 +0000 (18:55 +0000)
configure.ac
gtk/Makefile.am
gtk/conf.c
gtk/notify.c
gtk/tr-prefs.c
gtk/tr-prefs.h
transmission.spec.in

index a366aabcc4c33c1e6a52977b1ecbfa077ddfef3f..e440daec5c986ac298313925bd14e961b58cbf41 100644 (file)
@@ -45,6 +45,7 @@ GTK_MINIMUM=2.6.0
 LIBNOTIFY_MINIMUM=0.4.3
 DBUS_GLIB_MINIMUM=0.70
 LIBEVENT_MINIMUM=1.4.5
+CANBERRA_MINIMUM=0.10
 AC_SUBST(OPENSSL_MINIMUM)
 AC_SUBST(CURL_MINIMUM)
 AC_SUBST(GIO_MINIMUM)
@@ -53,6 +54,7 @@ AC_SUBST(GTK_MINIMUM)
 AC_SUBST(LIBNOTIFY_MINIMUM)
 AC_SUBST(DBUS_GLIB_MINIMUM)
 AC_SUBST(LIBEVENT_MINIUM)
+AC_SUBST(CANBERRA_MINIMUM)
 
 AC_PROG_CC
 AC_PROG_CXX
@@ -273,6 +275,23 @@ if test "x$build_gtk" = "xyes"; then
         fi
     fi
 
+    PKG_CHECK_MODULES([LIBCANBERRA],
+                      [libcanberra-gtk >= $CANBERRA_MINIMUM],
+                      [have_libcanberra=yes],
+                      [have_libcanberra=no])
+    AC_ARG_ENABLE([libcanberra], 
+                  AS_HELP_STRING([--enable-libcanberra],[enable sounds]),, 
+                  [enable_libcanberra=yes]) 
+    use_libcanberra=no
+    if test "x$enable_libcanberra" = "xyes" ; then
+        if test "x$have_libcanberra" = "xyes"; then
+            use_canberra=yes
+            AC_SUBST(LIBCANBERRA_LIBS) 
+            AC_SUBST(LIBCANBERRA_CFLAGS) 
+            AC_DEFINE([HAVE_LIBCANBERRA], 1) 
+        fi
+    fi
+
     PKG_CHECK_MODULES([DBUS_GLIB],
                       [dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
                       [use_dbus_glib=yes],
@@ -424,6 +443,7 @@ Configuration:
 
         Build Mac client:              ${build_mac}
         Build GTK+ client:             ${build_gtk}
+          ... with canberra support:   ${use_canberra}
           ... with gio support:        ${use_gio}
           ... with dbus-glib support:  ${use_dbus_glib}
           ... with libnotify support:  ${use_libnotify}
index 1d5ddf753c110ce8a1e1d19a80e9656c61f52f69..e553a4f730c8b9a744f406433c1d03ee7495613e 100644 (file)
@@ -21,6 +21,7 @@ AM_CPPFLAGS = \
 
 AM_CFLAGS = \
     $(LIBEVENT_CFLAGS) \
+    $(LIBCANBERRA_CFLAGS) \
     $(GTK_CFLAGS) \
     $(LIBCURL_CFLAGS) \
     $(GIO_CFLAGS) \
@@ -101,6 +102,7 @@ transmission_LDADD = \
     $(top_builddir)/libtransmission/libtransmission.a \
     $(top_builddir)/third-party/miniupnp/libminiupnp.a \
     $(top_builddir)/third-party/libnatpmp/libnatpmp.a \
+    $(LIBCANBERRA_LIBS) \
     $(DHT_LIBS) \
     $(GTK_LIBS) \
     $(GIO_LIBS) \
index 81fa63dc6ce485ef7630f860b8dfa8d01b705065..24b12446510ade494aafc79bb36c9bd4ffbedeb4 100644 (file)
@@ -175,6 +175,7 @@ tr_prefs_init_defaults( tr_benc * d )
     tr_bencDictAddBool( d, PREF_KEY_FILTERBAR, TRUE );
     tr_bencDictAddBool( d, PREF_KEY_STATUSBAR, TRUE );
     tr_bencDictAddBool( d, PREF_KEY_SHOW_TRAY_ICON, FALSE );
+    tr_bencDictAddBool( d, PREF_KEY_PLAY_DOWNLOAD_COMPLETE_SOUND, TRUE );
     tr_bencDictAddBool( d, PREF_KEY_SHOW_DESKTOP_NOTIFICATION, TRUE );
     tr_bencDictAddBool( d, PREF_KEY_SHOW_MORE_TRACKER_INFO, FALSE );
     tr_bencDictAddBool( d, PREF_KEY_SHOW_BACKUP_TRACKERS, FALSE );
index eebce34480e9c09a8e19b1df28c209bb2468990f..f4a9a4306f0aa4bff04c09113880f20a61467a87 100644 (file)
  */
 
 #include <string.h>
+
+#ifdef HAVE_LIBCANBERRA
+ #include <canberra-gtk.h>
+#endif
+
 #ifdef HAVE_GIO
  #include <gio/gio.h>
 #endif
+
 #include <glib/gi18n.h>
 #include "conf.h"
 #include "notify.h"
@@ -86,6 +92,18 @@ can_support_actions( void )
 void
 tr_notify_send( TrTorrent *tor )
 {
+#ifdef HAVE_LIBCANBERRA
+    if( pref_flag_get( PREF_KEY_PLAY_DOWNLOAD_COMPLETE_SOUND ) )
+    {
+        /* play the sound, using sounds from the naming spec */
+        ca_context_play( ca_gtk_context_get (), 0,
+                         CA_PROP_EVENT_ID, "complete-download",
+                         CA_PROP_APPLICATION_NAME, g_get_application_name,
+                         CA_PROP_EVENT_DESCRIPTION, _("Download complete"),
+                         NULL);
+    }
+#endif
+
     if( pref_flag_get( PREF_KEY_SHOW_DESKTOP_NOTIFICATION ) )
     {
         const tr_info * info = tr_torrent_info( tor );
index 31b21b4d605fa5d70e0f476651005a250af8b7c0..4d992fe3b75e9822ca818f9eba29a496e5e0673c 100644 (file)
@@ -342,7 +342,7 @@ desktopPage( GObject * core )
     w = new_check_button( s, PREF_KEY_INHIBIT_HIBERNATION, core );
     hig_workarea_add_wide_control( t, &row, w );
 
-    s = _( "Show Transmission in the _notification area" );
+    s = _( "Show Transmission icon in the _notification area" );
     w = new_check_button( s, PREF_KEY_SHOW_TRAY_ICON, core );
     hig_workarea_add_wide_control( t, &row, w );
 
@@ -350,6 +350,12 @@ desktopPage( GObject * core )
     w = new_check_button( s, PREF_KEY_SHOW_DESKTOP_NOTIFICATION, core );
     hig_workarea_add_wide_control( t, &row, w );
 
+#ifdef HAVE_LIBCANBERRA
+    s = _( "Play _sound when downloads are complete" );
+    w = new_check_button( s, PREF_KEY_PLAY_DOWNLOAD_COMPLETE_SOUND, core );
+    hig_workarea_add_wide_control( t, &row, w );
+#endif
+
     hig_workarea_finish( t, &row );
     return t;
 }
index 927a97fe8d11fe1e8ece86d890d2fd4ddff0ae0c..1754d28353dcd8977cb98697e407e76aac6974f0 100644 (file)
@@ -29,6 +29,7 @@ GtkWidget * tr_prefs_dialog_new( GObject *   core,
 #define PREF_KEY_DIR_WATCH_ENABLED                 "watch-dir-enabled"
 #define PREF_KEY_SHOW_TRAY_ICON                    "show-notification-area-icon"
 #define PREF_KEY_SHOW_DESKTOP_NOTIFICATION         "show-desktop-notification"
+#define PREF_KEY_PLAY_DOWNLOAD_COMPLETE_SOUND      "play-download-complete-sound"
 #define PREF_KEY_SHOW_MORE_TRACKER_INFO            "show-tracker-scrapes"
 #define PREF_KEY_SHOW_BACKUP_TRACKERS              "show-backup-trackers"
 #define PREF_KEY_START                             "start-added-torrents"
index b1297c7a9c934418deff3fe2a5cc620539702a56..206880f60ab3c484bf4f7eddd8a686399e8eb252 100644 (file)
@@ -13,21 +13,24 @@ Epoch:     1
 Source0:   %{name}-%{version}.tar.bz2
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
+
 BuildRequires: curl-devel >= @CURL_MINIMUM@
-BuildRequires: openssl-devel >= @OPENSSL_MINIMUM@
+BuildRequires: dbus-glib-devel >= @DBUS_GLIB_MINIMUM@
 BuildRequires: glib2-devel >= @GLIB_MINIMUM@
 BuildRequires: gtk2-devel >= @GTK_MINIMUM@
-BuildRequires: libnotify-devel >= @LIBNOTIFY_MINIMUM@
+BuildRequires: libcanberra-devel >= @CANBERRA_MINIMUM@
 BuildRequires: libevent-devel >= @LIBEVENT_MINIMUM@
-BuildRequires: dbus-glib-devel >= @DBUS_GLIB_MINIMUM@
+BuildRequires: libnotify-devel >= @LIBNOTIFY_MINIMUM@
+BuildRequires: openssl-devel >= @OPENSSL_MINIMUM@
 
 Requires: curl >= @CURL_MINIMUM@
-Requires: openssl >= @OPENSSL_MINIMUM@
+Requires: dbus-glib >= @DBUS_GLIB_MINIMUM@
 Requires: glib2 >= @GLIB_MINIMUM@
 Requires: gtk2 >= @GTK_MINIMUM@
+Requires: libcanberra >= @CANBERRA_MINIMUM@
 Requires: libevent >= @LIBEVENT_MINIMUM@
 Requires: libnotify >= @LIBNOTIFY_MINIMUM@
-Requires: dbus-glib >= @DBUS_GLIB_MINIMUM@
+Requires: openssl >= @OPENSSL_MINIMUM@
 
 Provides: %{name}