adium 2450:08aa9c3a346c: Create a new advanced preference called...

commits at adium.im commits at adium.im
Tue Jun 2 21:22:27 UTC 2009


details:	http://hg.adium.im/adium/rev/08aa9c3a346c
revision:	2450:08aa9c3a346c
author:		Zachary West <zacw at adium.im>
date:		Tue Jun 02 17:22:19 2009 -0400

Create a new advanced preference called "Confirmations". Move Quit Confirmations there.

Adds a new confirmation type for closing message windows with more than 1 tab open. Fixes #12006.

This new preference has two options: always confirm, only confirm when there's unread content. Displays an alert sheet when trying to close the window.

diffs (759 lines):

diff -r ba67e70f6454 -r 08aa9c3a346c Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj	Tue Jun 02 16:03:30 2009 -0400
+++ b/Adium.xcodeproj/project.pbxproj	Tue Jun 02 17:22:19 2009 -0400
@@ -95,6 +95,8 @@
 		111E89020F93FE3900A5F18B /* AIUserHostTooltip.m in Sources */ = {isa = PBXBuildFile; fileRef = 111E89000F93FE3900A5F18B /* AIUserHostTooltip.m */; };
 		1121B29A0F896A720047EC66 /* AIContactVisibilityControlPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 1121B2990F896A720047EC66 /* AIContactVisibilityControlPlugin.m */; };
 		112523190F5F7F86003FC58A /* AITwitterURLHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 112523180F5F7F86003FC58A /* AITwitterURLHandler.m */; };
