Changeset 1086
- Timestamp:
- 03/27/04 22:37:46 (5 years ago)
- Files:
-
- WiredClient/trunk/English.lproj/Accounts.nib/info.nib (modified) (1 diff)
- WiredClient/trunk/English.lproj/Accounts.nib/keyedobjects.nib (modified) (previous)
- WiredClient/trunk/English.lproj/Accounts.nib/objects.nib (modified) (previous)
- WiredClient/trunk/WCAccount.h (modified) (2 diffs)
- WiredClient/trunk/WCAccount.m (modified) (2 diffs)
- WiredClient/trunk/WCAccounts.h (modified) (3 diffs)
- WiredClient/trunk/WCAccounts.m (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredClient/trunk/English.lproj/Accounts.nib/info.nib
r944 r1086 4 4 <dict> 5 5 <key>IBDocumentLocation</key> 6 <string>2 48 95400 354 0 0 1280 1002 </string>6 <string>297 136 400 354 0 0 1280 1002 </string> 7 7 <key>IBFramework Version</key> 8 8 <string>349.0</string> 9 9 <key>IBSystem Version</key> 10 <string>7 D24</string>10 <string>7F44</string> 11 11 </dict> 12 12 </plist> WiredClient/trunk/WCAccount.h
r944 r1086 1 /* $Id: WCAccount.h,v 1. 1 2004/03/08 19:23:42morris Exp $ */1 /* $Id: WCAccount.h,v 1.2 2004/03/27 21:36:15 morris Exp $ */ 2 2 3 3 /* … … 69 69 70 70 - (NSComparisonResult) nameSort:(WCAccount *)other; 71 - (NSComparisonResult) typeSort:(WCAccount *)other; 71 72 72 73 @end WiredClient/trunk/WCAccount.m
r944 r1086 1 /* $Id: WCAccount.m,v 1. 1 2004/03/08 19:23:42morris Exp $ */1 /* $Id: WCAccount.m,v 1.2 2004/03/27 21:36:15 morris Exp $ */ 2 2 3 3 /* … … 240 240 } 241 241 242 243 244 - (NSComparisonResult)typeSort:(WCAccount *)other { 245 NSComparisonResult result; 246 247 // --- then sort by size 248 if(_type == WCAccountTypeUser && [other type] == WCAccountTypeGroup) 249 return NSOrderedAscending; 250 else if(_type == WCAccountTypeGroup && [other type] == WCAccountTypeUser) 251 return NSOrderedDescending; 252 else 253 result = [self nameSort:other]; 254 255 return result; 256 } 257 242 258 @end WiredClient/trunk/WCAccounts.h
r944 r1086 1 /* $Id: WCAccounts.h,v 1. 1 2004/03/08 19:23:42morris Exp $ */1 /* $Id: WCAccounts.h,v 1.2 2004/03/27 21:36:15 morris Exp $ */ 2 2 3 3 /* … … 34 34 IBOutlet NSTableView *_accountsTableView; 35 35 36 IBOutlet NSTableColumn *_iconTableColumn;37 36 IBOutlet NSTableColumn *_nameTableColumn; 38 37 … … 49 48 NSImage *_userImage, *_groupImage; 50 49 int _users, _groups; 50 51 NSImage *_sortUpImage, *_sortDownImage; 52 NSTableColumn *_lastTableColumn; 53 BOOL _sortDescending; 51 54 } 52 55 WiredClient/trunk/WCAccounts.m
r1037 r1086 1 /* $Id: WCAccounts.m,v 1. 3 2004/03/18 18:14:37morris Exp $ */1 /* $Id: WCAccounts.m,v 1.4 2004/03/27 21:36:15 morris Exp $ */ 2 2 3 3 /* … … 33 33 #import "WCConnection.h" 34 34 #import "WCError.h" 35 #import "WCIconCell.h" 35 36 #import "WCMain.h" 36 37 #import "WCPreferences.h" … … 105 106 106 107 - (void)windowDidLoad { 107 NSImageCell *imageCell;108 109 // --- set up the icon column for images110 i mageCell = [[NSImageCell alloc] init];111 [ _iconTableColumn setDataCell:imageCell];112 [i mageCell release];108 WCIconCell *iconCell; 109 110 // --- set up our custom cell type 111 iconCell = [[WCIconCell alloc] initWithImageWidth:16 whitespace:NO]; 112 [[_accountsTableView tableColumnWithIdentifier:@"Name"] setDataCell:iconCell]; 113 [iconCell release]; 113 114 114 115 // --- double-click 115 116 [_accountsTableView setDoubleAction:@selector(edit:)]; 117 118 // --- get the sort images 119 _sortUpImage = [[NSImage imageNamed:@"SortUp"] retain]; 120 _sortDownImage = [[NSImage imageNamed:@"SortDown"] retain]; 116 121 117 122 // --- window position 118 123 [self setShouldCascadeWindows:NO]; 119 124 [self setWindowFrameAutosaveName:@"Accounts"]; 125 126 // --- simulate a click on the name column to sort by name 127 [self tableView:_accountsTableView didClickTableColumn: 128 [_accountsTableView tableColumnWithIdentifier:@"Name"]]; 120 129 121 130 // --- start off in the table view … … 276 285 277 286 - (void)accountsShouldCompleteGroups:(NSNotification *)notification { 278 NSString *argument ;287 NSString *argument, *identifier; 279 288 WCConnection *connection; 280 289 … … 301 310 [_shownAccounts addObjectsFromArray:_allAccounts]; 302 311 312 // --- get identifier 313 identifier = [_lastTableColumn identifier]; 314 303 315 // --- sort the list 304 [_shownAccounts sortUsingSelector:@selector(nameSort:)]; 305 316 if([identifier isEqualToString:@"Name"]) 317 [_shownAccounts sortUsingSelector:@selector(nameSort:)]; 318 else if([identifier isEqualToString:@"Type"]) 319 [_shownAccounts sortUsingSelector:@selector(typeSort:)]; 320 306 321 // --- we're done 307 322 [_progressIndicator stopAnimation:self]; … … 525 540 526 541 527 - (id)tableView:(NSTableView *)sender objectValueForTableColumn:(NSTableColumn *)column row:(int)row { 542 - (void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn { 543 NSImage *sortImage; 544 NSString *identifier; 545 546 if(_lastTableColumn == tableColumn) { 547 // --- invert sorting 548 _sortDescending = !_sortDescending; 549 } else { 550 _sortDescending = NO; 551 552 if(_lastTableColumn) 553 [tableView setIndicatorImage:NULL inTableColumn:_lastTableColumn]; 554 555 // --- set the new sorting selector 556 _lastTableColumn = tableColumn; 557 558 // --- get identifier 559 identifier = [tableColumn identifier]; 560 561 if([identifier isEqualToString:@"Name"]) 562 [_shownAccounts sortUsingSelector:@selector(nameSort:)]; 563 else if([identifier isEqualToString:@"Type"]) 564 [_shownAccounts sortUsingSelector:@selector(typeSort:)]; 565 566 [tableView setHighlightedTableColumn:tableColumn]; 567 } 568 569 // --- set the image for the new column header 570 sortImage = _sortDescending ? _sortDownImage : _sortUpImage; 571 [tableView setIndicatorImage:sortImage inTableColumn:tableColumn]; 572 [tableView reloadData]; 573 } 574 575 576 577 - (id)tableView:(NSTableView *)sender objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row { 528 578 WCAccount *account; 579 NSString *identifier; 580 int i; 529 581 530 582 // --- get account 531 account = [_shownAccounts objectAtIndex:row]; 583 i = _sortDescending ? [_shownAccounts count] - (unsigned int) row - 1 : (unsigned int) row; 584 account = [_shownAccounts objectAtIndex:i]; 585 identifier = [tableColumn identifier]; 532 586 533 587 // --- populate columns 534 if(column == _iconTableColumn) { 588 if([identifier isEqualToString:@"Name"]) { 589 NSImage *icon; 590 535 591 switch([account type]) { 536 592 case WCAccountTypeUser: 537 return_userImage;593 icon = _userImage; 538 594 break; 539 595 540 596 case WCAccountTypeGroup: 541 return_groupImage;597 icon = _groupImage; 542 598 break; 543 599 } 544 545 return NULL;600 601 return [NSArray arrayWithObjects:[account name], icon, NULL]; 546 602 } 547 else if(column == _nameTableColumn) { 548 return [account name]; 603 else if([identifier isEqualToString:@"Type"]) { 604 switch([account type]) { 605 case WCAccountTypeUser: 606 return NSLocalizedString(@"User", @"Account type"); 607 break; 608 609 case WCAccountTypeGroup: 610 return NSLocalizedString(@"Group", @"Account type"); 611 break; 612 } 549 613 } 550 614
