Changeset 3570
- Timestamp:
- 01/26/07 21:45:40 (2 years ago)
- Files:
-
- trunk/Panels/JVChatRoomPanel.m (modified) (9 diffs)
- trunk/Panels/JVDirectChatPanel.h (modified) (1 diff)
- trunk/Panels/JVDirectChatPanel.m (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Panels/JVChatRoomPanel.m
r3534 r3570 242 242 } 243 243 244 [menu addItem:[NSMenuItem separatorItem]]; 245 246 item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Ignore Notifications", "lists whether or not notifications are enabled") action:@selector( toggleNotifications: ) keyEquivalent:@""]; 247 [item setEnabled:YES]; 248 [item setTarget:self]; 249 [menu addItem:item]; 250 [item release]; 251 244 252 return [menu autorelease]; 245 253 } … … 267 275 } 268 276 269 return YES;277 return [super validateMenuItem: menuItem]; 270 278 } 271 279 … … 332 340 [context setObject:self forKey:@"target"]; 333 341 [context setObject:NSStringFromSelector( @selector( activate: ) ) forKey:@"action"]; 334 [ [JVNotificationController defaultController]performNotification:@"JVChatRoomActivity" withContextInfo:context];342 [self performNotification:@"JVChatRoomActivity" withContextInfo:context]; 335 343 } 336 344 … … 342 350 [context setObject:self forKey:@"target"]; 343 351 [context setObject:NSStringFromSelector( @selector( activate: ) ) forKey:@"action"]; 344 [ [JVNotificationController defaultController]performNotification:@"JVChatReplyAfterAddressing" withContextInfo:context];352 [self performNotification:@"JVChatReplyAfterAddressing" withContextInfo:context]; 345 353 346 354 [_nextMessageAlertMembers removeObject:[message sender]]; … … 958 966 [context setObject:self forKey:@"target"]; 959 967 [context setObject:NSStringFromSelector( @selector( activate: ) ) forKey:@"action"]; 960 [ [JVNotificationController defaultController]performNotification:@"JVChatMemberJoinedRoom" withContextInfo:context];968 [self performNotification:@"JVChatMemberJoinedRoom" withContextInfo:context]; 961 969 962 970 [listItem release]; … … 993 1001 [context setObject:self forKey:@"target"]; 994 1002 [context setObject:NSStringFromSelector( @selector( activate: ) ) forKey:@"action"]; 995 [ [JVNotificationController defaultController]performNotification:@"JVChatMemberLeftRoom" withContextInfo:context];1003 [self performNotification:@"JVChatMemberLeftRoom" withContextInfo:context]; 996 1004 997 1005 [_preferredTabCompleteNicknames removeObject:[mbr nickname]]; … … 1036 1044 [context setObject:self forKey:@"target"]; 1037 1045 [context setObject:NSStringFromSelector( @selector( activate: ) ) forKey:@"action"]; 1038 [ [JVNotificationController defaultController]performNotification:@"JVChatMemberKicked" withContextInfo:context];1046 [self performNotification:@"JVChatMemberKicked" withContextInfo:context]; 1039 1047 1040 1048 // auto-rejoin on kick … … 1090 1098 [context setObject:self forKey:@"target"]; 1091 1099 [context setObject:NSStringFromSelector( @selector( activate: ) ) forKey:@"action"]; 1092 [ [JVNotificationController defaultController]performNotification:@"JVChatMemberKicked" withContextInfo:context];1100 [self performNotification:@"JVChatMemberKicked" withContextInfo:context]; 1093 1101 1094 1102 [mbr release]; … … 1314 1322 [context setObject:self forKey:@"target"]; 1315 1323 [context setObject:NSStringFromSelector( @selector( activate: ) ) forKey:@"action"]; 1316 [ [JVNotificationController defaultController]performNotification:notificationKey withContextInfo:context];1324 [self performNotification:notificationKey withContextInfo:context]; 1317 1325 } 1318 1326 } trunk/Panels/JVDirectChatPanel.h
r3561 r3570 63 63 - (JVMutableChatMessage *) currentMessage; 64 64 65 - (void) performNotification:(NSString *) identifier withContextInfo:(NSDictionary *) context; 66 65 67 - (unsigned int) newMessagesWaiting; 66 68 - (unsigned int) newHighlightMessagesWaiting; trunk/Panels/JVDirectChatPanel.m
r3561 r3570 462 462 [menu addItem:[NSMenuItem separatorItem]]; 463 463 464 item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Ignore Notifications", "lists whether or not notifications are enabled for this conversation") action:@selector( toggleNotifications: ) keyEquivalent:@""]; 465 [item setTarget:self]; 466 [menu addItem:item]; 467 [item release]; 468 469 [menu addItem:[NSMenuItem separatorItem]]; 470 464 471 if( [[[self windowController] allChatViewControllers] count] > 1 ) { 465 472 item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Detach From Window", "detach from window contextual menu item title" ) action:@selector( detachView: ) keyEquivalent:@""]; … … 483 490 484 491 return [menu autorelease]; 492 } 493 494 - (BOOL) validateMenuItem:(NSMenuItem *) menuItem { 495 if( [menuItem action] == @selector( toggleNotifications: ) ) { 496 if( [[self preferenceForKey:@"muted"] boolValue] ) 497 [menuItem setState:NSOnState]; 498 else [menuItem setState:NSOffState]; 499 } 500 501 return YES; 485 502 } 486 503 … … 830 847 [context setObject:self forKey:@"target"]; 831 848 [context setObject:NSStringFromSelector( @selector( activate: ) ) forKey:@"action"]; 832 [ [JVNotificationController defaultController]performNotification:@"JVChatMentioned" withContextInfo:context];849 [self performNotification:@"JVChatMentioned" withContextInfo:context]; 833 850 } 834 851 … … 839 856 else [context setObject:[NSString stringWithFormat:NSLocalizedString( @"%@'s message was ignored.", "direct chat user ignored bubble text" ), user] forKey:@"description"]; 840 857 [context setObject:[NSImage imageNamed:@"activity"] forKey:@"image"]; 841 [ [JVNotificationController defaultController]performNotification:( ( [cmessage ignoreStatus] == JVUserIgnored ) ? @"JVUserIgnored" : @"JVMessageIgnored" ) withContextInfo:context];858 [self performNotification:( ( [cmessage ignoreStatus] == JVUserIgnored ) ? @"JVUserIgnored" : @"JVMessageIgnored" ) withContextInfo:context]; 842 859 } 843 860 … … 889 906 [context setObject:self forKey:@"target"]; 890 907 [context setObject:NSStringFromSelector( @selector( activate: ) ) forKey:@"action"]; 891 [ [JVNotificationController defaultController]performNotification:@"JVChatFirstMessage" withContextInfo:context];908 [self performNotification:@"JVChatFirstMessage" withContextInfo:context]; 892 909 } else if( [message ignoreStatus] == JVNotIgnored ) { 893 910 NSMutableDictionary *context = [NSMutableDictionary dictionary]; … … 899 916 [context setObject:self forKey:@"target"]; 900 917 [context setObject:NSStringFromSelector( @selector( activate: ) ) forKey:@"action"]; 901 [ [JVNotificationController defaultController]performNotification:@"JVChatAdditionalMessages" withContextInfo:context];918 [self performNotification:@"JVChatAdditionalMessages" withContextInfo:context]; 902 919 } 903 920 } … … 944 961 - (JVMutableChatMessage *) currentMessage { 945 962 return _currentMessage; 963 } 964 965 #pragma mark - 966 #pragma mark Notifications Handling 967 968 /** 969 * This method should be used to handle all notification processing. It will check to see if 970 * notifications have been muted for the given chat room, and if they have, it will not pass 971 * the notification request on to the JVNotificationController. 972 */ 973 - (void) performNotification:(NSString *) identifier withContextInfo:(NSDictionary *) context { 974 if( ![[self preferenceForKey:@"muted"] boolValue] ) 975 [[JVNotificationController defaultController] performNotification:identifier withContextInfo:context]; 976 } 977 978 /** 979 * Toggles notifications (this is for private, direct user-user chats) 980 */ 981 - (IBAction) toggleNotifications:(id) sender { 982 if( [self preferenceForKey:@"muted"] == [NSNumber numberWithBool:YES] ) 983 [self setPreference:[NSNumber numberWithBool:NO] forKey:@"muted"]; 984 else [self setPreference:[NSNumber numberWithBool:YES] forKey:@"muted"]; 946 985 } 947 986