+		112939020FD5AC1B00FA8F53 /* AIConfirmationsAdvancedPreferences.nib in Resources */ = {isa = PBXBuildFile; fileRef = 112939010FD5AC1B00FA8F53 /* AIConfirmationsAdvancedPreferences.nib */; };
+		112939100FD5AE1400FA8F53 /* AIConfirmationsAdvancedPreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 1129390F0FD5AE1400FA8F53 /* AIConfirmationsAdvancedPreferences.m */; };
 		112B47240F82DC2300690E84 /* AIGroupChatStatusIcons.h in Headers */ = {isa = PBXBuildFile; fileRef = 112B47220F82DC2300690E84 /* AIGroupChatStatusIcons.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		112B47250F82DC2300690E84 /* AIGroupChatStatusIcons.m in Sources */ = {isa = PBXBuildFile; fileRef = 112B47230F82DC2300690E84 /* AIGroupChatStatusIcons.m */; };
 		112B47670F82E0FC00690E84 /* AIXtraInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 112B47650F82E0FC00690E84 /* AIXtraInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1798,6 +1800,9 @@
 		1121B2990F896A720047EC66 /* AIContactVisibilityControlPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIContactVisibilityControlPlugin.m; path = Source/AIContactVisibilityControlPlugin.m; sourceTree = "<group>"; };
 		112523170F5F7F86003FC58A /* AITwitterURLHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AITwitterURLHandler.h; path = "Plugins/Twitter Plugin/AITwitterURLHandler.h"; sourceTree = "<group>"; };
 		112523180F5F7F86003FC58A /* AITwitterURLHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AITwitterURLHandler.m; path = "Plugins/Twitter Plugin/AITwitterURLHandler.m"; sourceTree = "<group>"; };
+		112939010FD5AC1B00FA8F53 /* AIConfirmationsAdvancedPreferences.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = AIConfirmationsAdvancedPreferences.nib; path = Resources/AIConfirmationsAdvancedPreferences.nib; sourceTree = "<group>"; };
+		1129390E0FD5AE1400FA8F53 /* AIConfirmationsAdvancedPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIConfirmationsAdvancedPreferences.h; path = Source/AIConfirmationsAdvancedPreferences.h; sourceTree = "<group>"; };
+		1129390F0FD5AE1400FA8F53 /* AIConfirmationsAdvancedPreferences.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIConfirmationsAdvancedPreferences.m; path = Source/AIConfirmationsAdvancedPreferences.m; sourceTree = "<group>"; };
 		112B47220F82DC2300690E84 /* AIGroupChatStatusIcons.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIGroupChatStatusIcons.h; path = "Frameworks/Adium Framework/Source/AIGroupChatStatusIcons.h"; sourceTree = "<group>"; };
 		112B47230F82DC2300690E84 /* AIGroupChatStatusIcons.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIGroupChatStatusIcons.m; path = "Frameworks/Adium Framework/Source/AIGroupChatStatusIcons.m"; sourceTree = "<group>"; };
 		112B47650F82E0FC00690E84 /* AIXtraInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIXtraInfo.h; path = "Frameworks/Adium Framework/Source/AIXtraInfo.h"; sourceTree = "<group>"; };
@@ -5179,6 +5184,9 @@
 		3428328307D263F0004F01C9 /* Status Preferences */ = {
 			isa = PBXGroup;
 			children = (
+				112939010FD5AC1B00FA8F53 /* AIConfirmationsAdvancedPreferences.nib */,
+				1129390E0FD5AE1400FA8F53 /* AIConfirmationsAdvancedPreferences.h */,
+				1129390F0FD5AE1400FA8F53 /* AIConfirmationsAdvancedPreferences.m */,
 				11A2F1200FC8FC9D00C3F05C /* AIMessageAlertsAdvancedPreferences.h */,
 				11A2F1210FC8FC9D00C3F05C /* AIMessageAlertsAdvancedPreferences.m */,
 				11A2F1090FC8FC1A00C3F05C /* AIMessageAlertsAdvancedPreferences.nib */,
@@ -9823,6 +9831,7 @@
 				11D135D90FBE4C65000B0A5E /* AITwitterAccountView.nib in Resources */,
 				11A2F10A0FC8FC1A00C3F05C /* AIMessageAlertsAdvancedPreferences.nib in Resources */,
 				11BE29640FCCA8DA000E6A10 /* ImageUploaderProgress.nib in Resources */,
+				112939020FD5AC1B00FA8F53 /* AIConfirmationsAdvancedPreferences.nib in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -10483,6 +10492,7 @@
 				11BE28DF0FCC7D2B000E6A10 /* AIImageUploaderPlugin.m in Sources */,
 				11BE29680FCCA9E3000E6A10 /* AIImageUploaderWindowController.m in Sources */,
 				1197F6710FCF8D180032F19B /* AITwitterStatusFollowup.m in Sources */,
+				112939100FD5AE1400FA8F53 /* AIConfirmationsAdvancedPreferences.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff -r ba67e70f6454 -r 08aa9c3a346c Frameworks/Adium Framework/Source/AIAdiumProtocol.h
--- a/Frameworks/Adium Framework/Source/AIAdiumProtocol.h	Tue Jun 02 16:03:30 2009 -0400
+++ b/Frameworks/Adium Framework/Source/AIAdiumProtocol.h	Tue Jun 02 17:22:19 2009 -0400
@@ -21,6 +21,11 @@
 	AIQuitConfirmSelective
 } AIQuitConfirmationType;
 
+typedef enum {
+	AIMessageCloseAlways = 0,
+	AIMessageCloseUnread
+} AIMessageCloseConfirmationType;
+
 @protocol AIAccountController, AIChatController, AIContactAlertsController, AIDebugController, AIEmoticonController,
 		AIPreferenceController, AIMenuController, AIApplescriptabilityController, AIStatusController,
 		AIContentController, AIToolbarController, AISoundController, AIDockController,
diff -r ba67e70f6454 -r 08aa9c3a346c Frameworks/Adium Framework/Source/AIInterfaceControllerProtocol.h
--- a/Frameworks/Adium Framework/Source/AIInterfaceControllerProtocol.h	Tue Jun 02 16:03:30 2009 -0400
+++ b/Frameworks/Adium Framework/Source/AIInterfaceControllerProtocol.h	Tue Jun 02 17:22:19 2009 -0400
@@ -45,6 +45,15 @@
 #define KEY_CL_SHOW_TOOLTIPS_IN_BACKGROUND	@"Show Tooltips in Background"
 #define KEY_CL_WINDOW_HAS_SHADOW			@"Window Has Shadow"
 
+#define PREF_GROUP_CONFIRMATIONS		@"Confirmations"
+#define KEY_CONFIRM_QUIT				@"Confirm Quit"
+#define KEY_CONFIRM_QUIT_TYPE			@"Confirm Quit Type"
+#define KEY_CONFIRM_QUIT_FT				@"Suppress Quit Confirmation for File Transfers"
+#define KEY_CONFIRM_QUIT_OPEN			@"Suppress Quit Confirmation for Open Chats"
+#define KEY_CONFIRM_QUIT_UNREAD			@"Suppress Quit Confirmation for Unread Messages"
+#define KEY_CONFIRM_MSG_CLOSE			@"Confirm Message Window Close"
+#define KEY_CONFIRM_MSG_CLOSE_TYPE		@"Confirm Message Window Close Type"
+
 typedef enum {
 	AINormalWindowLevel = 0,
 	AIFloatingWindowLevel = 1,
diff -r ba67e70f6454 -r 08aa9c3a346c Plugins/Dual Window Interface/AIMessageWindowController.m
--- a/Plugins/Dual Window Interface/AIMessageWindowController.m	Tue Jun 02 16:03:30 2009 -0400
+++ b/Plugins/Dual Window Interface/AIMessageWindowController.m	Tue Jun 02 17:22:19 2009 -0400
@@ -237,8 +237,94 @@
 - (IBAction)closeWindow:(id)sender
 {
 	windowIsClosing = YES;
+	
+	[[self window] performClose:nil];
+}
 
-	[[self window] performClose:nil];
+/*!
+ * @brief Confirm if we should close the window.
+ */
+- (BOOL)windowShouldClose:(id)window
+{
+	if (!windowIsClosing
+		&& self.containedChats.count > 1
+		&& [[adium.preferenceController preferenceForKey:KEY_CONFIRM_MSG_CLOSE group:PREF_GROUP_CONFIRMATIONS] boolValue]) {
+		NSString *suppressionText = nil;
+		
+		NSInteger unreadCount = 0;
+		
+		for (AIChat *chat in self.containedChats) {
+			if (chat.unviewedContentCount) {
+				unreadCount++;
+			}
+		}
+		
+		switch ([[adium.preferenceController preferenceForKey:KEY_CONFIRM_MSG_CLOSE_TYPE group:PREF_GROUP_CONFIRMATIONS] integerValue]) {
+			case AIMessageCloseAlways:
+				suppressionText = AILocalizedString(@"Do not warn when closing multiple chats", nil);
+				break;
+				
+			case AIMessageCloseUnread:
+				if (unreadCount) {
+					suppressionText = AILocalizedString(@"Do not warn when closing unread chats", nil);
+				}
+				break;
+		}
+		
+		NSString *question = nil;
+		if (unreadCount) {
+			if (unreadCount == 1) {
+				question = [NSString stringWithFormat:AILocalizedString(@"%u chats are open in this window, 1 of which has unviewed messages. Do you want to close this window anyway?",nil),
+							self.containedChats.count];
+			} else {
+				question = [NSString stringWithFormat:AILocalizedString(@"%u chats are open in this window, %u of which have unviewed messages. Do you want to close this window anyway?",nil),
+							self.containedChats.count,
+							unreadCount];	
+			}
+		} else {
+			question = [NSString stringWithFormat:AILocalizedString(@"%u chats are open in this window. Do you want to close this window anyway?",nil),
+						self.containedChats.count];
+		}
+		
+		if (suppressionText) {
+			NSAlert *alert = [NSAlert alertWithMessageText:AILocalizedString(@"Are you sure you want to close this window?", nil)
+											 defaultButton:AILocalizedString(@"Close", nil)
+										   alternateButton:AILocalizedStringFromTable(@"Cancel", @"Buttons", nil)
+											   otherButton:nil
+								 informativeTextWithFormat:question];
+			
+			[alert setShowsSuppressionButton:YES];
+			[[alert suppressionButton] setTitle:suppressionText];
+			
+			[alert beginSheetModalForWindow:self.window 
+							  modalDelegate:self 
+							 didEndSelector:@selector(closeAlertDidEnd:returnCode:contextInfo:) 
+								contextInfo:nil];
+			
+			return NO;
+		}
+	}
+	
+	return YES;
+}
+
+- (void)closeAlertDidEnd:(NSAlert *)alert returnCode:(int)result contextInfo:(void *)contextInfo;
+{
+	
+	if ([alert suppressionButton].state == NSOnState) {
+		[adium.preferenceController setPreference:nil
+										   forKey:KEY_CONFIRM_MSG_CLOSE
+											group:PREF_GROUP_CONFIRMATIONS];
+	}
+
+	if (result == NSAlertDefaultReturn) {
+		// Dismiss the alert sheet.
+		[self.window orderOut:nil];
+		// Don't prompt again.
+		windowIsClosing = YES;
+		// Close the window.
+		[self closeWindow:nil];
+	}
 }
 
 /*!
diff -r ba67e70f6454 -r 08aa9c3a346c Plugins/General Preferences/ESGeneralPreferencesPlugin.h
--- a/Plugins/General Preferences/ESGeneralPreferencesPlugin.h	Tue Jun 02 16:03:30 2009 -0400
+++ b/Plugins/General Preferences/ESGeneralPreferencesPlugin.h	Tue Jun 02 17:22:19 2009 -0400
@@ -43,9 +43,6 @@
 #define PREF_GROUP_STATUS_MENU_ITEM     @"Status Menu Item"
 #define KEY_STATUS_MENU_ITEM_ENABLED    @"Status Menu Item Enabled"
 
-#define PREF_GROUP_CONFIRMATIONS		@"Confirmations"
-#define KEY_CONFIRM_QUIT				@"Confirm Quit"
-
 #define	KEY_GENERAL_HOTKEY				@"General Hot Key"
 
 @class PTHotKey;
diff -r ba67e70f6454 -r 08aa9c3a346c Resources/AIConfirmationsAdvancedPreferences.nib/classes.nib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/AIConfirmationsAdvancedPreferences.nib/classes.nib	Tue Jun 02 17:22:19 2009 -0400
@@ -0,0 +1,228 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBClasses</key>
+	<array>
+		<dict>
+			<key>CLASS</key>
+			<string>NSApplication</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSResponder</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>RBSplitView</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>delegate</key>
+				<string>id</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>RBSplitSubview</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSTextField</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSControl</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>AIAdvancedPreferencePane</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>AIModularPane</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>RBSplitSubview</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSView</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSMenu</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>ACTIONS</key>
+			<dict>
+				<key>adiumPrint</key>
+				<string>id</string>
+				<key>didAdjustSubviews</key>
+				<string>RBSplitView</string>
+				<key>prefsWindowWillClose</key>
+				<string>SS_PrefsController</string>
+				<key>toggleFindPanel</key>
+				<string>id</string>
+				<key>willAdjustSubviews</key>
+				<string>RBSplitView</string>
+			</dict>
+			<key>CLASS</key>
+			<string>NSObject</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>AILocalizationButton</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>view_anchorToLeftSide</key>
+				<string>NSView</string>
+				<key>view_anchorToRightSide</key>
+				<string>NSView</string>
+				<key>window_anchorOnLeftSide</key>
+				<string>NSWindow</string>
+				<key>window_anchorOnRightSide</key>
+				<string>NSWindow</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSButton</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSWindow</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSResponder</string>
+		</dict>
+		<dict>
+			<key>ACTIONS</key>
+			<dict>
+				<key>changePreference</key>
+				<string>id</string>
+			</dict>
+			<key>CLASS</key>
+			<string>AIConfirmationsAdvancedPreferences</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>checkBox_confirmBeforeClosing</key>
+				<string>NSButton</string>
+				<key>checkBox_confirmBeforeQuitting</key>
+				<string>NSButton</string>
+				<key>checkBox_quitConfirmFT</key>
+				<string>NSButton</string>
+				<key>checkBox_quitConfirmOpenChats</key>
+				<string>NSButton</string>
+				<key>checkBox_quitConfirmUnread</key>
+				<string>NSButton</string>
+				<key>label_messageCloseConfirmation</key>
+				<string>NSTextField</string>
+				<key>label_quitConfirmation</key>
+				<string>NSTextField</string>
+				<key>matrix_closeConfirmType</key>
+				<string>NSMatrix</string>
+				<key>matrix_quitConfirmType</key>
+				<string>NSMatrix</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>AIAdvancedPreferencePane</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSView</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSResponder</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSCell</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>ACTIONS</key>
+			<dict>
+				<key>changePreference</key>
+				<string>id</string>
+			</dict>
+			<key>CLASS</key>
+			<string>AIModularPane</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>plugin</key>
+				<string>id</string>
+				<key>view</key>
+				<string>NSView</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSButton</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSControl</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>AILocalizationTextField</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>view_anchorToLeftSide</key>
+				<string>NSView</string>
+				<key>view_anchorToRightSide</key>
+				<string>NSView</string>
+				<key>window_anchorOnLeftSide</key>
+				<string>NSWindow</string>
+				<key>window_anchorOnRightSide</key>
+				<string>NSWindow</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSTextField</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSButtonCell</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSActionCell</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>SS_PrefsController</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>delegate</key>
+				<string>id</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+	</array>
+	<key>IBVersion</key>
+	<string>1</string>
+</dict>
+</plist>
diff -r ba67e70f6454 -r 08aa9c3a346c Resources/AIConfirmationsAdvancedPreferences.nib/info.nib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/AIConfirmationsAdvancedPreferences.nib/info.nib	Tue Jun 02 17:22:19 2009 -0400
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBFramework Version</key>
+	<string>677</string>
+	<key>IBLastKnownRelativeProjectPath</key>
+	<string>../Adium.xcodeproj</string>
+	<key>IBOldestOS</key>
+	<integer>5</integer>
+	<key>IBOpenObjects</key>
+	<array>
+		<integer>1</integer>
+	</array>
+	<key>IBSystem Version</key>
+	<string>9J61</string>
+	<key>targetFramework</key>
+	<string>IBCocoaFramework</string>
+</dict>
+</plist>
diff -r ba67e70f6454 -r 08aa9c3a346c Resources/AIConfirmationsAdvancedPreferences.nib/keyedobjects.nib
Binary file Resources/AIConfirmationsAdvancedPreferences.nib/keyedobjects.nib has changed
diff -r ba67e70f6454 -r 08aa9c3a346c Resources/StatusPreferencesAdvanced.nib/classes.nib
--- a/Resources/StatusPreferencesAdvanced.nib/classes.nib	Tue Jun 02 16:03:30 2009 -0400
+++ b/Resources/StatusPreferencesAdvanced.nib/classes.nib	Tue Jun 02 17:22:19 2009 -0400
@@ -162,24 +162,12 @@
 			<string>ObjC</string>
 			<key>OUTLETS</key>
 			<dict>
-				<key>checkBox_quitConfirmEnabled</key>
-				<string>NSButton</string>
-				<key>checkBox_quitConfirmFT</key>
-				<string>NSButton</string>
-				<key>checkBox_quitConfirmOpenChats</key>
-				<string>NSButton</string>
-				<key>checkBox_quitConfirmUnread</key>
-				<string>NSButton</string>
 				<key>checkBox_statusWindowAlwaysOnTop</key>
 				<string>NSButton</string>
 				<key>checkBox_statusWindowHideInBackground</key>
 				<string>NSButton</string>
-				<key>label_quitConfirmation</key>
-				<string>NSTextField</string>
 				<key>label_statusWindow</key>
 				<string>NSTextField</string>
-				<key>matrix_quitConfirmation</key>
-				<string>NSMatrix</string>
 			</dict>
 			<key>SUPERCLASS</key>
 			<string>AIAdvancedPreferencePane</string>
diff -r ba67e70f6454 -r 08aa9c3a346c Resources/StatusPreferencesAdvanced.nib/keyedobjects.nib
Binary file Resources/StatusPreferencesAdvanced.nib/keyedobjects.nib has changed
diff -r ba67e70f6454 -r 08aa9c3a346c Source/AIAdvancedPreferencesPlugin.h
--- a/Source/AIAdvancedPreferencesPlugin.h	Tue Jun 02 16:03:30 2009 -0400
+++ b/Source/AIAdvancedPreferencesPlugin.h	Tue Jun 02 17:22:19 2009 -0400
@@ -5,10 +5,11 @@
 //  Created by Evan Schoenberg on 4/7/07.
 //
 
- at class AIMessageAlertsAdvancedPreferences;
+ at class AIMessageAlertsAdvancedPreferences, AIConfirmationsAdvancedPreferences;
 
 @interface AIAdvancedPreferencesPlugin : AIPlugin {
 	AIMessageAlertsAdvancedPreferences *messageAlertsPreferences;
+	AIConfirmationsAdvancedPreferences *confirmationsPreferences;
 }
 
 @end
diff -r ba67e70f6454 -r 08aa9c3a346c Source/AIAdvancedPreferencesPlugin.m
--- a/Source/AIAdvancedPreferencesPlugin.m	Tue Jun 02 16:03:30 2009 -0400
+++ b/Source/AIAdvancedPreferencesPlugin.m	Tue Jun 02 17:22:19 2009 -0400
@@ -8,6 +8,7 @@
 #import "AIAdvancedPreferencesPlugin.h"
 #import "AIAdvancedPreferences.h"
 #import "AIMessageAlertsAdvancedPreferences.h"
+#import "AIConfirmationsAdvancedPreferences.h"
 
 @implementation AIAdvancedPreferencesPlugin
 
@@ -17,6 +18,7 @@
 	
 	// Generic advanced panes with no specific plugins.
 	messageAlertsPreferences = [[AIMessageAlertsAdvancedPreferences preferencePane] retain];
+	confirmationsPreferences = [[AIConfirmationsAdvancedPreferences preferencePane] retain];
 }
 
 @end
diff -r ba67e70f6454 -r 08aa9c3a346c Source/AIConfirmationsAdvancedPreferences.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/AIConfirmationsAdvancedPreferences.h	Tue Jun 02 17:22:19 2009 -0400
@@ -0,0 +1,29 @@
+//
+//  AIConfirmationsAdvancedPreferences.h
+//  Adium
+//
+//  Created by Zachary West on 2009-06-02.
+//  Copyright 2009 Adium. All rights reserved.
+//
+
+#import <Adium/AIAdvancedPreferencePane.h>
+
+ at interface AIConfirmationsAdvancedPreferences : AIAdvancedPreferencePane {	
+	// Quit confirmation
+	IBOutlet	NSTextField		*label_quitConfirmation;
+	IBOutlet	NSButton		*checkBox_confirmBeforeQuitting;
+	IBOutlet	NSMatrix		*matrix_quitConfirmType;
+
+	IBOutlet	NSButton		*checkBox_quitConfirmFT;
+	IBOutlet	NSButton		*checkBox_quitConfirmUnread;
+	IBOutlet	NSButton		*checkBox_quitConfirmOpenChats;
+	
+	// Message window close confirmation
+	IBOutlet	NSTextField		*label_messageCloseConfirmation;
+	IBOutlet	NSButton		*checkBox_confirmBeforeClosing;
+	IBOutlet	NSMatrix		*matrix_closeConfirmType;
+}
+
+- (IBAction)changePreference:(id)sender;
+
+ at end
diff -r ba67e70f6454 -r 08aa9c3a346c Source/AIConfirmationsAdvancedPreferences.m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/AIConfirmationsAdvancedPreferences.m	Tue Jun 02 17:22:19 2009 -0400
@@ -0,0 +1,140 @@
+//
+//  AIConfirmationsAdvancedPreferences.m
+//  Adium
+//
+//  Created by Zachary West on 2009-06-02.
+//  Copyright 2009 Adium. All rights reserved.
+//
+
+#import "AIConfirmationsAdvancedPreferences.h"
+#import "AIPreferenceWindowController.h"
+
+#import <Adium/AIPreferenceControllerProtocol.h>
+#import <Adium/AIInterfaceControllerProtocol.h>
+
+#import <AIUtilities/AIStringAdditions.h>
+#import <AIUtilities/AIImageAdditions.h>
+
+ at implementation AIConfirmationsAdvancedPreferences
+#pragma mark Preference pane settings
+- (AIPreferenceCategory)category
+{
+    return AIPref_Advanced;
+}
+- (NSString *)label{
+    return AILocalizedString(@"Confirmations",nil);
+}
+- (NSString *)nibName{
+    return @"AIConfirmationsAdvancedPreferences";
+}
+- (NSImage *)image{
+	return [NSImage imageNamed:@"pref-events" forClass:[AIPreferenceWindowController class]];
+}
+
+/*!
+ * @brief The view loaded
+ */
+- (void)viewDidLoad
+{
+	[label_quitConfirmation setLocalizedString:AILocalizedString(@"Quit Confirmation", "Preference")];
+	[checkBox_confirmBeforeQuitting setLocalizedString:AILocalizedString(@"Confirm before quitting Adium", "Quit Confirmation preference")];
+	[checkBox_quitConfirmFT setLocalizedString:AILocalizedString(@"File transfers are in progress", "Quit Confirmation preference")];
+	[checkBox_quitConfirmUnread setLocalizedString:AILocalizedString(@"There are unread messages", "Quit Confirmation preference")];
+	[checkBox_quitConfirmOpenChats setLocalizedString:AILocalizedString(@"There are open chat windows", "Quit Confirmation preference")];
+	[[matrix_quitConfirmType cellWithTag:AIQuitConfirmAlways] setTitle:AILocalizedString(@"Always","Confirmation preference")];
+	[[matrix_quitConfirmType cellWithTag:AIQuitConfirmSelective] setTitle:[AILocalizedString(@"Only when","Quit Confirmation preference") stringByAppendingEllipsis]];
+	
+	[label_messageCloseConfirmation setLocalizedString:AILocalizedString(@"Window Close Confirmation", "Preference")];
+	[checkBox_confirmBeforeClosing setLocalizedString:AILocalizedString(@"Confirm before closing multiple chat windows", "Message close confirmation preference")];
+	[[matrix_closeConfirmType cellWithTag:AIMessageCloseAlways] setTitle:AILocalizedString(@"Always", "Confirmation preference")];
+	[[matrix_closeConfirmType cellWithTag:AIMessageCloseUnread] setTitle:AILocalizedString(@"Only when there are unread messages", "Message close confirmation preference")];
+	
+	NSDictionary *confirmationDict = [adium.preferenceController preferencesForGroup:PREF_GROUP_CONFIRMATIONS];
+
+	[checkBox_confirmBeforeQuitting setState:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT] boolValue]];
+	[matrix_quitConfirmType selectCellWithTag:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT_TYPE] integerValue]];
+	[checkBox_quitConfirmFT setState:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT_FT] boolValue]];
+	[checkBox_quitConfirmOpenChats setState:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT_OPEN] boolValue]];
+	[checkBox_quitConfirmUnread setState:[[confirmationDict objectForKey:KEY_CONFIRM_QUIT_UNREAD] boolValue]];
+	
+	[checkBox_confirmBeforeClosing setState:[[confirmationDict objectForKey:KEY_CONFIRM_MSG_CLOSE] boolValue]];
+	[matrix_closeConfirmType selectCellWithTag:[[confirmationDict objectForKey:KEY_CONFIRM_MSG_CLOSE_TYPE] integerValue]];
+	
+	[self configureControlDimming];
+	
+	[super viewDidLoad];
+}
+
+- (void)viewWillClose
+{	
+	[super viewWillClose];
+}
+
+- (IBAction)changePreference:(id)sender
+{
+	if (sender == checkBox_confirmBeforeQuitting) {
+		[adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
+										   forKey:KEY_CONFIRM_QUIT
+											group:PREF_GROUP_CONFIRMATIONS];
+		
+		[self configureControlDimming];
+	}
+	
+	if (sender == checkBox_quitConfirmFT) {
+		[adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
+										   forKey:KEY_CONFIRM_QUIT_FT
+											group:PREF_GROUP_CONFIRMATIONS];
+	}
+	
+	if (sender == checkBox_quitConfirmUnread) {
+		[adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
+										   forKey:KEY_CONFIRM_QUIT_UNREAD
+											group:PREF_GROUP_CONFIRMATIONS];		
+	}
+	
+	if (sender == checkBox_quitConfirmOpenChats) {
+		[adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
+										   forKey:KEY_CONFIRM_QUIT_OPEN
+											group:PREF_GROUP_CONFIRMATIONS];
+	}
+	
+	if (sender == matrix_quitConfirmType) {
+		[adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedCell] tag]]
+								   forKey:KEY_CONFIRM_QUIT_TYPE
+									group:PREF_GROUP_CONFIRMATIONS];
+		
+		[self configureControlDimming];
+	}
+	
+	if (sender == checkBox_confirmBeforeClosing) {
+		[adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
+										   forKey:KEY_CONFIRM_MSG_CLOSE
+											group:PREF_GROUP_CONFIRMATIONS];		
+		
+		[self configureControlDimming];		
+	}
+	
+	if (sender == matrix_closeConfirmType) {
+		[adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedCell] tag]]
+								   forKey:KEY_CONFIRM_MSG_CLOSE_TYPE
+									group:PREF_GROUP_CONFIRMATIONS];		
+	}
+	
+	[self viewDidLoad];
+}
+
+- (void)configureControlDimming
+{
+	BOOL		confirmQuitEnabled			= (checkBox_confirmBeforeQuitting.state == NSOnState);
+	BOOL		enableSpecificConfirmations = (confirmQuitEnabled && [[matrix_quitConfirmType selectedCell] tag] == AIQuitConfirmSelective);
+	
+	[matrix_quitConfirmType	setEnabled:confirmQuitEnabled];
+	[checkBox_quitConfirmFT	setEnabled:enableSpecificConfirmations];
+	[checkBox_quitConfirmUnread	setEnabled:enableSpecificConfirmations];
+	[checkBox_quitConfirmOpenChats setEnabled:enableSpecificConfirmations];
+	
+	BOOL		confirmCloseEnabled			= (checkBox_confirmBeforeClosing.state == NSOnState);
+	[matrix_closeConfirmType setEnabled:confirmCloseEnabled];
+}
+
+ at end
diff -r ba67e70f6454 -r 08aa9c3a346c Source/ESStatusAdvancedPreferences.h
--- a/Source/ESStatusAdvancedPreferences.h	Tue Jun 02 16:03:30 2009 -0400
+++ b/Source/ESStatusAdvancedPreferences.h	Tue Jun 02 17:22:19 2009 -0400
@@ -11,14 +11,6 @@
 	IBOutlet	NSTextField	*label_statusWindow;
 	IBOutlet	NSButton	*checkBox_statusWindowHideInBackground;
 	IBOutlet	NSButton	*checkBox_statusWindowAlwaysOnTop;	
