1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

attempt to decrease memory usage a bit when window/application is hidden

This commit is contained in:
Mitchell Livingston 2007-09-26 04:12:57 +00:00
parent f20358927b
commit 9dec223018
3 changed files with 40 additions and 27 deletions

View file

@ -177,6 +177,8 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
{
fLib = tr_init("macosx");
[NSApp setDelegate: self];
fTorrents = [[NSMutableArray alloc] init];
fDisplayedTorrents = [[NSMutableArray alloc] init];
@ -1450,30 +1452,36 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
- (void) updateUI
{
[fTorrents makeObjectsPerformSelector: @selector(update)];
//resort if necessary or just update the table
NSString * sortType = [fDefaults stringForKey: @"Sort"];
if ([sortType isEqualToString: SORT_PROGRESS] || [sortType isEqualToString: SORT_STATE]
|| [sortType isEqualToString: SORT_TRACKER])
[self sortTorrents];
else
[fTableView reloadData];
//update the global DL/UL rates
if (![fStatusBar isHidden])
if (![NSApp isHidden])
{
float downloadRate, uploadRate;
tr_torrentRates(fLib, & downloadRate, & uploadRate);
[fTotalDLField setStringValue: [NSLocalizedString(@"Total DL: ", "Status bar -> total download")
stringByAppendingString: [NSString stringForSpeed: downloadRate]]];
[fTotalULField setStringValue: [NSLocalizedString(@"Total UL: ", "Status bar -> total upload")
stringByAppendingString: [NSString stringForSpeed: uploadRate]]];
}
if ([fWindow isVisible])
{
//resort if necessary or just update the table
NSString * sortType = [fDefaults stringForKey: @"Sort"];
if ([sortType isEqualToString: SORT_PROGRESS] || [sortType isEqualToString: SORT_STATE]
|| [sortType isEqualToString: SORT_TRACKER])
[self sortTorrents];
else
[fTableView reloadData];
//update the global DL/UL rates
if (![fStatusBar isHidden])
{
float downloadRate, uploadRate;
tr_torrentRates(fLib, & downloadRate, & uploadRate);
[fTotalDLField setStringValue: [NSLocalizedString(@"Total DL: ", "Status bar -> total download")
stringByAppendingString: [NSString stringForSpeed: downloadRate]]];
[fTotalULField setStringValue: [NSLocalizedString(@"Total UL: ", "Status bar -> total upload")
stringByAppendingString: [NSString stringForSpeed: uploadRate]]];
}
}
//update non-constant parts of info window
if ([[fInfoController window] isVisible])
[fInfoController updateInfoStats];
//update non-constant parts of info window
if ([[fInfoController window] isVisible])
[fInfoController updateInfoStats];
}
//badge dock
[fBadger updateBadge];
@ -3219,6 +3227,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[fStatusBar setNeedsDisplay: YES];
[fBadger clearCompleted];
[self updateUI];
}
- (void) windowDidResignKey: (NSNotification *) notification
@ -3258,6 +3267,11 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[fSearchFilterField setHidden: !show];
}
- (void) applicationWillUnhide: (NSNotification *) notification
{
[self updateUI];
}
- (void) linkHomepage: (id) sender
{
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: WEBSITE_URL]];

View file

@ -388,11 +388,11 @@
if (have == 0)
[fHaveField setStringValue: [NSString stringForFileSize: 0]];
else if (have == haveVerified)
[fHaveField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ verified", "Inspector -> Activity tab -> have"),
[NSString stringForFileSize: haveVerified]]];
[fHaveField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ verified",
"Inspector -> Activity tab -> have"), [NSString stringForFileSize: haveVerified]]];
else
[fHaveField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ (%@ verified)", "Inspector -> Activity tab -> have"),
[NSString stringForFileSize: have], [NSString stringForFileSize: haveVerified]]];
[fHaveField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ (%@ verified)",
"Inspector -> Activity tab -> have"), [NSString stringForFileSize: have], [NSString stringForFileSize: haveVerified]]];
[fDownloadedTotalField setStringValue: [NSString stringForFileSize: downloadedTotal]];
[fUploadedTotalField setStringValue: [NSString stringForFileSize: uploadedTotal]];

View file

@ -173,8 +173,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
NSRect result = bounds;
result.size.height = BAR_HEIGHT;
result.origin.x = PADDING_HORIZONAL + (minimal ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG)
+ PADDING_BETWEEN_IMAGE_AND_BAR;
result.origin.x = PADDING_HORIZONAL + (minimal ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG) + PADDING_BETWEEN_IMAGE_AND_BAR;
result.origin.y += PADDING_ABOVE_TITLE + HEIGHT_TITLE;
if (minimal)