mirror of
https://github.com/transmission/transmission
synced 2025-02-20 13:16:53 +00:00
might as well dump a bunch of small changes/optimizations I have sitting locally
This commit is contained in:
parent
78c2abb585
commit
cee48f8c07
5 changed files with 17 additions and 30 deletions
|
@ -44,10 +44,10 @@
|
|||
NSString * path = [value stringByExpandingTildeInPath];
|
||||
NSImage * icon;
|
||||
//show a folder icon if the folder doesn't exist
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath: path] && [[path pathExtension] isEqualToString: @""])
|
||||
if ([[path pathExtension] isEqualToString: @""] && ![[NSFileManager defaultManager] fileExistsAtPath: path])
|
||||
icon = [[NSWorkspace sharedWorkspace] iconForFileType: NSFileTypeForHFSTypeCode('fldr')];
|
||||
else
|
||||
icon = [[NSWorkspace sharedWorkspace] iconForFile: [value stringByExpandingTildeInPath]];
|
||||
icon = [[NSWorkspace sharedWorkspace] iconForFile: path];
|
||||
|
||||
[icon setSize: NSMakeSize(16.0, 16.0)];
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
[self setSelectable: ![[self stringValue] isEqualToString: @""]];
|
||||
}
|
||||
|
||||
- (void)setObjectValue: (id < NSCopying >) object
|
||||
- (void) setObjectValue: (id <NSCopying>) object
|
||||
{
|
||||
[super setObjectValue: object];
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#import "PortChecker.h"
|
||||
|
||||
#define CHECKER_URL(port) [NSString stringWithFormat: @"http://portcheck.transmissionbt.com/%d", port]
|
||||
#define CHECK_FIRE 3.0
|
||||
#define CHECK_FIRE 3.0
|
||||
|
||||
@interface PortChecker (Private)
|
||||
|
||||
|
|
|
@ -913,22 +913,18 @@
|
|||
|
||||
NSMenuItem * item = [[NSMenuItem alloc] initWithTitle: name action: @selector(checkFile:) keyEquivalent: @""];
|
||||
|
||||
NSImage * icon;
|
||||
if (![node isFolder])
|
||||
icon = [node icon];
|
||||
else
|
||||
if ([node isFolder])
|
||||
{
|
||||
NSMenu * itemMenu = [[NSMenu alloc] initWithTitle: name];
|
||||
[itemMenu setAutoenablesItems: NO];
|
||||
[item setSubmenu: itemMenu];
|
||||
[itemMenu setDelegate: self];
|
||||
[itemMenu release];
|
||||
|
||||
icon = [[NSWorkspace sharedWorkspace] iconForFileType: NSFileTypeForHFSTypeCode('fldr')];
|
||||
}
|
||||
|
||||
[item setRepresentedObject: node];
|
||||
|
||||
NSImage * icon = [node icon];
|
||||
[icon setSize: NSMakeSize(16.0, 16.0)];
|
||||
[item setImage: icon];
|
||||
|
||||
|
|
|
@ -240,24 +240,17 @@ NSMutableSet * fTrackerIconLoading;
|
|||
|
||||
- (NSRect) imageRectForBounds: (NSRect) bounds
|
||||
{
|
||||
NSRect result = bounds;
|
||||
result.origin.x += PADDING_HORIZONAL;
|
||||
result.origin.y += PADDING_ABOVE_ICON;
|
||||
result.size = NSMakeSize(ICON_SIZE, ICON_SIZE);
|
||||
|
||||
return result;
|
||||
return NSMakeRect(NSMinX(bounds) + PADDING_HORIZONAL, NSMinY(bounds) + PADDING_ABOVE_ICON, ICON_SIZE, ICON_SIZE);
|
||||
}
|
||||
|
||||
- (NSRect) rectForNameWithString: (NSAttributedString *) string inBounds: (NSRect) bounds
|
||||
{
|
||||
const NSSize nameSize = [string size];
|
||||
|
||||
NSRect result = bounds;
|
||||
result.origin.x += PADDING_HORIZONAL + ICON_SIZE + PADDING_BETWEEN_ICON_AND_NAME;
|
||||
result.origin.y += PADDING_ABOVE_NAME;
|
||||
NSRect result;
|
||||
result.origin.x = NSMinX(bounds) + PADDING_HORIZONAL + ICON_SIZE + PADDING_BETWEEN_ICON_AND_NAME;
|
||||
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_NAME;
|
||||
|
||||
result.size = nameSize;
|
||||
result.size.width = MIN(result.size.width, NSMaxX(bounds) - NSMinX(result));
|
||||
result.size.height = [string size].height;
|
||||
result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONAL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -273,7 +266,7 @@ NSMutableSet * fTrackerIconLoading;
|
|||
{
|
||||
NSRect result = rightRect;
|
||||
result.size.width = [string size].width;
|
||||
result.origin.x -= result.size.width;
|
||||
result.origin.x -= NSWidth(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -281,14 +274,12 @@ NSMutableSet * fTrackerIconLoading;
|
|||
- (NSRect) rectForStatusWithString: (NSAttributedString *) string withAboveRect: (NSRect) aboveRect withRightRect: (NSRect) rightRect
|
||||
inBounds: (NSRect) bounds
|
||||
{
|
||||
const NSSize statusSize = [string size];
|
||||
|
||||
NSRect result = bounds;
|
||||
result.origin.x += PADDING_STATUS_HORIZONAL;
|
||||
NSRect result;
|
||||
result.origin.x = NSMinX(bounds) + PADDING_STATUS_HORIZONAL;
|
||||
result.origin.y = NSMaxY(aboveRect) + PADDING_BETWEEN_LINES;
|
||||
|
||||
result.size = statusSize;
|
||||
result.size.width = MIN(result.size.width, (NSMinX(rightRect) - PADDING_BETWEEN_LINES_ON_SAME_LINE) - NSMinX(result));
|
||||
result.size.height = [string size].height;
|
||||
result.size.width = NSMinX(rightRect) - PADDING_BETWEEN_LINES_ON_SAME_LINE - NSMinX(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue