adium 5432:01e230cae45d: The "extra pixel" here does hurt my eye...

commits at adium.im commits at adium.im
Wed Apr 24 20:31:45 UTC 2013


details:	http://hg.adium.im/adium/rev/01e230cae45d
revision:	5432:01e230cae45d
branch:		libotr4.0.0
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Wed Apr 24 22:30:41 2013 +0200

The "extra pixel" here does hurt my eyes, it makes the "Regenerate" button in OTR prefs move.
Subject: adium 5433:d2138e2c5e50: Some usability and UI improvements to the OTR prefs, ask the user they are sure before deleting their private key.

details:	http://hg.adium.im/adium/rev/d2138e2c5e50
revision:	5433:d2138e2c5e50
branch:		libotr4.0.0
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Wed Apr 24 22:31:35 2013 +0200

Some usability and UI improvements to the OTR prefs, ask the user they are sure before deleting their private key.

diffs (226 lines):

diff -r 9d5cc1abd7f1 -r d2138e2c5e50 Frameworks/Adium Framework/Source/AILocalizationControl.m
--- a/Frameworks/Adium Framework/Source/AILocalizationControl.m	Wed Apr 24 22:28:10 2013 +0200
+++ b/Frameworks/Adium Framework/Source/AILocalizationControl.m	Wed Apr 24 22:31:35 2013 +0200
@@ -116,9 +116,8 @@
 		newFrame.size.width += 8;
 	}
 	
-	//Only use integral widths to keep alignment correct;
-	//round up as an extra pixel of whitespace never hurt anybody
-	newFrame.size.width = AIround(NSWidth(newFrame) + 0.5f);
+	//Only use integral widths to keep alignment correct
+	newFrame.size.width = AIround(NSWidth(newFrame));
 	
 	//Enforce a minimum width of the original frame width
 //	NSLog(@"%@: new is %@; original is %@",inStringValue,NSStringFromRect(newFrame),NSStringFromRect(originalFrame));
@@ -143,9 +142,8 @@
 				newFrame.origin.x -= ((NSMaxX(newFrame) + 17) - windowMaxX);
 			}
 
-			//Only use integral origins to keep alignment correct;
-			//round up as an extra pixel of whitespace never hurt anybody
-			newFrame.origin.x = AIround(newFrame.origin.x + 0.5f);			
+			//Only use integral origins to keep alignment correct
+			newFrame.origin.x = AIround(newFrame.origin.x);
 			break;
 		}
 		case NSLeftTextAlignment:
diff -r 9d5cc1abd7f1 -r d2138e2c5e50 Resources/Preferences-Encryption.xib
--- a/Resources/Preferences-Encryption.xib	Wed Apr 24 22:28:10 2013 +0200
+++ b/Resources/Preferences-Encryption.xib	Wed Apr 24 22:31:35 2013 +0200
@@ -2,13 +2,13 @@
 <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
 	<data>
 		<int key="IBDocument.SystemTarget">1060</int>
-		<string key="IBDocument.SystemVersion">12C60</string>
-		<string key="IBDocument.InterfaceBuilderVersion">2844</string>
-		<string key="IBDocument.AppKitVersion">1187.34</string>
-		<string key="IBDocument.HIToolboxVersion">625.00</string>
+		<string key="IBDocument.SystemVersion">12D78</string>
+		<string key="IBDocument.InterfaceBuilderVersion">3084</string>
+		<string key="IBDocument.AppKitVersion">1187.37</string>
+		<string key="IBDocument.HIToolboxVersion">626.00</string>
 		<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
 			<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
-			<string key="NS.object.0">2844</string>
+			<string key="NS.object.0">3084</string>
 		</object>
 		<array key="IBDocument.IntegratedClassDependencies">
 			<string>NSButton</string>
@@ -257,8 +257,8 @@
 					</object>
 					<object class="NSButton" id="346757463">
 						<reference key="NSNextResponder" ref="261192207"/>
-						<int key="NSvFlags">268</int>
-						<string key="NSFrame">{{414, 261}, {97, 32}}</string>
+						<int key="NSvFlags">270</int>
+						<string key="NSFrame">{{414, 261}, {111, 32}}</string>
 						<reference key="NSSuperview" ref="261192207"/>
 						<reference key="NSWindow"/>
 						<reference key="NSNextKeyView" ref="152864849"/>
@@ -266,7 +266,7 @@
 						<object class="NSButtonCell" key="NSCell" id="9745553">
 							<int key="NSCellFlags">67108864</int>
 							<int key="NSCellFlags2">134217728</int>
