## OPTIONAL for the GTK+ client
##
##
-# play the XDG "download done" sound...
-CANBERRA_MINIMUM=0.10
-AC_SUBST(CANBERRA_MINIMUM)
# inhibit hibernation when a torrent is active...
DBUS_GLIB_MINIMUM=0.70
AC_SUBST(DBUS_GLIB_MINIMUM)
# implement "watch" directories to use new .torrent files...
GIO_MINIMUM=2.15.5
AC_SUBST(GIO_MINIMUM)
-# pop up a "download done" notice...
-LIBNOTIFY_MINIMUM=0.4.3
-AC_SUBST(LIBNOTIFY_MINIMUM)
# create the tray icon with AppIndicator
LIBAPPINDICATOR_MINIMUM=0.0.11
AC_SUBST(LIBAPPINDICATOR_MINIMUM)
build_gtk=no
use_gio=no
use_libappindicator=no
-use_libnotify=no
use_dbus_glib=no
-use_canberra=no
if test "x$want_gtk" = "xyes" ; then
if test "x$have_gtk" = "xyes"; then
build_gtk=yes
AC_DEFINE([HAVE_GIO], 1)
fi
- PKG_CHECK_MODULES([LIBNOTIFY],
- [libnotify >= $LIBNOTIFY_MINIMUM],
- [have_libnotify=yes],
- [have_libnotify=no])
- AC_ARG_ENABLE([libnotify],
- AS_HELP_STRING([--enable-libnotify],[enable notifications]),,
- [enable_libnotify=yes])
- use_libnotify=no
- if test "x$have_libnotify" = "xyes"; then
- if test "x$enable_libnotify" = "xyes" ; then
- use_libnotify=yes
- AC_DEFINE([HAVE_LIBNOTIFY], 1)
- else
- LIBNOTIFY_CFLAGS=
- LIBNOTIFY_LIBS=
- fi
- fi
-
PKG_CHECK_MODULES([LIBAPPINDICATOR],
[appindicator-0.1 >= $LIBAPPINDICATOR_MINIMUM],
[have_libappindicator=yes],
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])
- if test "x$have_libcanberra" = "xyes"; then
- if test "x$enable_libcanberra" = "xyes" ; then
- use_canberra=yes
- AC_DEFINE([HAVE_LIBCANBERRA], 1)
- else
- LIBCANBERRA_CFLAGS=
- LIBCANBERRA_LIBS=
- fi
- fi
-
PKG_CHECK_MODULES([DBUS_GLIB],
[dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
[use_dbus_glib=yes],
* dbus support: ${use_dbus_glib}
* gio for watchdir and mime-type support: ${use_gio}
- * libnotify for 'download completed' popups: ${use_libnotify}
- * libcanberra for 'download completed' sounds: ${use_canberra}
* libappindicator for an Ubuntu-style tray: ${use_libappindicator}
Build Daemon: ${build_daemon}
AM_CFLAGS = \
@LIBAPPINDICATOR_CFLAGS@ \
@LIBEVENT_CFLAGS@ \
- @LIBCANBERRA_CFLAGS@ \
@GTK_CFLAGS@ \
@LIBCURL_CFLAGS@ \
@GIO_CFLAGS@ \
- @LIBNOTIFY_CFLAGS@ \
@DBUS_GLIB_CFLAGS@ \
@OPENSSL_CFLAGS@ \
@ZLIB_CFLAGS@ \
$(top_builddir)/libtransmission/libtransmission.a \
$(top_builddir)/third-party/miniupnp/libminiupnp.a \
$(top_builddir)/third-party/libnatpmp/libnatpmp.a \
- @LIBCANBERRA_LIBS@ \
@DHT_LIBS@ \
@LIBUTP_LIBS@ \
@GTK_LIBS@ \
@GIO_LIBS@ \
@LIBAPPINDICATOR_LIBS@ \
- @LIBNOTIFY_LIBS@ \
@LIBEVENT_LIBS@ \
@DBUS_GLIB_LIBS@ \
@LIBCURL_LIBS@ \
if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD );
if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DESKTOP );
if( !str ) str = tr_getDefaultDownloadDir( );
- tr_bencDictAddStr( d, PREF_KEY_DIR_WATCH, str );
+ tr_bencDictAddStr ( d, PREF_KEY_DIR_WATCH, str );
tr_bencDictAddBool( d, PREF_KEY_DIR_WATCH_ENABLED, FALSE );
#endif
tr_bencDictAddBool( d, PREF_KEY_INHIBIT_HIBERNATION, FALSE );
tr_bencDictAddBool( d, PREF_KEY_BLOCKLIST_UPDATES_ENABLED, TRUE );
- tr_bencDictAddStr( d, PREF_KEY_OPEN_DIALOG_FOLDER, g_get_home_dir( ) );
+ tr_bencDictAddStr ( d, PREF_KEY_OPEN_DIALOG_FOLDER, g_get_home_dir( ) );
tr_bencDictAddBool( d, PREF_KEY_TOOLBAR, TRUE );
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_MORE_PEER_INFO, FALSE );
tr_bencDictAddBool( d, PREF_KEY_SHOW_BACKUP_TRACKERS, FALSE );
- tr_bencDictAddStr( d, PREF_KEY_STATUSBAR_STATS, "total-ratio" );
+ tr_bencDictAddStr ( d, PREF_KEY_STATUSBAR_STATS, "total-ratio" );
+
+ tr_bencDictAddStr ( d, PREF_KEY_TORRENT_ADDED_NOTIFICATION_COMMAND, "notify-send -c transfer -i transmission '%s' '%s'" );
+ tr_bencDictAddBool( d, PREF_KEY_TORRENT_ADDED_NOTIFICATION_ENABLED, true );
+ tr_bencDictAddStr ( d, PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_COMMAND, "notify-send -c transfer.complete -i transmission '%s' '%s'" );
+ tr_bencDictAddBool( d, PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_ENABLED, true );
+ tr_bencDictAddStr ( d, PREF_KEY_TORRENT_COMPLETE_SOUND_COMMAND, "canberra-gtk-play -i complete-download -d 'transmission torrent downloaded'" );
+ tr_bencDictAddBool( d, PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED, true );
tr_bencDictAddBool( d, PREF_KEY_OPTIONS_PROMPT, TRUE );
#include "hig.h"
#include "makemeta-ui.h"
#include "msgwin.h"
-#include "notify.h"
#include "open-dialog.h"
#include "relocate.h"
#include "stats.h"
if( configDir == NULL )
configDir = (char*) tr_getDefaultConfigDir( MY_CONFIG_NAME );
- gtr_notify_init( );
didinit = cf_init( configDir, NULL ); /* must come before actions_init */
setupsighandlers( ); /* set up handlers for fatal signals */
* $Id$
*/
-#include <string.h> /* strcmp() */
-
-#ifdef HAVE_LIBCANBERRA
- #include <canberra-gtk.h>
-#endif
-
-#ifdef HAVE_GIO
- #include <gio/gio.h>
-#endif
-
#include <glib/gi18n.h>
-#include "actions.h" /* NOTIFICATION_ICON */
#include "conf.h"
#include "notify.h"
#include "tr-prefs.h"
#include "util.h"
-#ifndef HAVE_LIBNOTIFY
-
-void gtr_notify_init( void ) { }
-void gtr_notify_torrent_completed( TrCore * core UNUSED, int torrent_id UNUSED ) { }
-void gtr_notify_torrent_added( const char * name UNUSED ) { }
-
-#else
- #include <libnotify/notify.h>
-
-void
-gtr_notify_init( void )
-{
- notify_init( "Transmission" );
-}
-
-struct notify_callback_data
-{
- TrCore * core;
- int torrent_id;
-};
-
-static void
-notify_callback_data_free( gpointer gdata )
-{
- struct notify_callback_data * data = gdata;
- g_object_unref( G_OBJECT( data->core ) );
- g_free( data );
-}
-
-static struct notify_callback_data *
-notify_callback_data_new( TrCore * core, int torrent_id )
-{
- struct notify_callback_data * data = g_new( struct notify_callback_data, 1 );
- data->core = core;
- data->torrent_id = torrent_id;
- g_object_ref( G_OBJECT( data->core ) );
- return data;
-}
-
-static void
-notifyCallback( NotifyNotification * n UNUSED,
- const char * action,
- gpointer gdata )
-{
- struct notify_callback_data * data = gdata;
- tr_torrent * tor = gtr_core_find_torrent( data->core, data->torrent_id );
-
- if( tor != NULL )
- {
- if( !strcmp( action, "folder" ) )
- {
- gtr_core_open_folder( data->core, data->torrent_id );
- }
- else if( !strcmp( action, "file" ) )
- {
- const tr_info * inf = tr_torrentInfo( tor );
- const char * dir = tr_torrentGetDownloadDir( tor );
- char * path = g_build_filename( dir, inf->files[0].name, NULL );
- gtr_open_file( path );
- g_free( path );
- }
- }
-}
-
-static gboolean
-can_support_actions( void )
-{
- static gboolean supported;
- static gboolean have_checked = FALSE;
-
- if( !have_checked )
- {
- GList * c;
- GList * caps = notify_get_server_caps( );
-
- have_checked = TRUE;
-
- for( c=caps; c && !supported; c=c->next )
- supported = !strcmp( "actions", (char*)c->data );
-
- g_list_foreach( caps, (GFunc)g_free, NULL );
- g_list_free( caps );
- }
-
- return supported;
-}
-
-static void
-addIcon( NotifyNotification * notify )
-{
- int size = 32;
- GtkIconTheme * theme;
- GdkPixbuf * icon;
-
- gtk_icon_size_lookup( GTK_ICON_SIZE_DIALOG, &size, &size );
- theme = gtk_icon_theme_get_default( );
- icon = gtk_icon_theme_load_icon( theme, NOTIFICATION_ICON, size, 0, NULL );
-
- if( icon != NULL )
- {
- notify_notification_set_icon_from_pixbuf( notify, icon );
- g_object_unref( icon );
- }
-}
-
-static NotifyNotification *
-tr_notify_notification_new( const char * summary,
- const char * body,
- const char * icon )
-{
- NotifyNotification * n = notify_notification_new( summary, body, icon
-/* the fourth argument was removed in libnotify 0.7.0 */
-#if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7)
- , NULL
-#endif
- );
- return n;
-}
-
void
gtr_notify_torrent_completed( TrCore * core, int torrent_id )
{
-#ifdef HAVE_LIBCANBERRA
- if( gtr_pref_flag_get( PREF_KEY_PLAY_DOWNLOAD_COMPLETE_SOUND ) )
+ if( gtr_pref_flag_get( PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED ) )
{
- /* 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);
+ const char * cmd = gtr_pref_string_get( PREF_KEY_TORRENT_COMPLETE_SOUND_COMMAND );
+ g_spawn_command_line_async( cmd, NULL );
}
-#endif
- if( gtr_pref_flag_get( PREF_KEY_SHOW_DESKTOP_NOTIFICATION ) )
+ if( gtr_pref_flag_get( PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_ENABLED ) )
{
- NotifyNotification * n;
- tr_torrent * tor = gtr_core_find_torrent( core, torrent_id );
-
- n = tr_notify_notification_new( _( "Torrent Complete" ), tr_torrentName( tor ), NULL );
- addIcon( n );
-
- if( can_support_actions( ) )
- {
- const tr_info * inf = tr_torrentInfo( tor );
- if( inf->fileCount == 1 )
- notify_notification_add_action(
- n, "file", _( "Open File" ),
- NOTIFY_ACTION_CALLBACK( notifyCallback ),
- notify_callback_data_new( core, torrent_id ),
- notify_callback_data_free );
-
- notify_notification_add_action(
- n, "folder", _( "Open Folder" ),
- NOTIFY_ACTION_CALLBACK( notifyCallback ),
- notify_callback_data_new( core, torrent_id ),
- notify_callback_data_free );
- }
-
- notify_notification_show( n, NULL );
+ const tr_torrent * tor = gtr_core_find_torrent( core, torrent_id );
+ const char * fmt = gtr_pref_string_get( PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_COMMAND );
+ char * cmd = g_strdup_printf( fmt, _( "Torrent Complete" ), ( tor ? tr_torrentName( tor ) : "" ) );
+ g_spawn_command_line_async( cmd, NULL );
+ g_free( cmd );
}
}
void
gtr_notify_torrent_added( const char * name )
{
- if( gtr_pref_flag_get( PREF_KEY_SHOW_DESKTOP_NOTIFICATION ) )
+ if( gtr_pref_flag_get( PREF_KEY_TORRENT_ADDED_NOTIFICATION_ENABLED ) )
{
- NotifyNotification * n = tr_notify_notification_new( _( "Torrent Added" ), name, NULL );
- addIcon( n );
- notify_notification_set_timeout( n, NOTIFY_EXPIRES_DEFAULT );
- notify_notification_show( n, NULL );
+ const char * fmt = gtr_pref_string_get( PREF_KEY_TORRENT_ADDED_NOTIFICATION_COMMAND );
+ char * cmd = g_strdup_printf( fmt, _( "Torrent Added" ), name );
+ g_spawn_command_line_async( cmd, NULL );
+ g_free( cmd );
}
}
-
-#endif
#include "tr-core.h"
-void gtr_notify_init( void );
-
void gtr_notify_torrent_added ( const char * name );
void gtr_notify_torrent_completed ( TrCore * core, int torrent_id );
static GtkWidget*
desktopPage( GObject * core )
{
- int row = 0;
+ int row = 0;
+ GtkWidget * t;
+ GtkWidget * w;
const char * s;
- GtkWidget * t;
- GtkWidget * w;
t = hig_workarea_create( );
hig_workarea_add_section_title( t, &row, _( "Desktop" ) );
- s = _( "Inhibit _hibernation when torrents are active" );
+ s = _( "_Inhibit hibernation when torrents are active" );
w = new_check_button( s, PREF_KEY_INHIBIT_HIBERNATION, core );
hig_workarea_add_wide_control( t, &row, w );
w = new_check_button( s, PREF_KEY_SHOW_TRAY_ICON, core );
hig_workarea_add_wide_control( t, &row, w );
- s = _( "Show _popup notifications" );
- w = new_check_button( s, PREF_KEY_SHOW_DESKTOP_NOTIFICATION, core );
+ hig_workarea_add_section_divider( t, &row );
+ hig_workarea_add_section_title ( t, &row, _( "Notification" ) );
+
+ s = _( "Show a notification when torrents are a_dded" );
+ w = new_check_button( s, PREF_KEY_TORRENT_ADDED_NOTIFICATION_ENABLED, 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 );
+ s = _( "Show a notification when torrents _finish" );
+ w = new_check_button( s, PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_ENABLED, core );
+ hig_workarea_add_wide_control( t, &row, w );
+
+ s = _( "Play a _sound when torrents finish" );
+ w = new_check_button( s, PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED, core );
hig_workarea_add_wide_control( t, &row, w );
-#endif
hig_workarea_finish( t, &row );
return t;
/* if you add a key here, you /must/ add its
* default in tr_prefs_init_defaults( void ) */
-#define PREF_KEY_USER_HAS_GIVEN_INFORMED_CONSENT "user-has-given-informed-consent"
-#define PREF_KEY_OPTIONS_PROMPT "show-options-window"
-#define PREF_KEY_OPEN_DIALOG_FOLDER "open-dialog-dir"
-#define PREF_KEY_INHIBIT_HIBERNATION "inhibit-desktop-hibernation"
-#define PREF_KEY_DIR_WATCH "watch-dir"
-#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_MORE_PEER_INFO "show-extra-peer-details"
-#define PREF_KEY_SHOW_BACKUP_TRACKERS "show-backup-trackers"
-#define PREF_KEY_SORT_MODE "sort-mode"
-#define PREF_KEY_SORT_REVERSED "sort-reversed"
-#define PREF_KEY_COMPACT_VIEW "compact-view"
-#define PREF_KEY_FILTERBAR "show-filterbar"
-#define PREF_KEY_STATUSBAR "show-statusbar"
-#define PREF_KEY_STATUSBAR_STATS "statusbar-stats"
-#define PREF_KEY_TOOLBAR "show-toolbar"
-#define PREF_KEY_BLOCKLIST_UPDATES_ENABLED "blocklist-updates-enabled"
-#define PREF_KEY_MAIN_WINDOW_HEIGHT "main-window-height"
-#define PREF_KEY_MAIN_WINDOW_WIDTH "main-window-width"
-#define PREF_KEY_MAIN_WINDOW_X "main-window-x"
-#define PREF_KEY_MAIN_WINDOW_Y "main-window-y"
-#define PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED "main-window-is-maximized"
+#define PREF_KEY_BLOCKLIST_UPDATES_ENABLED "blocklist-updates-enabled"
+#define PREF_KEY_COMPACT_VIEW "compact-view"
+#define PREF_KEY_DIR_WATCH_ENABLED "watch-dir-enabled"
+#define PREF_KEY_DIR_WATCH "watch-dir"
+#define PREF_KEY_FILTERBAR "show-filterbar"
+#define PREF_KEY_INHIBIT_HIBERNATION "inhibit-desktop-hibernation"
+#define PREF_KEY_MAIN_WINDOW_HEIGHT "main-window-height"
+#define PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED "main-window-is-maximized"
+#define PREF_KEY_MAIN_WINDOW_WIDTH "main-window-width"
+#define PREF_KEY_MAIN_WINDOW_X "main-window-x"
+#define PREF_KEY_MAIN_WINDOW_Y "main-window-y"
+#define PREF_KEY_OPEN_DIALOG_FOLDER "open-dialog-dir"
+#define PREF_KEY_OPTIONS_PROMPT "show-options-window"
+#define PREF_KEY_SHOW_BACKUP_TRACKERS "show-backup-trackers"
+#define PREF_KEY_SHOW_MORE_PEER_INFO "show-extra-peer-details"
+#define PREF_KEY_SHOW_MORE_TRACKER_INFO "show-tracker-scrapes"
+#define PREF_KEY_SHOW_TRAY_ICON "show-notification-area-icon"
+#define PREF_KEY_SORT_MODE "sort-mode"
+#define PREF_KEY_SORT_REVERSED "sort-reversed"
+#define PREF_KEY_STATUSBAR "show-statusbar"
+#define PREF_KEY_STATUSBAR_STATS "statusbar-stats"
+#define PREF_KEY_TOOLBAR "show-toolbar"
+#define PREF_KEY_TORRENT_ADDED_NOTIFICATION_COMMAND "torrent-added-notification-command"
+#define PREF_KEY_TORRENT_ADDED_NOTIFICATION_ENABLED "torrent-added-notification-enabled"
+#define PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_COMMAND "torrent-complete-notification-command"
+#define PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_ENABLED "torrent-complete-notification-enabled"
+#define PREF_KEY_TORRENT_COMPLETE_SOUND_COMMAND "torrent-complete-sound-command"
+#define PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED "torrent-complete-sound-enabled"
+#define PREF_KEY_USER_HAS_GIVEN_INFORMED_CONSENT "user-has-given-informed-consent"
enum
{
Requires: gtk2 >= @GTK_MINIMUM@
# OPTIONAL for the gtk+ client... see configure.ac for details
BuildRequires: dbus-glib-devel >= @DBUS_GLIB_MINIMUM@
-BuildRequires: libcanberra-devel >= @CANBERRA_MINIMUM@
-BuildRequires: libnotify-devel >= @LIBNOTIFY_MINIMUM@
Requires: dbus-glib >= @DBUS_GLIB_MINIMUM@
-Requires: libcanberra >= @CANBERRA_MINIMUM@
-Requires: libnotify >= @LIBNOTIFY_MINIMUM@
Provides: %{name}