-	
-	IBOutlet	NSTextField	*label_quitConfirmation;
-
-	IBOutlet	NSButton	*checkBox_quitConfirmEnabled;
-	IBOutlet	NSMatrix	*matrix_quitConfirmation;
-	IBOutlet	NSButton	*checkBox_quitConfirmFT;
-	IBOutlet	NSButton	*checkBox_quitConfirmUnread;
-	IBOutlet	NSButton	*checkBox_quitConfirmOpenChats;
 }
 
 @end
diff -r ba67e70f6454 -r 08aa9c3a346c Source/ESStatusAdvancedPreferences.m
--- a/Source/ESStatusAdvancedPreferences.m	Tue Jun 02 16:03:30 2009 -0400
+++ b/Source/ESStatusAdvancedPreferences.m	Tue Jun 02 17:22:19 2009 -0400
@@ -27,41 +27,12 @@
 	return [NSImage imageNamed:@"pref-status" forClass:[AIPreferenceWindowController class]];
 }
 
-//Called in response to all preference controls, applies new settings
-- (IBAction)changePreference:(id)sender
-{
-	if (sender == matrix_quitConfirmation || sender == checkBox_quitConfirmEnabled) {
-		[self configureControlDimming];
-	}
-}
-
-- (void)configureControlDimming
-{
-	BOOL		confirmQuitEnabled			= ([checkBox_quitConfirmEnabled state] == NSOnState);
-	BOOL		enableSpecificConfirmations = (confirmQuitEnabled && [[matrix_quitConfirmation selectedCell] tag] == AIQuitConfirmSelective);
-	
-	[matrix_quitConfirmation		setEnabled:confirmQuitEnabled];
-	[checkBox_quitConfirmFT			setEnabled:enableSpecificConfirmations];
-	[checkBox_quitConfirmUnread		setEnabled:enableSpecificConfirmations];
-	[checkBox_quitConfirmOpenChats	setEnabled:enableSpecificConfirmations];
-}
-
 //Configure the preference view
 - (void)viewDidLoad
