Changeset 3545
- Timestamp:
- 01/20/06 20:04:58 (3 years ago)
- Files:
-
- WiredClient/trunk/WCApplicationController.m (modified) (1 diff)
- WiredClient/trunk/WCChat.h (modified) (1 diff)
- WiredClient/trunk/WCChat.m (modified) (1 diff)
- WiredClient/trunk/WCConnectionController.m (modified) (2 diffs)
- WiredClient/trunk/WCDock.m (modified) (13 diffs)
- WiredClient/trunk/WCMessagesWindow.m (modified) (1 diff)
- WiredClient/trunk/WCPublicChat.m (modified) (1 diff)
- WiredClient/trunk/WCServerConnection.h (modified) (1 diff)
- WiredClient/trunk/WCServerConnection.m (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredClient/trunk/WCApplicationController.m
r3542 r3545 276 276 if(selector == @selector(hideConnection:)) 277 277 return ([self _shownConnection] != NULL); 278 else if(selector == @selector(nextConnection:)) 279 return ([self _shownConnection] != NULL); 280 else if(selector == @selector(previousConnection:)) 281 return ([self _shownConnection] != NULL); 278 else if(selector == @selector(nextConnection:) || selector == @selector(previousConnection:)) 279 return [[WCDock dock] validateMenuItem:item]; 282 280 283 281 return YES; WiredClient/trunk/WCChat.h
r3540 r3545 79 79 - (id)initChatWithConnection:(WCServerConnection *)connection windowNibName:(NSString *)windowNibName name:(NSString *)name; 80 80 81 - (void)serverConnectionLoggedIn:(NSNotification *)notification; 82 81 83 - (void)validate; 82 84 WiredClient/trunk/WCChat.m
r3540 r3545 599 599 600 600 601 - (void)serverConnection WillReconnect:(NSNotification *)notification {601 - (void)serverConnectionLoggedIn:(NSNotification *)notification { 602 602 [_users removeAllObjects]; 603 603 [_shownUsers removeAllObjects]; WiredClient/trunk/WCConnectionController.m
r3540 r3545 126 126 127 127 - (void)serverConnectionShouldHide:(NSNotification *)notification { 128 // _hidden = ![[self window] isVisible]; 129 // [[self window] orderOut:self]; 128 _hidden = ![[self window] isVisible]; 129 130 [[self window] orderOut:self]; 130 131 } 131 132 … … 133 134 134 135 - (void)serverConnectionShouldUnhide:(NSNotification *)notification { 135 //if(!_hidden)136 //[[self window] orderFront:self];136 if(!_hidden) 137 [[self window] orderFront:self]; 137 138 } 138 139 WiredClient/trunk/WCDock.m
r3542 r3545 34 34 @interface WCDock(Private) 35 35 36 - (void)validate; 37 - (void)updateStatus; 38 39 - (WCServerConnection *)selectedConnection; 40 - (WCServerConnection *)connectionAtIndex:(int)index; 41 - (void)openConnection:(WCServerConnection *)connection; 36 - (void)_validate; 37 - (void)_updateStatus; 38 39 - (WCServerConnection *)_selectedConnection; 40 - (WCServerConnection *)_connectionAtIndex:(unsigned int)index; 41 42 - (void)_openConnection:(WCServerConnection *)connection; 43 44 @end 45 46 47 @implementation WCDock(Private) 48 49 - (void)_validate { 50 int row; 51 52 row = [_dockTableView selectedRow]; 53 54 [_openButton setEnabled:(row >= 0)]; 55 [_hideButton setEnabled:(row >= 0)]; 56 [_hideButton setTitle:[[self _selectedConnection] isHidden] 57 ? NSLS(@"Show", "Show/hide button title") 58 : NSLS(@"Hide", "Show/hide button title")]; 59 } 60 61 62 63 - (void)_updateStatus { 64 [_statusTextField setStringValue:[NSSWF: 65 NSLS(@"%u %@", @"Dock status (connections, 'connection(s)')"), 66 [_shownConnections count], 67 [_shownConnections count] == 1 68 ? NSLS(@"connection", @"Connection singular") 69 : NSLS(@"connections", @"Connection plural")]]; 70 } 71 72 73 74 #pragma mark - 75 76 - (WCServerConnection *)_selectedConnection { 77 int row; 78 79 row = [_dockTableView selectedRow]; 80 81 if(row < 0) 82 return NULL; 83 84 return [self _connectionAtIndex:row]; 85 } 86 87 88 89 - (WCServerConnection *)_connectionAtIndex:(unsigned int)index { 90 if(index < [_shownConnections count]) 91 return [_shownConnections objectAtIndex:index]; 92 93 return NULL; 94 } 95 96 97 98 #pragma mark - 99 100 - (void)_openConnection:(WCServerConnection *)connection { 101 NSEnumerator *enumerator; 102 WCServerConnection *eachConnection; 103 104 if(!connection) 105 return; 106 107 if([WCSettings boolForKey:WCAutoHideOnSwitch]) { 108 enumerator = [_shownConnections objectEnumerator]; 109 110 while((eachConnection = [enumerator nextObject])) { 111 if(eachConnection != connection && ![eachConnection isHidden]) 112 [eachConnection hide]; 113 } 114 115 [_dockTableView reloadData]; 116 } 117 118 if([connection isHidden]) 119 [connection unhide]; 120 121 [[connection chat] showWindow:self]; 122 123 [self _validate]; 124 } 42 125 43 126 @end … … 68 151 69 152 [self window]; 70 153 154 [[NSNotificationCenter defaultCenter] 155 addObserver:self 156 selector:@selector(connectionDidClose:) 157 name:WCConnectionDidClose]; 158 159 [[NSNotificationCenter defaultCenter] 160 addObserver:self 161 selector:@selector(connectionShouldTerminate:) 162 name:WCConnectionShouldTerminate]; 163 164 [[NSNotificationCenter defaultCenter] 165 addObserver:self 166 selector:@selector(serverConnectionLoggedIn:) 167 name:WCServerConnectionLoggedIn]; 168 169 [[NSNotificationCenter defaultCenter] 170 addObserver:self 171 selector:@selector(chatUsersDidChange:) 172 name:WCChatUsersDidChange]; 173 71 174 [[NSNotificationCenter defaultCenter] 72 175 addObserver:self … … 105 208 WIMultiImageCell *imageCell; 106 209 107 // --- set up our custom cell types108 210 iconCell = [[WIIconCell alloc] init]; 109 211 [iconCell setImageWidth:14.0]; … … 115 217 [imageCell release]; 116 218 117 // --- window position118 219 [self setShouldCascadeWindows:NO]; 119 220 [self setWindowFrameAutosaveName:@"Dock"]; 120 221 121 // --- set up table view122 222 [_dockTableView setDoubleAction:@selector(open:)]; 123 223 [_dockTableView setDrawsStripes:YES]; 124 224 [_dockTableView registerForDraggedTypes:[NSArray arrayWithObject:WCServerConnectionPboardType]]; 125 225 126 // --- update buttons 127 [self validate]; 128 [self updateStatus]; 129 } 130 131 132 133 - (void)connectionHasAttached:(NSNotification *)notification { 134 /* NSEnumerator *enumerator; 135 WCServerConnection *connection, *each; 136 137 // --- add connection 226 [self _validate]; 227 [self _updateStatus]; 228 } 229 230 231 232 - (void)connectionDidClose:(NSNotification *)notification { 233 [_dockTableView reloadData]; 234 } 235 236 237 238 - (void)connectionShouldTerminate:(NSNotification *)notification { 239 WCServerConnection *connection; 240 241 connection = [notification object]; 242 [_shownConnections removeObject:connection]; 243 [_dockTableView reloadData]; 244 245 [self _updateStatus]; 246 } 247 248 249 250 - (void)serverConnectionLoggedIn:(NSNotification *)notification { 251 NSEnumerator *enumerator; 252 WCServerConnection *connection, *eachConnection; 253 138 254 connection = [notification object]; 139 255 [_shownConnections addObject:connection]; 140 [_dockTableView reloadData]; 141 142 // --- hide all previously unhidden 256 143 257 if([WCSettings boolForKey:WCAutoHideOnSwitch]) { 144 258 enumerator = [_shownConnections objectEnumerator]; 145 259 146 while((each = [enumerator nextObject])) {147 if(each != connection && ![connection isHidden])148 [each postNotificationName:WCConnectionShouldHide object:each];260 while((eachConnection = [enumerator nextObject])) { 261 if(eachConnection != connection && ![connection isHidden]) 262 [eachConnection hide]; 149 263 } 150 264 } 151 265 152 266 [_dockTableView reloadData]; 153 [self updateStatus];*/ 154 } 155 156 157 158 - (void)connectionHasClosed:(NSNotification *)notification { 159 [_dockTableView reloadData]; 160 } 161 162 163 164 - (void)connectionShouldTerminate:(NSNotification *)notification { 267 [self _updateStatus]; 268 } 269 270 271 272 - (void)chatUsersDidChange:(NSNotification *)notification { 273 [_dockTableView reloadData]; 274 } 275 276 277 278 - (void)messagesDidAddMessage:(NSNotification *)notification { 279 [_dockTableView reloadData]; 280 } 281 282 283 284 - (void)messagesDidReadMessage:(NSNotification *)notification { 285 [_dockTableView reloadData]; 286 } 287 288 289 290 - (void)newsDidAddPost:(NSNotification *)notification { 291 [_dockTableView reloadData]; 292 } 293 294 295 296 - (void)newsDidReadPost:(NSNotification *)notification { 297 [_dockTableView reloadData]; 298 } 299 300 301 302 #pragma mark - 303 304 - (BOOL)validateMenuItem:(NSMenuItem *)item { 305 SEL selector; 306 307 selector = [item action]; 308 309 if(selector == @selector(nextConnection:) || selector == @selector(previousConnection:)) 310 return ([_shownConnections count] > 0); 311 312 return YES; 313 } 314 315 316 317 #pragma mark - 318 319 - (IBAction)open:(id)sender { 320 [self _openConnection:[self _selectedConnection]]; 321 } 322 323 324 325 - (IBAction)hide:(id)sender { 165 326 WCServerConnection *connection; 166 167 connection = [notification object]; 168 [_shownConnections removeObject:connection]; 169 [_dockTableView reloadData]; 170 [self updateStatus]; 171 } 172 173 174 175 - (void)chatUsersDidChange:(NSNotification *)notification { 176 [_dockTableView reloadData]; 177 } 178 179 180 181 - (void)messagesDidAddMessage:(NSNotification *)notification { 182 [_dockTableView reloadData]; 183 } 184 185 186 187 - (void)messagesDidReadMessage:(NSNotification *)notification { 188 [_dockTableView reloadData]; 189 } 190 191 192 193 - (void)newsDidAddPost:(NSNotification *)notification { 194 [_dockTableView reloadData]; 195 } 196 197 198 199 - (void)newsDidReadPost:(NSNotification *)notification { 200 [_dockTableView reloadData]; 201 } 202 203 204 205 #pragma mark - 206 207 - (void)validate { 208 int row; 209 210 row = [_dockTableView selectedRow]; 211 212 [_openButton setEnabled:(row >= 0)]; 213 [_hideButton setEnabled:(row >= 0)]; 214 [_hideButton setTitle:[[self selectedConnection] isHidden] 215 ? NSLS(@"Show", "Show/hide button title") 216 : NSLS(@"Hide", "Show/hide button title")]; 217 } 218 219 220 221 - (BOOL)validateMenuItem:(NSMenuItem *)item { 222 NSLog(@"%@", item); 223 return YES; 224 } 225 226 227 228 - (void)updateStatus { 229 [_statusTextField setStringValue:[NSSWF: 230 NSLS(@"%u %@", @"Dock status (connections, 'connection(s)')"), 231 [_shownConnections count], 232 [_shownConnections count] == 1 233 ? NSLS(@"connection", @"Connection singular") 234 : NSLS(@"connections", @"Connection plural")]]; 235 } 236 237 238 239 - (WCServerConnection *)selectedConnection { 240 int row; 241 242 row = [_dockTableView selectedRow]; 243 244 if(row < 0) 245 return NULL; 246 247 return [self connectionAtIndex:row]; 248 } 249 250 251 252 - (WCServerConnection *)connectionAtIndex:(int)index { 253 return [_shownConnections objectAtIndex:index]; 254 } 255 256 257 258 - (void)openConnection:(WCServerConnection *)connection { 259 /* NSEnumerator *enumerator; 260 WCServerConnection *each; 261 262 if(connection) { 263 // --- hide all previously unhidden 264 if([WCSettings boolForKey:WCAutoHideOnSwitch]) { 265 enumerator = [_shownConnections objectEnumerator]; 266 267 while((each = [enumerator nextObject])) { 268 if(each != connection && ![each isHidden]) 269 [each postNotificationName:WCConnectionShouldHide object:each]; 270 } 271 } 272 273 [_dockTableView reloadData]; 274 275 // --- unhide first 276 if([connection isHidden]) 277 [connection postNotificationName:WCConnectionShouldUnhide object:connection]; 278 279 // --- show connection 280 [[connection chat] showWindow:self]; 281 [self validate]; 282 }*/ 283 } 284 285 286 287 #pragma mark - 288 289 - (IBAction)open:(id)sender { 290 [self openConnection:[self selectedConnection]]; 291 } 292 293 294 295 - (IBAction)hide:(id)sender { 296 /* WCServerConnection *connection; 297 298 connection = [self selectedConnection]; 327 328 connection = [self _selectedConnection]; 299 329 300 330 if([connection isHidden]) 301 [connection postNotificationName:WCConnectionShouldUnhide object:connection];331 [connection unhide]; 302 332 else 303 [connection postNotificationName:WCConnectionShouldHide object:connection];304 305 [self validate];306 [_dockTableView setNeedsDisplay:YES]; */333 [connection hide]; 334 335 [self _validate]; 336 [_dockTableView setNeedsDisplay:YES]; 307 337 } 308 338 … … 310 340 311 341 - (IBAction)hideConnection:(id)sender { 312 /*WCServerConnection *connection;342 WCServerConnection *connection; 313 343 314 344 connection = [(WCConnectionController *) [[NSApp keyWindow] windowController] connection]; 315 [connection postNotificationName:WCConnectionShouldHide object:connection];316 317 [self validate];318 [_dockTableView setNeedsDisplay:YES]; */345 [connection hide]; 346 347 [self _validate]; 348 [_dockTableView setNeedsDisplay:YES]; 319 349 } 320 350 … … 325 355 int i; 326 356 327 connection = [(WCConnectionController *) [[NSApp keyWindow] windowController] connection]; 357 if([[[NSApp keyWindow] windowController] isKindOfClass:[WCConnectionController class]]) 358 connection = [(WCConnectionController *) [[NSApp keyWindow] windowController] connection]; 359 else 360 connection = [_shownConnections lastObject]; 361 362 if(!connection) 363 return; 364 328 365 i = [_shownConnections indexOfObject:connection] + 1; 329 366 330 367 if((unsigned int) i >= [_shownConnections count]) 331 368 i = 0; 332 333 nextConnection = [ _shownConnections objectAtIndex:i];334 369 370 nextConnection = [self _connectionAtIndex:i]; 371 335 372 if(connection != nextConnection) 336 [self openConnection:nextConnection];373 [self _openConnection:nextConnection]; 337 374 } 338 375 … … 343 380 int i; 344 381 345 connection = [(WCConnectionController *) [[NSApp keyWindow] windowController] connection]; 382 if([[[NSApp keyWindow] windowController] isKindOfClass:[WCConnectionController class]]) 383 connection = [(WCConnectionController *) [[NSApp keyWindow] windowController] connection]; 384 else 385 connection = [self _connectionAtIndex:0]; 386 387 if(!connection) 388 return; 389 346 390 i = [_shownConnections indexOfObject:connection] - 1; 347 391 … … 349 393 i = [_shownConnections count] - 1; 350 394 351 previousConnection = [ _shownConnections objectAtIndex:i];395 previousConnection = [self _connectionAtIndex:i]; 352 396 353 397 if(connection != previousConnection) 354 [self openConnection:previousConnection];398 [self _openConnection:previousConnection]; 355 399 } 356 400 … … 370 414 NSMutableArray *images; 371 415 372 connection = [self connectionAtIndex:row];416 connection = [self _connectionAtIndex:row]; 373 417 374 418 if(tableColumn == _nameTableColumn) { … … 399 443 400 444 // --- has unread posts? 401 if([[connection messages] numberOfUnreadMessages] > 0) {445 if([[connection news] numberOfUnreadPosts] > 0) { 402 446 [images addObject:[connection isHidden] 403 447 ? [_postsImage tintedImageWithColor:[NSColor colorWithDeviceWhite:1.0 alpha:0.5]] … … 422 466 - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(int)row { 423 467 if([cell respondsToSelector:@selector(setTextColor:)]) { 424 // --- gray out hidden connections 425 [cell setTextColor:[[self connectionAtIndex:row] isHidden] 468 [cell setTextColor:[[self _connectionAtIndex:row] isHidden] 426 469 ? [NSColor grayColor] 427 470 : [NSColor blackColor]]; … … 432 475 433 476 - (void)tableViewSelectionDidChange:(NSNotification *)notification { 434 [self validate];435 [self updateStatus];477 [self _validate]; 478 [self _updateStatus]; 436 479 } 437 480 … … 452 495 453 496 - (NSDragOperation)tableView:(NSTableView*)tableView validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)operation { 454 // --- only accept drops in between rows455 497 if(operation != NSTableViewDropAbove) 456 498 return NSDragOperationNone; WiredClient/trunk/WCMessagesWindow.m
r3427 r3545 51 51 } 52 52 53 if([[event characters] isComposedOfCharactersFromSet:characterSet]) { 53 if([[event characters] isComposedOfCharactersFromSet:characterSet] && 54 [event character] != '\t') { 54 55 [[self delegate] showPrivateMessageReplyWithString:[event characters]]; 55 56 WiredClient/trunk/WCPublicChat.m
r3542 r3545 283 283 - (void)serverConnectionLoggedIn:(NSNotification *)notification { 284 284 [self showWindow:self]; 285 286 [super serverConnectionLoggedIn:notification]; 285 287 } 286 288 WiredClient/trunk/WCServerConnection.h
r3540 r3545 132 132 133 133 - (void)reconnect; 134 - (void)hide; 135 - (void)unhide; 134 136 135 137 - (BOOL)isReconnecting; WiredClient/trunk/WCServerConnection.m
r3542 r3545 68 68 _notificationCenter = [[NSNotificationCenter alloc] init]; 69 69 70 [self window]; 71 70 72 [self addObserver:self 71 73 selector:@selector(connectionDidConnect:) … … 116 118 name:WCServerConnectionReceivedPrivileges]; 117 119 118 [self window]; 120 [self addObserver:self 121 selector:@selector(serverConnectionShouldHide:) 122 name:WCServerConnectionShouldHide]; 123 124 [self addObserver:self 125 selector:@selector(serverConnectionShouldUnhide:) 126 name:WCServerConnectionShouldUnhide]; 119 127 120 128 return self; … … 416 424 417 425 426 - (void)serverConnectionShouldHide:(NSNotification *)notification { 427 _hidden = YES; 428 } 429 430 431 432 - (void)serverConnectionShouldUnhide:(NSNotification *)notification { 433 _hidden = NO; 434 } 435 436 437 418 438 #pragma mark - 419 439 … … 734 754 735 755 756 - (void)terminate { 757 [self postNotificationName:WCConnectionShouldTerminate object:self]; 758 } 759 760 761 736 762 - (void)reconnect { 737 763 [self postNotificationName:WCServerConnectionWillReconnect object:self]; … … 744 770 745 771 746 - (void)terminate { 747 [self postNotificationName:WCConnectionShouldTerminate object:self]; 772 - (void)hide { 773 [self postNotificationName:WCServerConnectionShouldHide object:self]; 774 } 775 776 777 778 - (void)unhide { 779 [self postNotificationName:WCServerConnectionShouldUnhide object:self]; 748 780 } 749 781
