diff --git a/macosx/Controller.h b/macosx/Controller.h index 83e74a344..d289e6add 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -205,6 +205,8 @@ - (void) sleepCallBack: (natural_t) messageType argument: (void *) messageArgument; +- (void) torrentTableViewSelectionDidChange: (NSNotification *) notification; + - (void) toggleSmallView: (id) sender; - (void) toggleStatusBar: (id) sender; diff --git a/macosx/Controller.m b/macosx/Controller.m index 5f8447d2e..cb2505a7c 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -391,6 +391,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [nc addObserver: self selector: @selector(torrentRestartedDownloading:) name: @"TorrentRestartedDownloading" object: nil]; + //avoids need of setting delegate + [nc addObserver: self selector: @selector(torrentTableViewSelectionDidChange:) + name: NSTableViewSelectionDidChangeNotification object: fTableView]; + [nc addObserver: self selector: @selector(updateControlTint:) name: NSControlTintDidChangeNotification object: nil]; @@ -2208,8 +2212,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy return YES; } -#warning get rid of delegate and make a notification -- (void) tableViewSelectionDidChange: (NSNotification *) notification +- (void) torrentTableViewSelectionDidChange: (NSNotification *) notification { [fInfoController updateInfoForTorrents: [fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]]]; } diff --git a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib index cf1959d2b..7f29175ec 100644 Binary files a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib and b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index b46e05a4f..e6b295007 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -76,6 +76,8 @@ [NSFont messageFontOfSize: 9.0], NSFontAttributeName, nil]; fDefaults = [NSUserDefaults standardUserDefaults]; + + [self setDelegate: self]; } return self; @@ -351,55 +353,45 @@ [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateStats" object: nil]; } -#warning only update shown -- (void) drawRect: (NSRect) r +- (void) drawRow: (int) row clipRect: (NSRect) rect { - NSRect rect; - Torrent * torrent; - NSImage * image; - BOOL smallView = [fDefaults boolForKey: @"SmallView"]; + [super drawRow: row clipRect: rect]; - [super drawRect: r]; + Torrent * torrent = [fTorrents objectAtIndex: row]; - int i; - for (i = 0; i < [fTorrents count]; i++) + //pause/resume icon + NSImage * pauseImage = nil; + NSRect pauseRect = [self pauseRectForRow: row]; + if ([torrent isActive]) { - torrent = [fTorrents objectAtIndex: i]; - rect = [self pauseRectForRow: i]; - - //pause/resume icon - image = nil; - if ([torrent isActive]) - { - if (![torrent isChecking]) - image = NSPointInRect(fClickPoint, rect) ? fPauseOnIcon : fPauseOffIcon; - } - else if ([torrent isPaused]) - { - if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask && [fDefaults boolForKey: @"Queue"]) - image = NSPointInRect(fClickPoint, rect) ? fResumeNoWaitOnIcon : fResumeNoWaitOffIcon; - else if ([torrent waitingToStart]) - image = NSPointInRect(fClickPoint, rect) ? fPauseOnIcon : fPauseOffIcon; - else - image = NSPointInRect(fClickPoint, rect) ? fResumeOnIcon : fResumeOffIcon; - } - else; - - if (image) - [image compositeToPoint: NSMakePoint(rect.origin.x, NSMaxY(rect)) operation: NSCompositeSourceOver]; - - //reveal icon - rect = [self revealRectForRow: i]; - image = NSPointInRect(fClickPoint, rect) ? fRevealOnIcon : fRevealOffIcon; - [image compositeToPoint: NSMakePoint(rect.origin.x, NSMaxY(rect)) operation: NSCompositeSourceOver]; - - //action icon - if (!smallView) - { - rect = [self actionRectForRow: i]; - image = NSPointInRect(fClickPoint, rect) ? fActionOnIcon : fActionOffIcon; - [image compositeToPoint: NSMakePoint(rect.origin.x, NSMaxY(rect)) operation: NSCompositeSourceOver]; - } + if (![torrent isChecking]) + pauseImage = NSPointInRect(fClickPoint, pauseRect) ? fPauseOnIcon : fPauseOffIcon; + } + else if ([torrent isPaused]) + { + if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask && [fDefaults boolForKey: @"Queue"]) + pauseImage = NSPointInRect(fClickPoint, pauseRect) ? fResumeNoWaitOnIcon : fResumeNoWaitOffIcon; + else if ([torrent waitingToStart]) + pauseImage = NSPointInRect(fClickPoint, pauseRect) ? fPauseOnIcon : fPauseOffIcon; + else + pauseImage = NSPointInRect(fClickPoint, pauseRect) ? fResumeOnIcon : fResumeOffIcon; + } + else; + + if (pauseImage) + [pauseImage compositeToPoint: NSMakePoint(pauseRect.origin.x, NSMaxY(pauseRect)) operation: NSCompositeSourceOver]; + + //reveal icon + NSRect revealRect = [self revealRectForRow: row]; + NSImage * revealImage = NSPointInRect(fClickPoint, revealRect) ? fRevealOnIcon : fRevealOffIcon; + [revealImage compositeToPoint: NSMakePoint(revealRect.origin.x, NSMaxY(revealRect)) operation: NSCompositeSourceOver]; + + //action icon + if (![fDefaults boolForKey: @"SmallView"]) + { + NSRect actionRect = [self actionRectForRow: row]; + NSImage * actionImage = NSPointInRect(fClickPoint, actionRect) ? fActionOnIcon : fActionOffIcon; + [actionImage compositeToPoint: NSMakePoint(actionRect.origin.x, NSMaxY(actionRect)) operation: NSCompositeSourceOver]; } }