From 64e82dad7106cb9807b58ee06ecea756848821d2 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 24 Feb 2008 16:10:18 +0000 Subject: [PATCH] (gtk) add prefs to toggle libnotify notification --- gtk/tr_prefs.c | 16 ++++++++++++---- gtk/tr_prefs.h | 1 + gtk/tr_torrent.c | 5 ++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/gtk/tr_prefs.c b/gtk/tr_prefs.c index db86a5d15..cabbff0ae 100644 --- a/gtk/tr_prefs.c +++ b/gtk/tr_prefs.c @@ -53,6 +53,8 @@ tr_prefs_init_global( void ) pref_int_set_default ( PREF_KEY_PORT, TR_DEFAULT_PORT ); + pref_flag_set_default ( PREF_KEY_NOTIFY, TRUE ); + pref_flag_set_default ( PREF_KEY_NAT, TRUE ); pref_flag_set_default ( PREF_KEY_PEX, TRUE ); pref_flag_set_default ( PREF_KEY_SYSTRAY, TRUE ); @@ -233,14 +235,11 @@ torrentPage( GObject * core ) GtkWidget * w; t = hig_workarea_create( ); - hig_workarea_add_section_title( t, &row, _( "Location" ) ); + hig_workarea_add_section_title( t, &row, _( "Adding" ) ); w = new_path_chooser_button( PREF_KEY_DIR_DEFAULT, core ); hig_workarea_add_row( t, &row, _( "Default download _location:" ), w, NULL ); - hig_workarea_add_section_divider( t, &row ); - hig_workarea_add_section_title( t, &row, _( "Adding Torrents" ) ); - s = _( "Show _options dialog" ); w = new_check_button( s, PREF_KEY_OPTIONS_PROMPT, core ); hig_workarea_add_wide_control( t, &row, w ); @@ -253,6 +252,15 @@ torrentPage( GObject * core ) w = new_check_button( s, PREF_KEY_DELETE_ORIGINAL, core ); hig_workarea_add_wide_control( t, &row, w ); +#ifdef HAVE_LIBNOTIFY + hig_workarea_add_section_divider( t, &row ); + hig_workarea_add_section_title( t, &row, _( "Notification" ) ); + + s = _( "_Popup message when a torrent finishes" ); + w = new_check_button( s, PREF_KEY_NOTIFY, core ); + hig_workarea_add_wide_control( t, &row, w ); +#endif + hig_workarea_finish( t, &row ); return t; } diff --git a/gtk/tr_prefs.h b/gtk/tr_prefs.h index 63d052db2..52a8cd1d1 100644 --- a/gtk/tr_prefs.h +++ b/gtk/tr_prefs.h @@ -35,6 +35,7 @@ GtkWidget * tr_prefs_dialog_new( GObject * core, GtkWindow * parent ); #define PREF_KEY_ASKQUIT "prompt-before-exit" #define PREF_KEY_ENCRYPTED_ONLY "encrypted-connections-only" #define PREF_KEY_MSGLEVEL "debug-message-level" +#define PREF_KEY_NOTIFY "notify-when-complete" #define PREF_KEY_SORT_MODE "sort-mode" #define PREF_KEY_SORT_REVERSED "sort-reversed" #define PREF_KEY_MINIMAL_VIEW "minimal-view" diff --git a/gtk/tr_torrent.c b/gtk/tr_torrent.c index fce411cf5..54ecc305a 100644 --- a/gtk/tr_torrent.c +++ b/gtk/tr_torrent.c @@ -166,8 +166,8 @@ tr_torrent_stop( TrTorrent * self ) static gboolean notifyInMainThread( gpointer user_data ) { -g_message( "calling tr_notify_send on %p", user_data ); - tr_notify_send( TR_TORRENT( user_data ) ); + if( pref_flag_get( PREF_KEY_NOTIFY ) ) + tr_notify_send( TR_TORRENT( user_data ) ); return FALSE; } static void @@ -175,7 +175,6 @@ statusChangedCallback( tr_torrent * tor UNUSED, cp_status_t status, void * user_data ) { -g_message( "status changed! new status is %d, user_data is %p", status, user_data ); if( status == TR_CP_COMPLETE ) g_idle_add( notifyInMainThread, user_data ); }