Changeset 13422
- Timestamp:
- 09/11/2005 10:20:05 PM (3 years ago)
- Files:
-
- branches/adium-0.8/Source/AdiumChatEvents.m (modified) (1 diff)
- branches/adium-0.8/Source/AIContactController.h (modified) (1 diff)
- branches/adium-0.8/Source/AIContactController.m (modified) (2 diffs)
- branches/adium-0.8/Source/AIContentController.h (modified) (2 diffs)
- branches/adium-0.8/Source/AINewContactWindowController.m (modified) (4 diffs)
- branches/adium-0.8/Source/AINewGroupWindowController.h (modified) (1 diff)
- branches/adium-0.8/Source/AINewGroupWindowController.m (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/adium-0.8/Source/AdiumChatEvents.m
r13406 r13422 11 11 #import <Adium/AIListContact.h> 12 12 #import <Adium/AIListObject.h> 13 #import <AIUtilities/ AIImageAdditions.h>13 #import <AIUtilities/ESImageAdditions.h> 14 14 15 15 @implementation AdiumChatEvents branches/adium-0.8/Source/AIContactController.h
r13113 r13422 120 120 - (AIListContact *)existingContactWithService:(AIService *)inService account:(AIAccount *)inAccount UID:(NSString *)inUID; 121 121 - (AIListGroup *)groupWithUID:(NSString *)groupUID; 122 - (AIListGroup *)existingGroupWithUID:(NSString *)groupUID; 122 123 - (NSMutableArray *)allContactsInGroup:(AIListGroup *)inGroup subgroups:(BOOL)subGroups onAccount:(AIAccount *)inAccount; 123 124 - (NSMenu *)menuOfAllContactsInContainingObject:(AIListObject<AIContainingObject> *)inGroup withTarget:(id)target; branches/adium-0.8/Source/AIContactController.m
r13223 r13422 2034 2034 } else { 2035 2035 if(!(group = [groupDict objectForKey:groupUID])) { 2036 //NSArray *groupNest = [groupUID componentsSeparatedByString:@":"];2037 //NSString *groupName = [groupNest lastObject];2038 //AIListGroup *targetGroup;2039 2040 2036 //Create 2041 2037 group = [[AIListGroup alloc] initWithUID:groupUID]; 2042 //[group setStatusObject:groupName forKey:@"FormattedUID" notify:YES];2043 2038 2044 2039 //Place new groups at the bottom of our list (by giving them the largest ordering index) 2045 // largestOrder += 1.0;2046 // [group setOrderIndex:largestOrder];2047 2040 float orderIndex = [group orderIndex]; 2048 2041 if (orderIndex > nextOrderIndex) nextOrderIndex = orderIndex + 1; 2049 2042 2050 // add2043 //Add 2051 2044 [self _updateAllAttributesOfObject:group]; 2052 2045 [groupDict setObject:group forKey:groupUID]; 2053 2046 2054 2047 //Add to target group 2055 //if([groupNest count] == 1) {2056 // targetGroup = contactList;2057 //} else {2058 // targetGroup = [self groupWithUID:[groupUID substringToIndex:[groupUID length] - ([groupName length] + 1)]];2059 //}2060 [ /*targetGroup*/contactList addObject:group];2061 [self _listChangedGroup:/*targetGroup*/contactList object:group]; 2048 [contactList addObject:group]; 2049 [self _listChangedGroup:contactList object:group]; 2050 2051 //Add to the contact list 2052 [contactList addObject:group]; 2053 [self _listChangedGroup:contactList object:group]; 2054 2062 2055 [group release]; 2063 2056 } … … 2065 2058 2066 2059 return(group); 2060 } 2061 2062 - (AIListGroup *)existingGroupWithUID:(NSString *)groupUID 2063 { 2064 AIListGroup *group; 2065 2066 if (!groupUID || ![groupUID length] || [groupUID isEqualToString:ADIUM_ROOT_GROUP_NAME]) { 2067 //Return our root group if it is requested 2068 group = contactList; 2069 } else { 2070 group = [groupDict objectForKey:groupUID]; 2071 } 2072 2073 return group; 2067 2074 } 2068 2075 branches/adium-0.8/Source/AIContentController.h
r13406 r13422 25 25 @protocol AITextEntryView, AIEventHandler; 26 26 27 @class AIAccount, AIChat, AIListContact, AIListObject, AIContentObject, AdiumContentFiltering ;27 @class AIAccount, AIChat, AIListContact, AIListObject, AIContentObject, AdiumContentFiltering, AdiumChatEvents; 28 28 29 29 typedef enum { … … 90 90 91 91 AdiumContentFiltering *adiumContentFiltering; 92 AdiumChatEvents *adiumChatEvents; 92 93 93 94 NSMutableSet *openChats; branches/adium-0.8/Source/AINewContactWindowController.m
r10866 r13422 18 18 #import "AIContactController.h" 19 19 #import "AINewContactWindowController.h" 20 #import "AINewGroupWindowController.h" 21 #import <AIUtilities/AIMenuAdditions.h> 20 22 #import <AIUtilities/AIPopUpButtonAdditions.h> 23 #import <AIUtilities/AIStringAdditions.h> 21 24 #import <Adium/AIAccount.h> 22 25 #import <Adium/AIListContact.h> … … 26 29 27 30 #define ADD_CONTACT_PROMPT_NIB @"AddContact" 31 #define DEFAULT_GROUP_NAME AILocalizedString(@"Contacts",nil) 28 32 29 33 @interface AINewContactWindowController (PRIVATE) … … 180 184 [[popUp_targetGroup selectedItem] representedObject] : 181 185 nil); 182 186 187 if (!group) group = [[adium contactController] groupWithUID:DEFAULT_GROUP_NAME]; 188 183 189 while(account = [enumerator nextObject]){ 184 190 if([account contactListEditable] && … … 299 305 { 300 306 AIListObject *selectedObject; 301 AIListGroup *group; 302 307 NSMenu *menu; 303 308 //Rebuild the menu 304 [popUp_targetGroup setMenu:[[adium contactController] menuOfAllGroupsInGroup:nil withTarget:self]]; 305 309 menu = [[adium contactController] menuOfAllGroupsInGroup:nil withTarget:self]; 310 311 //Add a default group name to the menu if there are no groups listed 312 if ([menu numberOfItems] == 0) { 313 [menu addItemWithTitle:DEFAULT_GROUP_NAME 314 target:self 315 action:@selector(selectGroup:) 316 keyEquivalent:@""]; 317 } 318 319 [menu addItem:[NSMenuItem separatorItem]]; 320 [menu addItemWithTitle:[AILocalizedString(@"New Group",nil) stringByAppendingEllipsis] 321 target:self 322 action:@selector(newGroup:) 323 keyEquivalent:@""]; 324 306 325 //Select the group of the currently selected object on the contact list 307 326 selectedObject = [[adium contactController] selectedListObject]; 308 309 if(selectedObject != nil) { 310 //Find the first containing object which is an AIListGroup, starting with the selected object itself 311 group = (AIListGroup*)selectedObject; 312 while (group && ![group isKindOfClass:[AIListGroup class]]){ 313 group = (AIListGroup*)[group containingObject]; 314 } 315 316 if(group){ 317 [popUp_targetGroup selectItemWithRepresentedObject:group]; 318 }else if([popUp_targetGroup numberOfItems] > 0){ 319 [popUp_targetGroup selectItemAtIndex:0]; 320 } 321 322 } 327 while (selectedObject && ![selectedObject isKindOfClass:[AIListGroup class]]) { 328 selectedObject = [selectedObject containingObject]; 329 } 330 331 [popUp_targetGroup setMenu:menu]; 332 333 //If there was no selected group, just select the first item 334 if (selectedObject) { 335 if (![popUp_targetGroup selectItemWithRepresentedObject:selectedObject]) { 336 [popUp_targetGroup selectItemAtIndex:0]; 337 } 338 339 } else { 340 [popUp_targetGroup selectItemAtIndex:0]; 341 } 342 } 343 344 /* 345 * @brief Prompt the user to add a new group immediately 346 */ 347 - (void)newGroup:(id)sender 348 { 349 AINewGroupWindowController *newGroupWindowController; 350 351 newGroupWindowController = [AINewGroupWindowController promptForNewGroupOnWindow:[self window]]; 352 353 //Observe for the New Group window to close 354 [[adium notificationCenter] addObserver:self 355 selector:@selector(newGroupDidEnd:) 356 name:@"NewGroupWindowControllerDidEnd" 357 object:[newGroupWindowController window]]; 358 } 359 360 - (void)newGroupDidEnd:(NSNotification *)inNotification 361 { 362 NSWindow *window = [inNotification object]; 363 364 if ([[window windowController] isKindOfClass:[AINewGroupWindowController class]]) { 365 NSString *newGroupUID = [[window windowController] newGroupUID]; 366 AIListGroup *group = [[adium contactController] existingGroupWithUID:newGroupUID]; 367 368 //Rebuild the group menu 369 [self buildGroupMenu]; 370 371 /* Select the new group if it exists; otherwise select the first group (so we don't still have New Group... selected). 372 * If the user canceled, group will be nil since the group doesn't exist. 373 */ 374 if (![popUp_targetGroup selectItemWithRepresentedObject:group]) { 375 [popUp_targetGroup selectItemAtIndex:0]; 376 } 377 378 [[self window] performSelector:@selector(makeKeyAndOrderFront:) 379 withObject:self 380 afterDelay:0]; 381 } 382 383 //Stop observing 384 [[adium notificationCenter] removeObserver:self 385 name:@"NewGroupWindowControllerDidEnd" 386 object:window]; 323 387 } 324 388 branches/adium-0.8/Source/AINewGroupWindowController.h
r9675 r13422 27 27 } 28 28 29 + (void)promptForNewGroupOnWindow:(NSWindow *)parentWindow; 29 + (AINewGroupWindowController *)promptForNewGroupOnWindow:(NSWindow *)parentWindow; 30 - (NSString *)newGroupUID; 30 31 - (IBAction)cancel:(id)sender; 31 32 - (IBAction)addGroup:(id)sender; branches/adium-0.8/Source/AINewGroupWindowController.m
r10862 r13422 31 31 * @param parentWindow Window on which to show as a sheet. Pass nil for a panel prompt. 32 32 */ 33 + ( void)promptForNewGroupOnWindow:(NSWindow *)parentWindow33 + (AINewGroupWindowController *)promptForNewGroupOnWindow:(NSWindow *)parentWindow 34 34 { 35 AINewGroupWindowController *newGroupWindow ;35 AINewGroupWindowController *newGroupWindowController; 36 36 37 newGroupWindow = [[self alloc] initWithWindowNibName:ADD_GROUP_PROMPT_NIB];37 newGroupWindowController = [[self alloc] initWithWindowNibName:ADD_GROUP_PROMPT_NIB]; 38 38 39 39 if(parentWindow){ 40 [NSApp beginSheet:[newGroupWindow window]40 [NSApp beginSheet:[newGroupWindowController window] 41 41 modalForWindow:parentWindow 42 modalDelegate:newGroupWindow 42 modalDelegate:newGroupWindowController 43 43 didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) 44 44 contextInfo:nil]; 45 45 }else{ 46 [newGroupWindow showWindow:nil];46 [newGroupWindowController showWindow:nil]; 47 47 } 48 48 49 return newGroupWindowController; 49 50 } 50 51 … … 69 70 - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo 70 71 { 72 [[adium notificationCenter] postNotificationName:@"NewGroupWindowControllerDidEnd" 73 object:sheet]; 71 74 [sheet orderOut:nil]; 72 75 } … … 84 87 } 85 88 89 /* 90 * @brief UID of the new group 91 */ 92 - (NSString *)newGroupUID 93 { 94 return [[[textField_groupName stringValue] copy] autorelease]; 95 } 96 86 97 /*! 87 98 * @brief Add the group … … 89 100 - (IBAction)addGroup:(id)sender 90 101 { 91 [[adium contactController] groupWithUID:[textField_groupName stringValue]];102 AIListGroup *group = [[adium contactController] groupWithUID:[self newGroupUID]]; 92 103 93 104 if([[self window] isSheet]){