mirror of
https://github.com/munki/munki.git
synced 2026-01-26 00:49:21 -06:00
resize password label and field to adjust for localization
This commit is contained in:
@@ -35,6 +35,7 @@ class MSCPasswordAlertController(NSObject):
|
||||
|
||||
def promptForPasswordForAuthRestart(self):
|
||||
'''Set up and display our alert that prompts for password'''
|
||||
# Set up all the fields and buttons with localized text
|
||||
alert = NSAlert.alloc().init()
|
||||
alert.addButtonWithTitle_(
|
||||
NSLocalizedString(u"Allow", u"Allow button text"))
|
||||
@@ -50,7 +51,16 @@ class MSCPasswordAlertController(NSObject):
|
||||
alert.setAccessoryView_(self.passwordView)
|
||||
self.passwordLabel.setStringValue_(NSLocalizedString(
|
||||
u"Password:",u"Password label"))
|
||||
self.passwordField.setStringValue_("")
|
||||
self.passwordField.setStringValue_(u"")
|
||||
# resize label to fit the text
|
||||
self.passwordLabel.sizeToFit()
|
||||
# resize the password field to use the rest of the available space
|
||||
viewWidth = self.passwordView.frame().size.width
|
||||
labelWidth = self.passwordLabel.frame().size.width
|
||||
fieldFrame = self.passwordField.frame()
|
||||
fieldFrame.origin.x = labelWidth + 8
|
||||
fieldFrame.size.width = viewWidth - labelWidth - 8
|
||||
self.passwordField.setFrame_(fieldFrame)
|
||||
# add esc as a key equivilent for the Deny button
|
||||
alert.buttons().objectAtIndex_(1).setKeyEquivalent_(chr(27))
|
||||
# change the Allow button to call our password validation method
|
||||
@@ -59,9 +69,10 @@ class MSCPasswordAlertController(NSObject):
|
||||
allowButton.setAction_(self.verifyPassword_)
|
||||
# make sure our password field is ready to accept input
|
||||
alert.window().setInitialFirstResponder_(self.passwordField)
|
||||
# we can finally run the alert!
|
||||
result = alert.runModal()
|
||||
if result == NSAlertFirstButtonReturn:
|
||||
# they clicked "Allow"
|
||||
# they clicked "Allow". We handled it in the verifyPassword method
|
||||
msclog.log("user", "stored password for auth restart")
|
||||
if result == NSAlertSecondButtonReturn:
|
||||
# they clicked "Deny"
|
||||
|
||||
@@ -537,7 +537,7 @@
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<secureTextField wantsLayer="YES" verticalHuggingPriority="750" id="RBe-5Z-jso">
|
||||
<rect key="frame" x="104" y="0.0" width="213" height="22"/>
|
||||
<rect key="frame" x="75" y="0.0" width="242" height="22"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="675-6Y-zrc">
|
||||
<font key="font" metaFont="system"/>
|
||||
@@ -549,9 +549,9 @@
|
||||
</secureTextFieldCell>
|
||||
</secureTextField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="X5P-3t-HRa">
|
||||
<rect key="frame" x="1" y="3" width="97" height="17"/>
|
||||
<rect key="frame" x="1" y="3" width="76" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Password:" id="Ef8-fO-Dm6">
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Password:" id="Ef8-fO-Dm6">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
|
||||
Reference in New Issue
Block a user