From: Mitchell Livingston Date: Sat, 9 Feb 2013 19:13:26 +0000 (+0000) Subject: resize the rename dialogue buttons for different localizations X-Git-Tag: 2.80~97 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c2bde757187b788cf8ee27c1dd2084755dcf212c;p=transmission resize the rename dialogue buttons for different localizations --- diff --git a/macosx/FileRenameSheetController.m b/macosx/FileRenameSheetController.m index 312486464..72024f747 100644 --- a/macosx/FileRenameSheetController.m +++ b/macosx/FileRenameSheetController.m @@ -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;