-							<string key="NSContents">Generate</string>
+							<string key="NSContents">Regenerate</string>
 							<reference key="NSSupport" ref="970377140"/>
 							<reference key="NSControlView" ref="346757463"/>
 							<int key="NSButtonFlags">-2038284288</int>
@@ -688,13 +688,13 @@
 						<array class="NSMutableArray" key="children">
 							<reference ref="365143233"/>
 							<reference ref="152864849"/>
-							<reference ref="346757463"/>
 							<reference ref="246614867"/>
 							<reference ref="953884195"/>
 							<reference ref="41604946"/>
 							<reference ref="590488253"/>
 							<reference ref="476167500"/>
 							<reference ref="944557168"/>
+							<reference ref="346757463"/>
 						</array>
 						<reference key="parent" ref="0"/>
 						<string key="objectName">View</string>
@@ -927,7 +927,7 @@
 			<nil key="activeLocalization"/>
 			<dictionary class="NSMutableDictionary" key="localizations"/>
 			<nil key="sourceID"/>
-			<int key="maxID">78</int>
+			<int key="maxID">79</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1030,7 +1030,7 @@
 					</dictionary>
 					<dictionary class="NSMutableDictionary" key="outlets">
 						<string key="button_forgetFingerprint">NSButton</string>
-						<string key="button_generate">NSButton</string>
+						<string key="button_generate">AILocalizationButton</string>
 						<string key="button_showFingerprint">NSButton</string>
 						<string key="field_filter">NSSearchField</string>
 						<string key="label_knownFingerprints">NSTextField</string>
@@ -1046,7 +1046,7 @@
 						</object>
 						<object class="IBToOneOutletInfo" key="button_generate">
 							<string key="name">button_generate</string>
-							<string key="candidateClassName">NSButton</string>
+							<string key="candidateClassName">AILocalizationButton</string>
 						</object>
 						<object class="IBToOneOutletInfo" key="button_showFingerprint">
 							<string key="name">button_showFingerprint</string>
