Only close windows in response to fini messages from clients.
authorJustin Anderson <jander@mit.edu>
Fri, 3 Oct 2008 15:56:54 +0000 (15:56 +0000)
committerJustin Anderson <jander@mit.edu>
Fri, 3 Oct 2008 15:56:54 +0000 (15:56 +0000)
Only center the windows the first time they are shown for a client.
Improve the math on the NSRect sent to -[NSWindow setFrame:] so dialog windows don't jump around the screen and the title bar stays in the same place.
Refactor repeated view swapping code to -[AuthenticationController swapView:].

ticket: 6142

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20821 dc483132-0cff-0310-8789-dd5450dbe970

src/kim/agent/mac/AuthenticationController.h
src/kim/agent/mac/AuthenticationController.m
src/kim/agent/mac/IPCClient.m
src/kim/agent/mac/SelectIdentityController.m
src/kim/agent/mac/resources/English.lproj/Authentication.xib

index f6f5bd2b212a6ddc1e4b83bc9287c0317e3eddb8..3d382c117b2e4cd3da865bc8ed2df5c82036c5d3 100644 (file)
 
 - (IBAction) changePasswordGearAction: (id) sender;
 
+- (void) swapView: (NSView *) aView;
+
 @end
index d2d6b3716bc257a1af99b24aedcb91d5025863c9..1b911759466a7d57c5a7a1212ca912bee4c8be53 100644 (file)
 
 - (IBAction) showWindow: (id) sender
 {
-    [[self window] center];
+
     [super showWindow:sender];
 }
 
     [glueController setValue:message
                   forKeyPath:message_keypath];
 
