adium 5483:0e4c479f6b82: Restored "Add Contact to Group" behavio...

commits at adium.im commits at adium.im
Sat May 11 10:18:56 UTC 2013


details:	http://hg.adium.im/adium/rev/0e4c479f6b82
revision:	5483:0e4c479f6b82
branch:		adium-1.6
author:		User Detmud <detmud at me.com>
date:		Sat Jan 26 05:22:18 2013 +0100

Restored "Add Contact to Group" behaviour to come with the appropriate group selected. Fixes #13027

r=xnyhps: Removed some unnecessary whitespace changes from the patch.

diffs (134 lines):

diff -r 4ec6382f8985 -r 0e4c479f6b82 Source/AIContactListEditorPlugin.m
--- a/Source/AIContactListEditorPlugin.m	Fri May 10 15:37:35 2013 +0200
+++ b/Source/AIContactListEditorPlugin.m	Sat Jan 26 05:22:18 2013 +0100
@@ -213,17 +213,22 @@
  */
 - (void)promptForNewContactOnWindow:(NSWindow *)inWindow selectedListObject:(AIListObject *)inListObject
 {
-	//We only autofill if the selected list object is a contact and a stranger
-	if (![inListObject isKindOfClass:[AIListContact class]] ||
-		[inListObject isKindOfClass:[AIListBookmark class]] ||
-		[(AIListContact *)inListObject isIntentionallyNotAStranger] ||
-		[inListObject isKindOfClass:[AIMetaContact class]]) {
-		inListObject = nil;
+	//We only autofill if the selected list object is a contact, a stranger or a call from a Group (add Contact in Group)
+	AINewContactWindowController *newContactWindowController;
+
+	if ([inListObject isKindOfClass:[AIListGroup class]]) {
+		newContactWindowController = [[AINewContactWindowController alloc] initWithGroupName : (inListObject ? inListObject.UID:nil)];
+
+	} else if ([inListObject isKindOfClass:[AIListContact class]]) {
+		newContactWindowController = [[AINewContactWindowController alloc] initWithContactName:(inListObject ? inListObject.UID:nil)
+																					   service:(inListObject ? [(AIListContact *)inListObject service]:nil)
+																					   account:nil];
+	} else {
+		newContactWindowController = [[AINewContactWindowController alloc] initWithContactName:nil
+																					   service:nil
+																					   account:nil];
 	}
 	
-	AINewContactWindowController *newContactWindowController = [[AINewContactWindowController alloc] initWithContactName:(inListObject ? inListObject.UID : nil)
-																												 service:(inListObject ? [(AIListContact *)inListObject service] : nil)
-																												 account:nil];
 	[newContactWindowController showOnWindow:inWindow];
 }
 
diff -r 4ec6382f8985 -r 0e4c479f6b82 Source/AINewContactWindowController.h
--- a/Source/AINewContactWindowController.h	Fri May 10 15:37:35 2013 +0200
+++ b/Source/AINewContactWindowController.h	Sat Jan 26 05:22:18 2013 +0100
@@ -48,6 +48,7 @@
 	AIService						*service;
 	AIAccount						*initialAccount;
 	ABPerson						*person;
+	NSString						*groupName;
 }
 
 - (id)initWithContactName:(NSString *)inName service:(AIService *)inService account:(AIAccount *)inAccount;
diff -r 4ec6382f8985 -r 0e4c479f6b82 Source/AINewContactWindowController.m
--- a/Source/AINewContactWindowController.m	Fri May 10 15:37:35 2013 +0200
+++ b/Source/AINewContactWindowController.m	Sat Jan 26 05:22:18 2013 +0100
@@ -1,4 +1,4 @@
-/* 
+/*
  * Adium is the legal property of its developers, whose names are listed in the copyright file included
  * with this source distribution.
  * 
@@ -92,6 +92,25 @@
 		initialAccount = [inAccount retain];
 		contactName = [inName retain];
 		person = nil;
+		groupName = nil;
+	}
+	
+	return self;
+}
+
+/*!
+ * @brief Initialize
+ *
+ * @param inGroup Initial value for the Group name field
+ */
+- (id)initWithGroupName:(NSString *)inGroup
+{
+	if ((self = [super initWithWindowNibName:ADD_CONTACT_PROMPT_NIB])) {
+		service = nil;
+		initialAccount = nil;
+		contactName = nil;
+		person = nil;
+		groupName = inGroup;
 	}
 	
 	return self;
@@ -111,7 +130,8 @@
 	[initialAccount release];
 	[person release];
 	[checkedAccounts release];
-
+	[groupName release];
+	
 	[[NSNotificationCenter defaultCenter] removeObserver:self];
 
 	[super dealloc];
@@ -431,7 +451,12 @@
 
 	[popUp_targetGroup setMenu:menu];
 
-	[popUp_targetGroup selectItemAtIndex:0];
+	//if a group has been set
+	if (groupName != nil) {
+		[popUp_targetGroup selectItemWithTitle:groupName];
+	} else {
+		[popUp_targetGroup selectItemAtIndex:0];
+	}
 }
 
 /*!
@@ -464,7 +489,12 @@
 		 * If the user cancelled, group will be nil since the group doesn't exist.
 		 */
 		if (![popUp_targetGroup selectItemWithRepresentedObject:group]) {
-			[popUp_targetGroup selectItemAtIndex:0];			
+			//if a group has been set
+			if (groupName != nil) {
+				[popUp_targetGroup selectItemWithTitle:groupName];
+			} else {
+				[popUp_targetGroup selectItemAtIndex:0];
+			}
 		}
 		
 		[[self window] performSelector:@selector(makeKeyAndOrderFront:)
@@ -600,6 +630,14 @@
 }
 
 /*!
+ * @brief selector to select Group used by "Add Contact to Group"
+ */
+- (void)selectGroupByName:(NSString *)groupName
+{
+    [popUp_targetGroup selectItemWithTitle:groupName];
+}
+
+/*!
  * @brief Empty selector called by the group popUp menu
  */
 - (void)selectGroup:(id)sender




More information about the commits mailing list