diff -r 9d5cc1abd7f1 -r d2138e2c5e50 Source/AdiumOTREncryption.m
--- a/Source/AdiumOTREncryption.m	Wed Apr 24 22:28:10 2013 +0200
+++ b/Source/AdiumOTREncryption.m	Wed Apr 24 22:31:35 2013 +0200
@@ -916,9 +916,16 @@
 {
 	ConnContext		*context = contextForChat(inChat);
 	
-	AIOTRSMPSecretAnswerWindowController *windowController = [[AIOTRSMPSecretAnswerWindowController alloc] initWithQuestion:@"" from:inChat.listObject completionHandler:^(NSString *answer, NSString *question) {
-		otrl_message_initiate_smp_q(otrg_get_userstate(), &ui_ops, NULL, context, (const char *)[question UTF8String], (const unsigned char *)[answer UTF8String], answer.length);
-	} isInitiator:TRUE];
+	AIOTRSMPSecretAnswerWindowController *windowController = [[AIOTRSMPSecretAnswerWindowController alloc] initWithQuestion:@""
+																													   from:inChat.listObject
+																										  completionHandler:^(NSString *answer, NSString *question) {
+		otrl_message_initiate_smp_q(otrg_get_userstate(),
+									&ui_ops, NULL, context,
+									(const char *)[question UTF8String],
+									(const unsigned char *)[answer UTF8String],
+									answer.length);
+	}
+																												isInitiator:TRUE];
 	
 	[windowController showWindow:nil];
 	[windowController.window orderFront:nil];
@@ -928,9 +935,15 @@
 {
 	ConnContext		*context = contextForChat(inChat);
 	
-	AIOTRSMPSharedSecretWindowController *windowController = [[AIOTRSMPSharedSecretWindowController alloc] initFrom:inChat.listObject completionHandler:^(NSString *answer) {
-		otrl_message_initiate_smp(otrg_get_userstate(), &ui_ops, NULL, context, (const unsigned char *)[answer UTF8String], answer.length);
-	} isInitiator:TRUE];
+	AIOTRSMPSharedSecretWindowController *windowController = [[AIOTRSMPSharedSecretWindowController alloc] initFrom:inChat.listObject
+																								  completionHandler:^(NSString *answer) {
+		otrl_message_initiate_smp(otrg_get_userstate(),
+								  &ui_ops, NULL,
+								  context,
+								  (const unsigned char *)[answer UTF8String],
+								  answer.length);
+	}
+																										isInitiator:TRUE];
 	
 	[windowController showWindow:nil];
 	[windowController.window orderFront:nil];
diff -r 9d5cc1abd7f1 -r d2138e2c5e50 Source/ESOTRPreferences.h
--- a/Source/ESOTRPreferences.h	Wed Apr 24 22:28:10 2013 +0200
+++ b/Source/ESOTRPreferences.h	Wed Apr 24 22:31:35 2013 +0200
@@ -19,7 +19,7 @@
 
 @interface ESOTRPreferences : AIPreferencePane <AIAccountMenuDelegate, NSTableViewDelegate, NSTableViewDataSource> {
 	IBOutlet	NSPopUpButton	*popUp_accounts;
-	IBOutlet	NSButton		*button_generate;
+	IBOutlet	AILocalizationButton	*button_generate;
 	IBOutlet	NSTextField		*textField_privateKey;
 	
 	IBOutlet	NSTableView		*tableView_fingerprints;
diff -r 9d5cc1abd7f1 -r d2138e2c5e50 Source/ESOTRPreferences.m
--- a/Source/ESOTRPreferences.m	Wed Apr 24 22:28:10 2013 +0200
+++ b/Source/ESOTRPreferences.m	Wed Apr 24 22:31:35 2013 +0200
@@ -80,9 +80,10 @@
 	[label_knownFingerprints setStringValue:AILocalizedString(@"Known Fingerprints:", nil)];
 	[button_forgetFingerprint setTitle:AILocalizedString(@"Delete", nil)];
 	[button_showFingerprint setTitle:[AILocalizedString(@"Show", nil) stringByAppendingEllipsis]];
-	[button_generate setTitle:AILocalizedString(@"Generate", nil)];
 	[[[tableView_fingerprints tableColumnWithIdentifier:@"UID"] headerCell] setStringValue:AILocalizedString(@"Name", nil)];
 	[[[tableView_fingerprints tableColumnWithIdentifier:@"Status"] headerCell] setStringValue:AILocalizedString(@"Status", nil)];
+	
+	// button_generate already got localized when -updatePrivateKeyList got called.
 }
 
 - (void)viewWillClose
@@ -211,10 +212,10 @@
 													   fingerprint_buf, accountname, protocol);
 				
 				if (fingerprint) {
-					[button_generate setTitle:AILocalizedString(@"Regenerate", nil)];
+					[button_generate setLocalizedString:AILocalizedString(@"Regenerate", nil)];
 					fingerprintString = [NSString stringWithFormat:AILocalizedString(@"Fingerprint: %.80s",nil), fingerprint];
 				} else {
-					[button_generate setTitle:AILocalizedString(@"Generate", nil)];
+					[button_generate setLocalizedString:AILocalizedString(@"Generate", nil)];
 					fingerprintString = AILocalizedString(@"No private key present", "Message to show in the Encryption OTR preferences when an account is selected which does not have a private key");
 				}
 			}
@@ -233,8 +234,30 @@
 {
 	AIAccount	*account = ([popUp_accounts numberOfItems] ? [[popUp_accounts selectedItem] representedObject] : nil);
 	
-	otrg_plugin_create_privkey([account.internalObjectID UTF8String],
-							   [account.service.serviceCodeUniqueID UTF8String]);
+	if (account) {
+		const char		*accountname = [account.internalObjectID UTF8String];
+		const char		*protocol = [account.service.serviceCodeUniqueID UTF8String];
+		char			*fingerprint;
+		OtrlUserState	otrg_plugin_userstate;
+		
+		if ((otrg_plugin_userstate = otrg_get_userstate())){
+			char fingerprint_buf[45];
+			fingerprint = otrl_privkey_fingerprint(otrg_plugin_userstate,
+												   fingerprint_buf, accountname, protocol);
+			
+			if (fingerprint) {
+				NSAlert *deleteKeyAlert = [NSAlert alertWithMessageText:AILocalizedString(@"Are you sure you want to generate a new OTR key?", nil)
+														  defaultButton:AILocalizedString(@"Cancel", nil)
+														alternateButton:AILocalizedString(@"Delete", nil)
+															otherButton:nil
+											  informativeTextWithFormat:AILocalizedString(@"This will permanently delete your old key and all your contacts will need to verify your fingerprint again.", "Message when regenerating an OTR key")];
+				if ([deleteKeyAlert runModal] == NSAlertDefaultReturn) return;
+			}
+		}
+		
+		otrg_plugin_create_privkey([account.internalObjectID UTF8String],
+								   [account.service.serviceCodeUniqueID UTF8String]);
+	}
 }
 
 /*!




More information about the commits mailing list