-    [[containerView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
-    [theWindow setFrame:[theWindow frameRectForContentRect:[identityView frame]] display:NO];
-    [containerView addSubview:identityView];
-
     [enterSpinny stopAnimation:nil];
-    
+
+    [self swapView:identityView];
+
     [theWindow makeFirstResponder:identityField];
-    [self showWindow:nil];
+
+    [[self window] makeKeyAndOrderFront:nil];
 }
 
 - (void) showAuthPrompt
 
     // set badge
     [passwordBadge setBadgePath:associatedClient.path];
-
-    frame = [passwordView frame];
-    [[containerView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
-    [theWindow setFrame:[theWindow frameRectForContentRect:frame] display:NO];
-    [containerView addSubview:passwordView];
-
+    
     // adjust for checkbox visibility
-    if (![[glueController valueForKeyPath:allow_save_password_keypath] boolValue]) {
-        frame = [theWindow frame];
+    if (![[glueController valueForKeyPath:allow_save_password_keypath] boolValue] &&
+        ![rememberPasswordInKeychainCheckBox isHidden]) {
+        [rememberPasswordInKeychainCheckBox setHidden:YES];
+        frame = [passwordView frame];
         shrinkBy = ([passwordField frame].origin.y - 
                     [rememberPasswordInKeychainCheckBox frame].origin.y);
-        frame.origin.y += shrinkBy;
         frame.size.height -= shrinkBy;
-        [theWindow setFrame:frame display:NO];
+        [passwordView setFrame:frame];
     }
     
+    [self swapView:passwordView];
+    
     [theWindow makeFirstResponder:passwordField];
     [self showWindow:nil];
 }
 
-- (void) showSAM
+- (void) swapView: (NSView *) aView
 {
     NSWindow *theWindow = [self window];
+    NSRect windowFrame;
+    NSRect viewFrame;
+    
+    [[containerView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
+    
+    windowFrame = [theWindow frame];
+    viewFrame = [theWindow frameRectForContentRect:[aView frame]];
+    windowFrame.origin.y -= viewFrame.size.height - windowFrame.size.height;
+    
+    windowFrame.size.width = viewFrame.size.width;
+    windowFrame.size.height = viewFrame.size.height;
+    
+    [theWindow setFrame:windowFrame display:YES animate:YES];
+    
+    [containerView addSubview:aView];
+    
+}
 
+- (void) showSAM
+{
     // set badge
     [samBadge setBadgePath:associatedClient.path];
 
     [glueController setValue:[NSNumber numberWithBool:NO]
                    forKeyPath:allow_save_password_keypath];
     
-    [[containerView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
-    [theWindow setFrame:[theWindow frameRectForContentRect:[samView frame]] display:NO];
-    [containerView addSubview:samView];
+    [self swapView:samView];
     
     [self showWindow:nil];
     [[self window] makeFirstResponder:samPromptField];
         // Your password has expired, would you like to change it?
     }
     [glueController setValue:message forKeyPath:message_keypath];
-                     
-    // wake up the nib connections and adjust window size
-    [[containerView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
-    [theWindow setFrame:[theWindow frameRectForContentRect:[changePasswordView frame]] display:NO];
-    // set up controls with info from associatedClient
-    [containerView addSubview:changePasswordView];
+    
     // set badge
     [changePasswordBadge setBadgePath:associatedClient.path];
     
     [changePasswordSpinny stopAnimation:nil];
     
+    [self swapView:changePasswordView];
+    
     [self showWindow:nil];
     [theWindow makeFirstResponder:oldPasswordField];
 }
 {
     // wake up the nib connections and adjust window size
     [self window];
-    // set up controls with info from associatedClient
-    [[containerView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
-    [containerView addSubview:errorView];
     // set badge
     [errorBadge setBadgePath:associatedClient.path];
+
+    [self swapView:errorView];
     
     [self showWindow:nil];
 }
 - (IBAction) cancel: (id) sender
 {
     [associatedClient didCancel];
-    [self close];
 }
 
 - (IBAction) enterIdentity: (id) sender
index d024f0b6cde6c6379701c718d0f9d9ca8a5c628c..c271740a75a31371cdc86704c1765415a8640f4b 100644 (file)
@@ -104,8 +104,6 @@ enum krb_agent_client_state {
     else if (self.state == ipc_client_state_change_password) {
         [KerberosAgentListener didChangePassword:self.currentInfo error:err];
     }
-    [self.selectController close];
-    [self.authController close];
     self.state = ipc_client_state_idle;
 }
 
index 66da11e2cbed0e7799c6e2986168274ce46791b8..4ad47c93ecb604f9a3e76a28ea2425266a8dac2e 100644 (file)
 - (IBAction) cancel: (id) sender
 {
     [associatedClient didCancel];
-    [self close];
 }
 
 // ---------------------------------------------------------------------------
index b7fdc822c2cdc2fe9edcd3ecaa4dcb49d52a2a75..aac2d7fa82d7c3f49a3d20c19819adfff78b927a 100644 (file)
@@ -10,6 +10,7 @@
                        <bool key="EncodedWithXMLCoder">YES</bool>
                        <integer value="300288"/>
                        <integer value="19"/>
+                       <integer value="300175"/>
                        <integer value="300420"/>
                </object>
                <object class="NSArray" key="IBDocument.PluginDependencies">
                                <string key="NSClassName">NSView</string>
                        </object>
                        <object class="NSCustomView" id="866582848">
-                               <nil key="NSNextResponder"/>
+                               <reference key="NSNextResponder"/>
                                <int key="NSvFlags">274</int>
                                <object class="NSMutableArray" key="NSSubviews">
                                        <bool key="EncodedWithXMLCoder">YES</bool>
                                        </object>
                                </object>
                                <string key="NSFrameSize">{500, 208}</string>
+                               <reference key="NSSuperview"/>
                                <string key="NSClassName">NSView</string>
                        </object>
                        <object class="NSCustomView" id="898191415">
                                        </object>
                                        <int key="connectionID">300416</int>
                                </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBBindingConnection" key="connection">
-                                               <string key="label">hidden: selection.allow_save</string>
-                                               <reference key="source" ref="645528597"/>
-                                               <reference key="destination" ref="57033499"/>
-                                               <object class="NSNibBindingConnector" key="connector">
-                                                       <reference key="NSSource" ref="645528597"/>
-                                                       <reference key="NSDestination" ref="57033499"/>
-                                                       <string key="NSLabel">hidden: selection.allow_save</string>
-                                                       <string key="NSBinding">hidden</string>
-                                                       <string key="NSKeyPath">selection.allow_save</string>
-                                                       <object class="NSDictionary" key="NSOptions">
-                                                               <string key="NS.key.0">NSValueTransformerName</string>
-                                                               <string key="NS.object.0">NSNegateBoolean</string>
-                                                       </object>
-                                                       <int key="NSNibBindingConnectorVersion">2</int>
-                                               </object>
-                                       </object>
-                                       <int key="connectionID">300417</int>
-                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">ticketOptionsSheet</string>
                                        <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
                                        <string>{{628, 646}, {500, 210}}</string>
                                        <reference ref="9"/>
-                                       <reference ref="9"/>
+                                       <integer value="0"/>
                                        <string>{{932, 664}, {484, 199}}</string>
                                        <reference ref="9"/>
                                        <reference ref="9"/>