Changeset 22571
- Timestamp:
- 02/08/2008 02:10:10 PM (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/adium-1.2/Frameworks/Adium Framework/Source/AIContactMenu.h
r22292 r22571 17 17 BOOL delegateRespondsToDidSelectContact; 18 18 BOOL delegateRespondsToShouldIncludeContact; 19 BOOL delegateRespondsToValidateContact; 19 20 BOOL shouldUseDisplayName; 20 21 BOOL shouldDisplayGroupHeaders; … … 33 34 - (void)contactMenu:(AIContactMenu *)inContactMenu didRebuildMenuItems:(NSArray *)menuItems; 34 35 - (void)contactMenu:(AIContactMenu *)inContactMenu didSelectContact:(AIListContact *)inContact; //Optional 36 - (AIListContact *)contactMenu:(AIContactMenu *)inContactMenu validateContact:(AIListContact *)inContact; //Optional 35 37 - (BOOL)contactMenu:(AIContactMenu *)inContactMenu shouldIncludeContact:(AIListContact *)inContact; //Optional 36 38 - (BOOL)contactMenuShouldUseUserIcon:(AIContactMenu *)inContactMenu; //Optional branches/adium-1.2/Frameworks/Adium Framework/Source/AIContactMenu.m
r22292 r22571 18 18 - (id)initWithDelegate:(id)inDelegate forContactsInObject:(AIListObject *)inContainingObject; 19 19 - (NSArray *)contactMenusForListObjects:(NSArray *)listObjects; 20 - (NSArray *)listObjectsFor ContainedObjects:(NSArray *)listObjects;20 - (NSArray *)listObjectsForMenuFromArrayOfListObjects:(NSArray *)listObjects; 21 21 - (void)_updateMenuItem:(NSMenuItem *)menuItem; 22 22 @end … … 50 50 // Register for contact list order notifications (so we can update our sorting) 51 51 [[adium notificationCenter] addObserver:self 52 selector:@selector(rebuildMenu)53 name:Contact_OrderChanged54 object:nil];52 selector:@selector(contactOrderChanged:) 53 name:Contact_OrderChanged 54 object:nil]; 55 55 56 56 [self rebuildMenu]; … … 82 82 } 83 83 84 - (void)contactOrderChanged:(NSNotification *)notification 85 { 86 AIListObject *changedObject = [notification object]; 87 if (changedObject == containingObject) { 88 [self rebuildMenu]; 89 } 90 } 84 91 85 92 //Delegate ------------------------------------------------------------------------------------------------------------- … … 96 103 delegateRespondsToDidSelectContact = [delegate respondsToSelector:@selector(contactMenu:didSelectContact:)]; 97 104 delegateRespondsToShouldIncludeContact = [delegate respondsToSelector:@selector(contactMenu:shouldIncludeContact:)]; 98 105 delegateRespondsToValidateContact = [delegate respondsToSelector:@selector(contactMenu:validateContact:)]; 106 99 107 shouldUseUserIcon = ([delegate respondsToSelector:@selector(contactMenuShouldUseUserIcon:)] && 100 108 [delegate contactMenuShouldUseUserIcon:self]); … … 160 168 */ 161 169 if (!shouldDisplayGroupHeaders) { 162 listObjects = [self listObjectsFor ContainedObjects:listObjects];170 listObjects = [self listObjectsForMenuFromArrayOfListObjects:listObjects]; 163 171 } 164 172 … … 167 175 } else { 168 176 // We can assume these are already sorted 169 listObjects = ([containingObject conformsToProtocol:@protocol(AIContainingObject)] ?170 [(AIListObject<AIContainingObject> *)containingObject listContacts] :171 [NSArray arrayWithObject:containingObject]);177 listObjects = [self listObjectsForMenuFromArrayOfListObjects:([containingObject conformsToProtocol:@protocol(AIContainingObject)] ? 178 [(AIListObject<AIContainingObject> *)containingObject listContacts] : 179 [NSArray arrayWithObject:containingObject])]; 172 180 } 173 181 … … 179 187 * @brief Creates an array of list objects which should be presented in the menu, expanding any containing objects 180 188 */ 181 - (NSArray *)listObjectsFor ContainedObjects:(NSArray *)listObjects189 - (NSArray *)listObjectsForMenuFromArrayOfListObjects:(NSArray *)listObjects 182 190 { 183 191 NSMutableArray *listObjectArray = [NSMutableArray array]; … … 187 195 while ((listObject = [enumerator nextObject])) { 188 196 if ([listObject isKindOfClass:[AIListContact class]]) { 189 // Include if the delegate doesn't specify, or if the delegate approves the contact. 197 /* Include if the delegate doesn't specify, or if the delegate approves the contact. 198 * Note that this includes a metacontact itself, not its contained objects. 199 */ 190 200 if (!delegateRespondsToShouldIncludeContact || [delegate contactMenu:self shouldIncludeContact:(AIListContact *)listObject]) { 201 if (delegateRespondsToValidateContact) 202 listObject = [delegate contactMenu:self validateContact:(AIListContact *)listObject]; 203 191 204 [listObjectArray addObject:listObject]; 192 205 } 193 // Only recurse through groups; meta contacts can stay as meta contacts. 194 } else if ([listObject isKindOfClass:[AIListGroup class]] && [listObject conformsToProtocol:@protocol(AIContainingObject)]) {195 [listObjectArray addObjectsFromArray:[self listObjectsFor ContainedObjects:[(AIListObject<AIContainingObject>*)listObject listContacts]]];206 207 } else if ([listObject isKindOfClass:[AIListGroup class]]) { 208 [listObjectArray addObjectsFromArray:[self listObjectsForMenuFromArrayOfListObjects:[(AIListGroup *)listObject listContacts]]]; 196 209 } 197 210 } … … 211 224 while ((listObject = [enumerator nextObject])) { 212 225 // Display groups inline 213 if ([listObject isKindOfClass:[AIListGroup class]] && [listObject conformsToProtocol:@protocol(AIContainingObject)]) {214 NSArray *containedListObjects = [self listObjectsFor ContainedObjects:[(AIListObject<AIContainingObject> *)listObject listContacts]];226 if ([listObject isKindOfClass:[AIListGroup class]]) { 227 NSArray *containedListObjects = [self listObjectsForMenuFromArrayOfListObjects:[(AIListObject<AIContainingObject> *)listObject listContacts]]; 215 228 216 229 // If there's any contained list objects, add ourself as a group and add the contained objects. … … 277 290 { 278 291 if ([inObject isKindOfClass:[AIListContact class]]) { 292 //Note that this will return nil if we don't ahve a menu item for inObject 279 293 NSMenuItem *menuItem = [self menuItemForContact:(AIListContact *)inObject]; 280 294 … … 285 299 [inModifiedKeys containsObject:@"IdleSince"] || 286 300 [inModifiedKeys containsObject:@"StatusType"]) { 287 301 288 302 //Update the changed menu item (or rebuild the entire menu if this item should be removed or added) 289 303 if (delegateRespondsToShouldIncludeContact) { branches/adium-1.2/Plugins/Dual Window Interface/AIAccountSelectionView.m
r21803 r22571 37 37 @interface AIAccountSelectionView (PRIVATE) 38 38 - (id)_init; 39 - (void)c hatMetaContactChanged;39 - (void)configureForCurrentChat; 40 40 - (void)chatDestinationChanged:(NSNotification *)notification; 41 41 - (void)chatSourceChanged:(NSNotification *)notification; … … 157 157 158 158 //Update source and destination menus 159 [self c hatMetaContactChanged];159 [self configureForCurrentChat]; 160 160 } 161 161 } … … 163 163 164 164 /*! 165 * @brief Update our menus when the meta contact or the meta contact's content changes 166 */ 167 - (void)chatMetaContactChanged 168 { 165 * @brief Build and configure all menus for the current chat 166 */ 167 - (void)configureForCurrentChat 168 { 169 AILogWithSignature(@""); 170 169 171 //Rebuild 'To' contact menu 170 if ([self choicesAvailableForContact]){172 if ([self choicesAvailableForContact]) { 171 173 [self _createContactMenu]; 172 } else{174 } else { 173 175 [self _destroyContactMenu]; 174 176 } … … 183 185 - (void)chatDestinationChanged:(NSNotification *)notification 184 186 { 187 AILogWithSignature(@"popUp_contacts selecting %@ (%@)", [chat listObject], [notification object]); 188 185 189 //Update selection in contact menu 186 190 [popUp_contacts selectItemWithRepresentedObjectUsingCompare:[chat listObject]]; … … 343 347 */ 344 348 - (void)contactMenu:(AIContactMenu *)inContactMenu didRebuildMenuItems:(NSArray *)menuItems { 349 AILogWithSignature(@""); 345 350 [popUp_contacts setMenu:[inContactMenu menu]]; 351 [self chatDestinationChanged:nil]; 346 352 } 347 353 - (void)contactMenu:(AIContactMenu *)inContactMenu didSelectContact:(AIListContact *)inContact { 348 354 [[adium chatController] switchChat:chat toListContact:inContact usingContactAccount:YES]; 349 355 } 350 356 - (AIListContact *)contactMenu:(AIContactMenu *)inContactMenu validateContact:(AIListContact *)inContact { 357 AIListContact *preferredContact = [[adium contactController] preferredContactForContentType:CONTENT_MESSAGE_TYPE 358 forListContact:inContact]; 359 return preferredContact; 360 } 351 361 /*! 352 362 * @brief Create the contact menu and add it to our view