From aefd0f4df22927b443fd6040b1effb785af53eec Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 30 Mar 2009 22:18:25 +0000 Subject: [PATCH] only show a Growl notification when the speed limit is auto-enable/disabled --- macosx/Controller.h | 2 +- macosx/Controller.m | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/macosx/Controller.h b/macosx/Controller.h index 5f2fbc2b8..77e2dad5b 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -211,7 +211,7 @@ typedef enum - (void) toggleSpeedLimit: (id) sender; - (void) speedLimitChanged: (id) sender; -- (void) altSpeedToggledCallbackIsLimited: (NSNumber *) limited; +- (void) altSpeedToggledCallbackIsLimited: (NSDictionary *) dict; - (void) setLimitGlobalEnabled: (id) sender; - (void) setQuickLimitGlobal: (id) sender; diff --git a/macosx/Controller.m b/macosx/Controller.m index baab261b8..c1c930190 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -145,8 +145,10 @@ typedef enum static void altSpeedToggledCallback(tr_session * handle UNUSED, tr_bool active, tr_bool byUser, void * controller) { + NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [[NSNumber alloc] initWithBool: active], @"Active", + [[NSNumber alloc] initWithBool: byUser], @"ByUser", nil]; [(Controller *)controller performSelectorOnMainThread: @selector(altSpeedToggledCallbackIsLimited:) - withObject: [[NSNumber alloc] initWithBool: active] waitUntilDone: NO]; + withObject: dict waitUntilDone: NO]; } static tr_rpc_callback_status rpcCallback(tr_session * handle UNUSED, tr_rpc_callback_type type, struct tr_torrent * torrentStruct, void * controller) @@ -2322,22 +2324,22 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy [self updateSpeedFieldsToolTips]; } -//limited has been retained -- (void) altSpeedToggledCallbackIsLimited: (NSNumber *) limited +//dict has been retained +- (void) altSpeedToggledCallbackIsLimited: (NSDictionary *) dict { - const BOOL isLimited = [limited boolValue]; + const BOOL isLimited = [[dict objectForKey: @"Active"] boolValue]; [fDefaults setBool: isLimited forKey: @"SpeedLimit"]; [self updateSpeedFieldsToolTips]; - #warning don't show on startup or on manual changed - [GrowlApplicationBridge notifyWithTitle: isLimited - ? NSLocalizedString(@"Speed Limit Auto Enabled", "Growl notification title") - : NSLocalizedString(@"Speed Limit Auto Disabled", "Growl notification title") - description: NSLocalizedString(@"Bandwidth settings changed", "Growl notification description") - notificationName: GROWL_AUTO_SPEED_LIMIT iconData: nil priority: 0 isSticky: NO clickContext: nil]; + if (![[dict objectForKey: @"ByUser"] boolValue]) + [GrowlApplicationBridge notifyWithTitle: isLimited + ? NSLocalizedString(@"Speed Limit Auto Enabled", "Growl notification title") + : NSLocalizedString(@"Speed Limit Auto Disabled", "Growl notification title") + description: NSLocalizedString(@"Bandwidth settings changed", "Growl notification description") + notificationName: GROWL_AUTO_SPEED_LIMIT iconData: nil priority: 0 isSticky: NO clickContext: nil]; - [limited release]; + [dict release]; } - (void) setLimitGlobalEnabled: (id) sender -- 2.40.0