]> granicus.if.org Git - transmission/commitdiff
resize the rename dialogue buttons for different localizations
authorMitchell Livingston <livings124@transmissionbt.com>
Sat, 9 Feb 2013 19:13:26 +0000 (19:13 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sat, 9 Feb 2013 19:13:26 +0000 (19:13 +0000)
macosx/FileRenameSheetController.m

index 3124864646588d7193acf7c10ded085abf639360..72024f74742b4d125a5e49ff2ad3edc8c15c2f84 100644 (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;