-{	[label_statusWindow setLocalizedString:AILocalizedString(@"Away Status Window", nil)];
+{
+	[label_statusWindow setLocalizedString:AILocalizedString(@"Away Status Window", nil)];
 	[checkBox_statusWindowHideInBackground setLocalizedString:AILocalizedString(@"Hide the status window when Adium is not active", nil)];
 	[checkBox_statusWindowAlwaysOnTop setLocalizedString:AILocalizedString(@"Show the status window above other windows", nil)];
-
-	[label_quitConfirmation setLocalizedString:AILocalizedString(@"Quit Confirmation", @"Preference")];
-	[checkBox_quitConfirmEnabled setLocalizedString:AILocalizedString(@"Confirm before quitting Adium", @"Quit Confirmation preference")];
-	[checkBox_quitConfirmFT setLocalizedString:AILocalizedString(@"File transfers are in progress", @"Quit Confirmation preference")];
-	[checkBox_quitConfirmUnread setLocalizedString:AILocalizedString(@"There are unread messages", @"Quit Confirmation preference")];
-	[checkBox_quitConfirmOpenChats setLocalizedString:AILocalizedString(@"There are open chat windows", @"Quit Confirmation preference")];
-	
-	[[matrix_quitConfirmation cellWithTag:AIQuitConfirmAlways] setTitle:AILocalizedString(@"Always",@"Quit Confirmation preference")];
-	[[matrix_quitConfirmation cellWithTag:AIQuitConfirmSelective] setTitle:[AILocalizedString(@"Only when",@"Quit Confirmation preference") stringByAppendingEllipsis]];
-	
-	[self configureControlDimming];
 	
 	[super viewDidLoad];
 }




More information about the commits mailing list