mirror of
https://github.com/transmission/transmission
synced 2025-03-03 18:25:35 +00:00
make sure a info tab is loaded the first time it's shown
This commit is contained in:
parent
7bf62b1311
commit
41f29d45eb
7 changed files with 165 additions and 203 deletions
|
@ -31,12 +31,6 @@
|
|||
#define PIECES_CONTROL_PROGRESS 0
|
||||
#define PIECES_CONTROL_AVAILABLE 1
|
||||
|
||||
@interface InfoActivityViewController (Private)
|
||||
|
||||
- (void) resetInfo;
|
||||
|
||||
@end
|
||||
|
||||
@implementation InfoActivityViewController
|
||||
|
||||
- (id) init
|
||||
|
@ -60,7 +54,37 @@
|
|||
[fTorrents release];
|
||||
fTorrents = [torrents retain];
|
||||
|
||||
[self resetInfo];
|
||||
const NSUInteger count = [fTorrents count];
|
||||
if (count != 1)
|
||||
{
|
||||
if (count == 0)
|
||||
{
|
||||
[fHaveField setStringValue: @""];
|
||||
[fDownloadedTotalField setStringValue: @""];
|
||||
[fUploadedTotalField setStringValue: @""];
|
||||
[fFailedHashField setStringValue: @""];
|
||||
[fDateActivityField setStringValue: @""];
|
||||
[fRatioField setStringValue: @""];
|
||||
}
|
||||
|
||||
[fStateField setStringValue: @""];
|
||||
[fProgressField setStringValue: @""];
|
||||
|
||||
[fErrorMessageView setString: @""];
|
||||
|
||||
[fDateAddedField setStringValue: @""];
|
||||
[fDateCompletedField setStringValue: @""];
|
||||
|
||||
[fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_AVAILABLE];
|
||||
[fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_PROGRESS];
|
||||
[fPiecesControl setEnabled: NO];
|
||||
[fPiecesView setTorrent: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
[fDateAddedField setObjectValue: [torrent dateAdded]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) updateInfo
|
||||
|
@ -151,42 +175,3 @@
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation InfoActivityViewController (Private)
|
||||
|
||||
- (void) resetInfo
|
||||
{
|
||||
const NSUInteger count = [fTorrents count];
|
||||
if (count != 1)
|
||||
{
|
||||
if (count == 0)
|
||||
{
|
||||
[fHaveField setStringValue: @""];
|
||||
[fDownloadedTotalField setStringValue: @""];
|
||||
[fUploadedTotalField setStringValue: @""];
|
||||
[fFailedHashField setStringValue: @""];
|
||||
[fDateActivityField setStringValue: @""];
|
||||
[fRatioField setStringValue: @""];
|
||||
}
|
||||
|
||||
[fStateField setStringValue: @""];
|
||||
[fProgressField setStringValue: @""];
|
||||
|
||||
[fErrorMessageView setString: @""];
|
||||
|
||||
[fDateAddedField setStringValue: @""];
|
||||
[fDateCompletedField setStringValue: @""];
|
||||
|
||||
[fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_AVAILABLE];
|
||||
[fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_PROGRESS];
|
||||
[fPiecesControl setEnabled: NO];
|
||||
[fPiecesView setTorrent: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
[fDateAddedField setObjectValue: [torrent dateAdded]];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
@interface InfoFileViewController (Private)
|
||||
|
||||
- (void) resetInfo;
|
||||
|
||||
- (BOOL) canQuickLookFile: (FileListNode *) item;
|
||||
|
||||
@end
|
||||
|
@ -64,7 +62,20 @@
|
|||
[fTorrents release];
|
||||
fTorrents = [torrents retain];
|
||||
|
||||
[self resetInfo];
|
||||
[fFileFilterField setStringValue: @""];
|
||||
|
||||
if ([fTorrents count] == 1)
|
||||
{
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
|
||||
[fFileController setTorrent: torrent];
|
||||
[fFileFilterField setEnabled: [torrent isFolder]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[fFileController setTorrent: nil];
|
||||
[fFileFilterField setEnabled: NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) updateInfo
|
||||
|
@ -147,24 +158,6 @@
|
|||
|
||||
@implementation InfoFileViewController (Private)
|
||||
|
||||
- (void) resetInfo
|
||||
{
|
||||
[fFileFilterField setStringValue: @""];
|
||||
|
||||
if ([fTorrents count] == 1)
|
||||
{
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
|
||||
[fFileController setTorrent: torrent];
|
||||
[fFileFilterField setEnabled: [torrent isFolder]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[fFileController setTorrent: nil];
|
||||
[fFileFilterField setEnabled: NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) canQuickLookFile: (FileListNode *) item
|
||||
{
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
|
|
|
@ -27,12 +27,6 @@
|
|||
#import "NSStringAdditions.h"
|
||||
#import "Torrent.h"
|
||||
|
||||
@interface InfoGeneralViewController (Private)
|
||||
|
||||
- (void) resetInfo;
|
||||
|
||||
@end
|
||||
|
||||
@implementation InfoGeneralViewController
|
||||
|
||||
- (id) init
|
||||
|
@ -74,45 +68,6 @@
|
|||
[fTorrents release];
|
||||
fTorrents = [torrents retain];
|
||||
|
||||
[self resetInfo];
|
||||
}
|
||||
|
||||
- (void) updateInfo
|
||||
{
|
||||
if ([fTorrents count] != 1)
|
||||
return;
|
||||
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
|
||||
NSString * location = [torrent dataLocation];
|
||||
[fDataLocationField setStringValue: location ? [location stringByAbbreviatingWithTildeInPath] : @""];
|
||||
[fDataLocationField setToolTip: location ? location : @""];
|
||||
|
||||
[fRevealDataButton setHidden: !location];
|
||||
}
|
||||
|
||||
- (void) revealDataFile: (id) sender
|
||||
{
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
NSString * location = [torrent dataLocation];
|
||||
if (!location)
|
||||
return;
|
||||
|
||||
if ([NSApp isOnSnowLeopardOrBetter])
|
||||
{
|
||||
NSURL * file = [NSURL fileURLWithPath: location];
|
||||
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: [NSArray arrayWithObject: file]];
|
||||
}
|
||||
else
|
||||
[[NSWorkspace sharedWorkspace] selectFile: location inFileViewerRootedAtPath: nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation InfoGeneralViewController (Private)
|
||||
|
||||
- (void) resetInfo
|
||||
{
|
||||
if ([fTorrents count] == 1)
|
||||
{
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
|
@ -153,4 +108,34 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void) updateInfo
|
||||
{
|
||||
if ([fTorrents count] != 1)
|
||||
return;
|
||||
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
|
||||
NSString * location = [torrent dataLocation];
|
||||
[fDataLocationField setStringValue: location ? [location stringByAbbreviatingWithTildeInPath] : @""];
|
||||
[fDataLocationField setToolTip: location ? location : @""];
|
||||
|
||||
[fRevealDataButton setHidden: !location];
|
||||
}
|
||||
|
||||
- (void) revealDataFile: (id) sender
|
||||
{
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
NSString * location = [torrent dataLocation];
|
||||
if (!location)
|
||||
return;
|
||||
|
||||
if ([NSApp isOnSnowLeopardOrBetter])
|
||||
{
|
||||
NSURL * file = [NSURL fileURLWithPath: location];
|
||||
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: [NSArray arrayWithObject: file]];
|
||||
}
|
||||
else
|
||||
[[NSWorkspace sharedWorkspace] selectFile: location inFileViewerRootedAtPath: nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -35,12 +35,6 @@
|
|||
|
||||
#define INVALID -99
|
||||
|
||||
@interface InfoOptionsViewController (Private)
|
||||
|
||||
- (void) resetInfo;
|
||||
|
||||
@end
|
||||
|
||||
@implementation InfoOptionsViewController
|
||||
|
||||
- (id) init
|
||||
|
@ -64,7 +58,37 @@
|
|||
[fTorrents release];
|
||||
fTorrents = [torrents retain];
|
||||
|
||||
[self resetInfo];
|
||||
if ([fTorrents count] == 0)
|
||||
{
|
||||
[fUploadLimitCheck setEnabled: NO];
|
||||
[fUploadLimitCheck setState: NSOffState];
|
||||
[fUploadLimitField setEnabled: NO];
|
||||
[fUploadLimitLabel setEnabled: NO];
|
||||
[fUploadLimitField setStringValue: @""];
|
||||
|
||||
[fDownloadLimitCheck setEnabled: NO];
|
||||
[fDownloadLimitCheck setState: NSOffState];
|
||||
[fDownloadLimitField setEnabled: NO];
|
||||
[fDownloadLimitLabel setEnabled: NO];
|
||||
[fDownloadLimitField setStringValue: @""];
|
||||
|
||||
[fGlobalLimitCheck setEnabled: NO];
|
||||
[fGlobalLimitCheck setState: NSOffState];
|
||||
|
||||
[fPriorityPopUp setEnabled: NO];
|
||||
[fPriorityPopUp selectItemAtIndex: -1];
|
||||
|
||||
[fRatioPopUp setEnabled: NO];
|
||||
[fRatioPopUp selectItemAtIndex: -1];
|
||||
[fRatioLimitField setHidden: YES];
|
||||
[fRatioLimitField setStringValue: @""];
|
||||
|
||||
[fPeersConnectField setEnabled: NO];
|
||||
[fPeersConnectField setStringValue: @""];
|
||||
[fPeersConnectLabel setEnabled: NO];
|
||||
}
|
||||
else
|
||||
[self updateOptions];
|
||||
}
|
||||
|
||||
- (void) updateOptions
|
||||
|
@ -351,39 +375,4 @@
|
|||
|
||||
@implementation InfoOptionsViewController (Private)
|
||||
|
||||
- (void) resetInfo
|
||||
{
|
||||
if ([fTorrents count] == 0)
|
||||
{
|
||||
[fUploadLimitCheck setEnabled: NO];
|
||||
[fUploadLimitCheck setState: NSOffState];
|
||||
[fUploadLimitField setEnabled: NO];
|
||||
[fUploadLimitLabel setEnabled: NO];
|
||||
[fUploadLimitField setStringValue: @""];
|
||||
|
||||
[fDownloadLimitCheck setEnabled: NO];
|
||||
[fDownloadLimitCheck setState: NSOffState];
|
||||
[fDownloadLimitField setEnabled: NO];
|
||||
[fDownloadLimitLabel setEnabled: NO];
|
||||
[fDownloadLimitField setStringValue: @""];
|
||||
|
||||
[fGlobalLimitCheck setEnabled: NO];
|
||||
[fGlobalLimitCheck setState: NSOffState];
|
||||
|
||||
[fPriorityPopUp setEnabled: NO];
|
||||
[fPriorityPopUp selectItemAtIndex: -1];
|
||||
|
||||
[fRatioPopUp setEnabled: NO];
|
||||
[fRatioPopUp selectItemAtIndex: -1];
|
||||
[fRatioLimitField setHidden: YES];
|
||||
[fRatioLimitField setStringValue: @""];
|
||||
|
||||
[fPeersConnectField setEnabled: NO];
|
||||
[fPeersConnectField setStringValue: @""];
|
||||
[fPeersConnectLabel setEnabled: NO];
|
||||
}
|
||||
else
|
||||
[self updateOptions];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -451,7 +451,6 @@
|
|||
fPeers = nil;
|
||||
[fPeerTable reloadData];
|
||||
|
||||
#warning should be reset when != to 1?
|
||||
[fConnectedPeersField setStringValue: @""];
|
||||
}
|
||||
else
|
||||
|
@ -552,7 +551,7 @@
|
|||
//sort by IP after primary sort
|
||||
if (useSecond)
|
||||
{
|
||||
#warning when 10.6-only, replate with sortDescriptorWithKey:ascending:selector:
|
||||
#warning when 10.6-only, replace with sortDescriptorWithKey:ascending:selector:
|
||||
NSSortDescriptor * secondDescriptor = [[NSSortDescriptor alloc] initWithKey: @"IP" ascending: asc
|
||||
selector: @selector(compareNumeric:)];
|
||||
[descriptors addObject: secondDescriptor];
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
|
||||
@interface InfoTrackersViewController (Private)
|
||||
|
||||
- (void) resetInfo;
|
||||
|
||||
- (void) addTrackers;
|
||||
- (void) removeTrackers;
|
||||
|
||||
|
@ -72,7 +70,32 @@
|
|||
[fTorrents release];
|
||||
fTorrents = [torrents retain];
|
||||
|
||||
[self resetInfo];
|
||||
const NSUInteger numberSelected = [fTorrents count];
|
||||
if (numberSelected != 1)
|
||||
{
|
||||
if (numberSelected == 0)
|
||||
{
|
||||
[fTrackers release];
|
||||
fTrackers = nil;
|
||||
|
||||
[fTrackerTable setTrackers: nil];
|
||||
[fTrackerTable reloadData];
|
||||
}
|
||||
|
||||
[fTrackerTable setTorrent: nil];
|
||||
|
||||
[fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_ADD_TAG];
|
||||
[fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
|
||||
}
|
||||
else
|
||||
{
|
||||
[fTrackerTable setTorrent: [fTorrents objectAtIndex: 0]];
|
||||
|
||||
[fTrackerAddRemoveControl setEnabled: YES forSegment: TRACKER_ADD_TAG];
|
||||
[fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
|
||||
}
|
||||
|
||||
[fTrackerTable deselectAll: self];
|
||||
}
|
||||
|
||||
- (void) updateInfo
|
||||
|
@ -223,36 +246,6 @@
|
|||
|
||||
@implementation InfoTrackersViewController (Private)
|
||||
|
||||
- (void) resetInfo
|
||||
{
|
||||
const NSUInteger numberSelected = [fTorrents count];
|
||||
if (numberSelected != 1)
|
||||
{
|
||||
if (numberSelected == 0)
|
||||
{
|
||||
[fTrackers release];
|
||||
fTrackers = nil;
|
||||
|
||||
[fTrackerTable setTrackers: nil];
|
||||
[fTrackerTable reloadData];
|
||||
}
|
||||
|
||||
[fTrackerTable setTorrent: nil];
|
||||
|
||||
[fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_ADD_TAG];
|
||||
[fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
|
||||
}
|
||||
else
|
||||
{
|
||||
[fTrackerTable setTorrent: [fTorrents objectAtIndex: 0]];
|
||||
|
||||
[fTrackerAddRemoveControl setEnabled: YES forSegment: TRACKER_ADD_TAG];
|
||||
[fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
|
||||
}
|
||||
|
||||
[fTrackerTable deselectAll: self];
|
||||
}
|
||||
|
||||
#warning doesn't like blank addresses
|
||||
- (void) addTrackers
|
||||
{
|
||||
|
|
|
@ -68,16 +68,7 @@ typedef enum
|
|||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super initWithWindowNibName: @"InfoWindow"]))
|
||||
{
|
||||
fGeneralViewController = [[InfoGeneralViewController alloc] init];
|
||||
fActivityViewController = [[InfoActivityViewController alloc] init];
|
||||
fTrackersViewController = [[InfoTrackersViewController alloc] init];
|
||||
fPeersViewController = [[InfoPeersViewController alloc] init];
|
||||
fFileViewController = [[InfoFileViewController alloc] init];
|
||||
fOptionsViewController = [[InfoOptionsViewController alloc] init];
|
||||
}
|
||||
|
||||
self = [super initWithWindowNibName: @"InfoWindow"];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -243,8 +234,6 @@ typedef enum
|
|||
if (fCurrentTabTag == oldTabTag)
|
||||
return;
|
||||
|
||||
[self updateInfoStats];
|
||||
|
||||
//take care of old view
|
||||
CGFloat oldHeight = 0;
|
||||
NSString * oldResizeSaveKey = nil;
|
||||
|
@ -287,37 +276,53 @@ typedef enum
|
|||
}
|
||||
|
||||
//set new tab item
|
||||
NSView * view = [self tabViewForTag: fCurrentTabTag];
|
||||
|
||||
#warning get titles from view controller?
|
||||
NSString * resizeSaveKey = nil;
|
||||
NSString * identifier, * title;
|
||||
switch (fCurrentTabTag)
|
||||
{
|
||||
case TAB_GENERAL_TAG:
|
||||
if (!fGeneralViewController)
|
||||
fGeneralViewController = [[InfoGeneralViewController alloc] init];
|
||||
|
||||
identifier = TAB_INFO_IDENT;
|
||||
title = NSLocalizedString(@"General Info", "Inspector -> title");
|
||||
break;
|
||||
case TAB_ACTIVITY_TAG:
|
||||
if (!fActivityViewController)
|
||||
fActivityViewController = [[InfoActivityViewController alloc] init];
|
||||
|
||||
identifier = TAB_ACTIVITY_IDENT;
|
||||
title = NSLocalizedString(@"Activity", "Inspector -> title");
|
||||
break;
|
||||
case TAB_TRACKERS_TAG:
|
||||
if (!fTrackersViewController)
|
||||
fTrackersViewController = [[InfoTrackersViewController alloc] init];
|
||||
|
||||
identifier = TAB_TRACKER_IDENT;
|
||||
title = NSLocalizedString(@"Trackers", "Inspector -> title");
|
||||
resizeSaveKey = @"InspectorContentHeightTracker";
|
||||
break;
|
||||
case TAB_PEERS_TAG:
|
||||
if (!fPeersViewController)
|
||||
fPeersViewController = [[InfoPeersViewController alloc] init];
|
||||
|
||||
identifier = TAB_PEERS_IDENT;
|
||||
title = NSLocalizedString(@"Peers", "Inspector -> title");
|
||||
resizeSaveKey = @"InspectorContentHeightPeers";
|
||||
break;
|
||||
case TAB_FILE_TAG:
|
||||
if (!fFileViewController)
|
||||
fFileViewController = [[InfoFileViewController alloc] init];
|
||||
|
||||
identifier = TAB_FILES_IDENT;
|
||||
title = NSLocalizedString(@"Files", "Inspector -> title");
|
||||
resizeSaveKey = @"InspectorContentHeightFiles";
|
||||
break;
|
||||
case TAB_OPTIONS_TAG:
|
||||
if (!fOptionsViewController)
|
||||
fOptionsViewController = [[InfoOptionsViewController alloc] init];
|
||||
|
||||
identifier = TAB_OPTIONS_IDENT;
|
||||
title = NSLocalizedString(@"Options", "Inspector -> title");
|
||||
break;
|
||||
|
@ -335,6 +340,18 @@ typedef enum
|
|||
//selected tab item
|
||||
[(InfoTabButtonCell *)[fTabMatrix selectedCell] setSelectedTab: YES];
|
||||
|
||||
NSView * view = [self tabViewForTag: fCurrentTabTag];
|
||||
|
||||
//if view was just loaded - has to be a better way
|
||||
[fGeneralViewController setInfoForTorrents: fTorrents];
|
||||
[fActivityViewController setInfoForTorrents: fTorrents];
|
||||
[fTrackersViewController setInfoForTorrents: fTorrents];
|
||||
[fPeersViewController setInfoForTorrents: fTorrents];
|
||||
[fFileViewController setInfoForTorrents: fTorrents];
|
||||
[fOptionsViewController setInfoForTorrents: fTorrents];
|
||||
|
||||
[self updateInfoStats];
|
||||
|
||||
NSRect windowRect = [window frame], viewRect = [view frame];
|
||||
|
||||
if (resizeSaveKey)
|
||||
|
@ -367,6 +384,7 @@ typedef enum
|
|||
|
||||
[window setFrame: windowRect display: YES animate: oldTabTag != INVALID];
|
||||
[[window contentView] addSubview: view];
|
||||
|
||||
[view setHidden: NO];
|
||||
|
||||
if ([NSApp isOnSnowLeopardOrBetter] && (fCurrentTabTag == TAB_FILE_TAG || oldTabTag == TAB_FILE_TAG)
|
||||
|
|
Loading…
Reference in a new issue