diff --git a/gtk/notify.c b/gtk/notify.c index c0a5ec1d1..1d39794a1 100644 --- a/gtk/notify.c +++ b/gtk/notify.c @@ -60,20 +60,27 @@ notifyCallback( NotifyNotification * n UNUSED, void tr_notify_send( TrTorrent *tor ) { - const tr_info * info = tr_torrent_info( tor ); - NotifyNotification * n = notify_notification_new( _( - "Torrent Complete" ), - info->name, - "transmission", NULL ); + if( pref_flag_get( PREF_KEY_SHOW_DESKTOP_NOTIFICATION ) ) + { + const tr_info * info = tr_torrent_info( tor ); + NotifyNotification * n; - if( info->fileCount == 1 ) - notify_notification_add_action( n, "file", _( "Open File" ), - NOTIFY_ACTION_CALLBACK( - notifyCallback ), tor, NULL ); - notify_notification_add_action( n, "folder", _( "Open Folder" ), - NOTIFY_ACTION_CALLBACK( - notifyCallback ), tor, NULL ); - notify_notification_show( n, NULL ); + n = notify_notification_new( _( "Torrent Complete" ), + info->name, + "transmission", NULL ); + + if( info->fileCount == 1 ) + notify_notification_add_action( + n, "file", _( "Open File" ), + NOTIFY_ACTION_CALLBACK( notifyCallback ), tor, + NULL ); + + notify_notification_add_action( + n, "folder", _( "Open Folder" ), + NOTIFY_ACTION_CALLBACK( notifyCallback ), tor, NULL ); + + notify_notification_show( n, NULL ); + } } #endif diff --git a/gtk/tr-prefs.c b/gtk/tr-prefs.c index ca7277951..895b20ca2 100644 --- a/gtk/tr-prefs.c +++ b/gtk/tr-prefs.c @@ -39,7 +39,7 @@ tr_prefs_init_global( void ) cf_check_older_configs( ); -#if HAVE_GIO +#ifdef HAVE_GIO str = NULL; if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DESKTOP ); if( !str ) str = tr_getDefaultDownloadDir( ); @@ -56,6 +56,7 @@ tr_prefs_init_global( void ) pref_flag_set_default ( PREF_KEY_FILTERBAR, TRUE ); pref_flag_set_default ( PREF_KEY_STATUSBAR, TRUE ); pref_flag_set_default ( PREF_KEY_SHOW_TRAY_ICON, FALSE ); + pref_flag_set_default ( PREF_KEY_SHOW_DESKTOP_NOTIFICATION, TRUE ); pref_string_set_default ( PREF_KEY_STATUSBAR_STATS, "total-ratio" ); pref_flag_set_default ( PREF_KEY_SCHED_LIMIT_ENABLED, FALSE ); @@ -350,6 +351,10 @@ desktopPage( GObject * core ) w = new_check_button( s, PREF_KEY_SHOW_TRAY_ICON, core ); hig_workarea_add_wide_control( t, &row, w ); + s = _( "Show desktop _notifications" ); + w = new_check_button( s, PREF_KEY_SHOW_DESKTOP_NOTIFICATION, core ); + hig_workarea_add_wide_control( t, &row, w ); + hig_workarea_finish( t, &row ); return t; } diff --git a/gtk/tr-prefs.h b/gtk/tr-prefs.h index 95d312a18..d9850630d 100644 --- a/gtk/tr-prefs.h +++ b/gtk/tr-prefs.h @@ -32,6 +32,7 @@ GtkWidget * tr_prefs_dialog_new( GObject * core, #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_START "start-added-torrents" #define PREF_KEY_TRASH_ORIGINAL "trash-original-torrent-files" #define PREF_KEY_ASKQUIT "prompt-before-exit"