From 29f733f13287fd7a9a52df4f21892ba957f876c1 Mon Sep 17 00:00:00 2001 From: Justin Anderson Date: Fri, 3 Oct 2008 15:56:54 +0000 Subject: [PATCH] Only close windows in response to fini messages from clients. 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 | 2 + src/kim/agent/mac/AuthenticationController.m | 71 +++++++++++-------- src/kim/agent/mac/IPCClient.m | 2 - src/kim/agent/mac/SelectIdentityController.m | 1 - .../English.lproj/Authentication.xib | 26 ++----- 5 files changed, 46 insertions(+), 56 deletions(-) diff --git a/src/kim/agent/mac/AuthenticationController.h b/src/kim/agent/mac/AuthenticationController.h index f6f5bd2b2..3d382c117 100644 --- a/src/kim/agent/mac/AuthenticationController.h +++ b/src/kim/agent/mac/AuthenticationController.h @@ -104,4 +104,6 @@ - (IBAction) changePasswordGearAction: (id) sender; +- (void) swapView: (NSView *) aView; + @end diff --git a/src/kim/agent/mac/AuthenticationController.m b/src/kim/agent/mac/AuthenticationController.m index d2d6b3716..1b9117594 100644 --- a/src/kim/agent/mac/AuthenticationController.m +++ b/src/kim/agent/mac/AuthenticationController.m @@ -144,7 +144,7 @@ - (IBAction) showWindow: (id) sender { - [[self window] center]; + [super showWindow:sender]; } @@ -218,14 +218,13 @@ [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 @@ -269,39 +268,54 @@ // 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]; @@ -340,17 +354,14 @@ // 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]; } @@ -359,11 +370,10 @@ { // 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]; } @@ -514,7 +524,6 @@ - (IBAction) cancel: (id) sender { [associatedClient didCancel]; - [self close]; } - (IBAction) enterIdentity: (id) sender diff --git a/src/kim/agent/mac/IPCClient.m b/src/kim/agent/mac/IPCClient.m index d024f0b6c..c271740a7 100644 --- a/src/kim/agent/mac/IPCClient.m +++ b/src/kim/agent/mac/IPCClient.m @@ -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; } diff --git a/src/kim/agent/mac/SelectIdentityController.m b/src/kim/agent/mac/SelectIdentityController.m index 66da11e2c..4ad47c93e 100644 --- a/src/kim/agent/mac/SelectIdentityController.m +++ b/src/kim/agent/mac/SelectIdentityController.m @@ -178,7 +178,6 @@ - (IBAction) cancel: (id) sender { [associatedClient didCancel]; - [self close]; } // --------------------------------------------------------------------------- diff --git a/src/kim/agent/mac/resources/English.lproj/Authentication.xib b/src/kim/agent/mac/resources/English.lproj/Authentication.xib index b7fdc822c..aac2d7fa8 100644 --- a/src/kim/agent/mac/resources/English.lproj/Authentication.xib +++ b/src/kim/agent/mac/resources/English.lproj/Authentication.xib @@ -10,6 +10,7 @@ YES + @@ -375,7 +376,7 @@ NSView - + 274 YES @@ -521,6 +522,7 @@ {500, 208} + NSView @@ -1685,26 +1687,6 @@ 300416 - - - hidden: selection.allow_save - - - - - - hidden: selection.allow_save - hidden - selection.allow_save - - NSValueTransformerName - NSNegateBoolean - - 2 - - - 300417 - ticketOptionsSheet @@ -3087,7 +3069,7 @@ com.apple.InterfaceBuilder.CocoaPlugin {{628, 646}, {500, 210}} - + {{932, 664}, {484, 199}} -- 2.26.2