1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-31 03:12:44 +00:00

resize the rename dialogue buttons for different localizations

This commit is contained in:
Mitchell Livingston 2013-02-09 19:13:26 +00:00
parent 00a5e86939
commit c2bde75718

View file

@ -93,9 +93,31 @@ typedef void (^CompletionBlock)(BOOL);
[self.inputField setStringValue: self.originalName];
[self.renameButton setEnabled: NO];
#warning size these
//resize the buttons so that they're long enough and the same width
const NSRect oldRenameFrame = [self.renameButton frame];
const NSRect oldCancelFrame = [self.cancelButton frame];
//get the extra width of the rename button from the English xib - the width from sizeToFit is too squished
[self.renameButton sizeToFit];
const CGFloat extra = NSWidth(oldRenameFrame) - NSWidth([self.renameButton frame]);
[self.renameButton setStringValue: NSLocalizedString(@"Rename", "rename sheet button")];
[self.cancelButton setStringValue: NSLocalizedString(@"Cancel", "rename sheet button")];
[self.renameButton sizeToFit];
[self.cancelButton sizeToFit];
NSRect newRenameFrame = [self.renameButton frame];
NSRect newCancelFrame = [self.cancelButton frame];
newRenameFrame.size.width = MAX(NSWidth(newRenameFrame), NSWidth(newCancelFrame)) + extra;
newCancelFrame.size.width = MAX(NSWidth(newRenameFrame), NSWidth(newCancelFrame)) + extra;
const CGFloat renameWidthIncrease = NSWidth(newRenameFrame) - NSWidth(oldRenameFrame);
newRenameFrame.origin.x -= renameWidthIncrease;
[self.renameButton setFrame:newRenameFrame];
const CGFloat cancelWidthIncrease = NSWidth(newCancelFrame) - NSWidth(oldCancelFrame);
newCancelFrame.origin.x -= renameWidthIncrease + cancelWidthIncrease;
[self.cancelButton setFrame:newCancelFrame];
}
- (IBAction) rename: (id) sender;