Changeset 3544

Show
Ignore:
Timestamp:
01/07/07 20:01:50 (2 years ago)
Author:
timothy
Message:

Clean up code and user a standard menu for all chat users. Removes a couple duplicate send file dialogs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Controllers/JVChatWindowController.m

    r3471 r3544  
    962962        NSArray *results = [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 
    963963        if( [results count] ) { 
    964                 [menu addItem:[NSMenuItem separatorItem]]; 
     964                if( [menu numberOfItems ] && ! [[[menu itemArray] lastObject] isSeparatorItem] ) 
     965                        [menu addItem:[NSMenuItem separatorItem]]; 
    965966 
    966967                NSArray *items = nil; 
  • trunk/Controllers/JVTabbedChatWindowController.m

    r3471 r3544  
    287287                NSArray *results = [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 
    288288                if( [results count] ) { 
    289                         [menu addItem:[NSMenuItem separatorItem]]; 
     289                        if( [menu numberOfItems ] && ! [[[menu itemArray] lastObject] isSeparatorItem] ) 
     290                                [menu addItem:[NSMenuItem separatorItem]]; 
    290291 
    291292                        NSArray *items = nil; 
  • trunk/Controllers/MVBuddyListController.h

    r3492 r3544  
    1818        @private 
    1919        IBOutlet MVTableView *buddies; 
    20         IBOutlet NSMenu *actionMenu; 
    2120        IBOutlet NSButton *sendMessageButton; 
     21        IBOutlet NSButton *actionButton; 
    2222        IBOutlet NSButton *infoButton; 
    2323 
  • trunk/Controllers/MVBuddyListController.m

    r3500 r3544  
    11#import "MVBuddyListController.h" 
     2 
    23#import "JVBuddy.h" 
    34#import "JVChatController.h" 
     5#import "JVDetailCell.h" 
     6#import "JVInspectorController.h" 
     7#import "JVNotificationController.h" 
     8#import "MVChatUserAdditions.h" 
    49#import "MVConnectionsController.h" 
    510#import "MVFileTransferController.h" 
    6 #import "JVNotificationController.h" 
    7 #import "JVInspectorController.h" 
    811#import "MVTableView.h" 
    9 #import "JVDetailCell.h" 
    1012 
    1113static MVBuddyListController *sharedInstance = nil; 
     
    1719- (void) _setBuddiesNeedSortAnimated; 
    1820- (void) _sortBuddiesAnimated:(id) sender; 
     21- (NSMenu *) _menuForBuddy:(JVBuddy *) buddy; 
    1922@end 
    2023 
     
    386389- (IBAction) sendFileToSelectedBuddy:(id) sender { 
    387390        if( [buddies selectedRow] == -1 ) return; 
    388         BOOL passive = [[NSUserDefaults standardUserDefaults] boolForKey:@"JVSendFilesPassively"]; 
    389391        JVBuddy *buddy = [_buddyOrder objectAtIndex:[buddies selectedRow]]; 
    390392        MVChatUser *user = [buddy activeUser]; 
    391         if( [user type] != MVChatRemoteUserType ) return; 
    392  
    393         NSOpenPanel *panel = [NSOpenPanel openPanel]; 
    394         [panel setResolvesAliases:YES]; 
    395         [panel setCanChooseFiles:YES]; 
    396         [panel setCanChooseDirectories:NO]; 
    397         [panel setAllowsMultipleSelection:YES]; 
    398  
    399         NSView *view = [[NSView alloc] initWithFrame:NSMakeRect( 0., 0., 200., 28. )]; 
    400         [view setAutoresizingMask:( NSViewWidthSizable | NSViewMaxXMargin )]; 
    401  
    402         NSButton *passiveButton = [[NSButton alloc] initWithFrame:NSMakeRect( 0., 6., 200., 18. )]; 
    403         [[passiveButton cell] setButtonType:NSSwitchButton]; 
    404         [passiveButton setState:passive]; 
    405         [passiveButton setTitle:NSLocalizedString( @"Send File Passively", "send files passively file send open dialog button" )]; 
    406         [passiveButton sizeToFit]; 
    407  
    408         NSRect frame = [view frame]; 
    409         frame.size.width = NSWidth( [passiveButton frame] ); 
    410  
    411         [view setFrame:frame]; 
    412         [view addSubview:passiveButton]; 
    413         [passiveButton release]; 
    414  
    415         [panel setAccessoryView:view]; 
    416         [view release]; 
    417  
    418         if( [panel runModalForTypes:nil] == NSOKButton ) { 
    419                 NSEnumerator *enumerator = [[panel filenames] objectEnumerator]; 
    420                 passive = [passiveButton state]; 
    421                 NSString *path = nil; 
    422                 while( ( path = [enumerator nextObject] ) ) 
    423                         [[MVFileTransferController defaultController] addFileTransfer:[user sendFile:path passively:passive]]; 
    424         } 
     393        [user sendFile:sender]; 
    425394} 
    426395 
     
    737706 
    738707- (NSMenu *) tableView:(MVTableView *) tableView menuForTableColumn:(NSTableColumn *) tableColumn row:(int) row { 
    739         if( tableView != buddies ) return nil; 
    740  
    741         NSMenu *menu = [actionMenu copyWithZone:[self zone]]; 
     708        if( tableView != buddies || row == -1 || row >= (int)[_buddyOrder count] ) return nil; 
    742709        JVBuddy *buddy = [_buddyOrder objectAtIndex:row]; 
    743  
    744         NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( NSArray * ), @encode( id ), @encode( id ), nil]; 
    745         NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 
    746         id view = nil; 
    747  
    748         [invocation setSelector:@selector( contextualMenuItemsForObject:inView: )]; 
    749         [invocation setArgument:&buddy atIndex:2]; 
    750         [invocation setArgument:&view atIndex:3]; 
    751  
    752         NSArray *results = [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 
    753         if( [results count] ) { 
    754                 [menu addItem:[NSMenuItem separatorItem]]; 
    755  
    756                 NSArray *items = nil; 
    757                 NSMenuItem *item = nil; 
    758                 NSEnumerator *enumerator = [results objectEnumerator]; 
    759                 while( ( items = [enumerator nextObject] ) ) { 
    760                         if( ! [items respondsToSelector:@selector( objectEnumerator )] ) continue; 
    761                         NSEnumerator *ienumerator = [items objectEnumerator]; 
    762                         while( ( item = [ienumerator nextObject] ) ) 
    763                                 if( [item isKindOfClass:[NSMenuItem class]] ) [menu addItem:item]; 
    764                 } 
    765  
    766                 if( [[[menu itemArray] lastObject] isSeparatorItem] ) 
    767                         [menu removeItem:[[menu itemArray] lastObject]]; 
    768         } 
    769  
    770         return [menu autorelease]; 
     710        return [self _menuForBuddy:buddy]; 
    771711} 
    772712 
     
    802742        [sendMessageButton setEnabled:enabled]; 
    803743        [infoButton setEnabled:enabled]; 
     744        [actionButton setEnabled:enabled]; 
     745 
     746        if( [buddies selectedRow] != -1 ) { 
     747                JVBuddy *buddy = [_buddyOrder objectAtIndex:[buddies selectedRow]]; 
     748                [actionButton setMenu:[self _menuForBuddy:buddy]]; 
     749        } else { 
     750                [actionButton setMenu:nil]; 
     751        } 
     752 
    804753        [[JVInspectorController sharedInspector] inspectObject:[self objectToInspect]]; 
    805754} 
     
    10841033        [list release]; 
    10851034} 
     1035 
     1036- (NSMenu *) _menuForBuddy:(JVBuddy *) buddy { 
     1037        NSMenu *menu = [[NSMenu alloc] initWithTitle:@""]; 
     1038        NSMenuItem *item = nil; 
     1039 
     1040        NSArray *standardItems = [[buddy activeUser] standardMenuItems]; 
     1041        NSEnumerator *enumerator = [standardItems objectEnumerator]; 
     1042        while( ( item = [enumerator nextObject] ) ) { 
     1043                if( [item action] == @selector( addBuddy: ) ) 
     1044                        continue; 
     1045                if( [item action] == @selector( toggleIgnore: ) ) 
     1046                        continue; 
     1047                [menu addItem:item]; 
     1048        } 
     1049 
     1050        NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( NSArray * ), @encode( id ), @encode( id ), nil]; 
     1051        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 
     1052        id view = nil; 
     1053 
     1054        [invocation setSelector:@selector( contextualMenuItemsForObject:inView: )]; 
     1055        [invocation setArgument:&buddy atIndex:2]; 
     1056        [invocation setArgument:&view atIndex:3]; 
     1057 
     1058        NSArray *results = [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 
     1059        if( [results count] ) { 
     1060                if( [menu numberOfItems ] && ! [[[menu itemArray] lastObject] isSeparatorItem] ) 
     1061                        [menu addItem:[NSMenuItem separatorItem]]; 
     1062 
     1063                NSArray *items = nil; 
     1064                NSMenuItem *item = nil; 
     1065                NSEnumerator *enumerator = [results objectEnumerator]; 
     1066                while( ( items = [enumerator nextObject] ) ) { 
     1067                        if( ! [items respondsToSelector:@selector( objectEnumerator )] ) continue; 
     1068                        NSEnumerator *ienumerator = [items objectEnumerator]; 
     1069                        while( ( item = [ienumerator nextObject] ) ) 
     1070                                if( [item isKindOfClass:[NSMenuItem class]] ) [menu addItem:item]; 
     1071                } 
     1072 
     1073                if( [[[menu itemArray] lastObject] isSeparatorItem] ) 
     1074                        [menu removeItem:[[menu itemArray] lastObject]]; 
     1075        } 
     1076 
     1077        return [menu autorelease]; 
     1078} 
    10861079@end 
    10871080 
  • trunk/Controllers/MVConnectionsController.m

    r3524 r3544  
    11151115                NSArray *results = [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 
    11161116                if( [results count] ) { 
    1117                         [menu addItem:[NSMenuItem separatorItem]]; 
     1117                        if( [menu numberOfItems ] && ! [[[menu itemArray] lastObject] isSeparatorItem] ) 
     1118                                [menu addItem:[NSMenuItem separatorItem]]; 
    11181119 
    11191120                        NSArray *items = nil; 
  • trunk/Languages/Dutch.lproj/MVBuddyList.nib/classes.nib

    r3501 r3544  
    2828            LANGUAGE = ObjC;  
    2929            OUTLETS = { 
    30                 actionMenu = NSMenu;  
     30                actionButton = NSButton;  
    3131                addButton = NSButton;  
    3232                buddies = MVTableView;  
  • trunk/Languages/Dutch.lproj/MVBuddyList.nib/info.nib

    r3501 r3544  
    99                <key>148</key> 
    1010                <string>552 603 220 194 0 0 1280 832 </string> 
    11                 <key>168</key> 
    12                 <string>460 587 132 99 0 0 1440 878 </string> 
    1311        </dict> 
    1412        <key>IBFramework Version</key> 
     
    1816        <key>IBOpenObjects</key> 
    1917        <array> 
    20                 <integer>115</integer> 
    21                 <integer>80</integer> 
     18                <integer>41</integer> 
    2219        </array> 
    2320        <key>IBSystem Version</key> 
  • trunk/Languages/English.lproj/MVBuddyList.nib/classes.nib

    r3488 r3544  
    2828            LANGUAGE = ObjC;  
    2929            OUTLETS = { 
    30                 actionMenu = NSMenu;  
     30                actionButton = NSButton;  
    3131                addButton = NSButton;  
    3232                buddies = MVTableView;  
  • trunk/Languages/English.lproj/MVBuddyList.nib/info.nib

    r3488 r3544  
    88        <dict> 
    99                <key>148</key> 
    10                 <string>552 603 220 194 0 0 1280 832 </string> 
    11                 <key>168</key> 
    12                 <string>460 587 132 99 0 0 1440 878 </string> 
     10                <string>636 649 234 226 0 0 1440 878 </string> 
    1311        </dict> 
    1412        <key>IBFramework Version</key> 
     
    1816        <key>IBOpenObjects</key> 
    1917        <array> 
     18                <integer>80</integer> 
    2019                <integer>115</integer> 
    21                 <integer>80</integer> 
    22                 <integer>168</integer> 
     20                <integer>148</integer> 
     21                <integer>41</integer> 
    2322        </array> 
    2423        <key>IBSystem Version</key> 
  • trunk/Languages/French.lproj/MVBuddyList.nib/classes.nib

    r3501 r3544  
    2828            LANGUAGE = ObjC;  
    2929            OUTLETS = { 
    30                 actionMenu = NSMenu;  
     30                actionButton = NSButton;  
    3131                addButton = NSButton;  
    3232                buddies = MVTableView;  
  • trunk/Languages/French.lproj/MVBuddyList.nib/info.nib

    r3501 r3544  
    99                <key>148</key> 
    1010                <string>552 603 220 194 0 0 1280 832 </string> 
    11                 <key>168</key> 
    12                 <string>460 587 132 99 0 0 1440 878 </string> 
    1311        </dict> 
    1412        <key>IBFramework Version</key> 
     
    1816        <key>IBOpenObjects</key> 
    1917        <array> 
    20                 <integer>115</integer> 
    21                 <integer>80</integer> 
    2218                <integer>41</integer> 
    2319        </array> 
  • trunk/Languages/German.lproj/MVBuddyList.nib/classes.nib

    r3501 r3544  
    2828            LANGUAGE = ObjC;  
    2929            OUTLETS = { 
    30                 actionMenu = NSMenu;  
     30                actionButton = NSButton;  
    3131                addButton = NSButton;  
    3232                buddies = MVTableView;  
  • trunk/Languages/German.lproj/MVBuddyList.nib/info.nib

    r3501 r3544  
    99                <key>148</key> 
    1010                <string>552 603 220 194 0 0 1280 832 </string> 
    11                 <key>168</key> 
    12                 <string>460 587 132 99 0 0 1440 878 </string> 
    1311        </dict> 
    1412        <key>IBFramework Version</key> 
     
    1917        <array> 
    2018                <integer>115</integer> 
     19                <integer>41</integer> 
    2120        </array> 
    2221        <key>IBSystem Version</key> 
  • trunk/Languages/Italian.lproj/MVBuddyList.nib/classes.nib

    r3501 r3544  
    2828            LANGUAGE = ObjC;  
    2929            OUTLETS = { 
    30                 actionMenu = NSMenu;  
     30                actionButton = NSButton;  
    3131                addButton = NSButton;  
    3232                buddies = MVTableView;  
  • trunk/Languages/Italian.lproj/MVBuddyList.nib/info.nib

    r3501 r3544  
    99                <key>148</key> 
    1010                <string>552 603 220 194 0 0 1280 832 </string> 
    11                 <key>168</key> 
    12                 <string>460 587 173 99 0 0 1440 878 </string> 
    1311        </dict> 
    1412        <key>IBFramework Version</key> 
     
    1816        <key>IBOpenObjects</key> 
    1917        <array> 
    20                 <integer>168</integer> 
    21                 <integer>115</integer> 
     18                <integer>41</integer> 
    2219        </array> 
    2320        <key>IBSystem Version</key> 
  • trunk/Languages/Spanish.lproj/MVBuddyList.nib/classes.nib

    r3501 r3544  
    2828            LANGUAGE = ObjC;  
    2929            OUTLETS = { 
    30                 actionMenu = NSMenu;  
     30                actionButton = NSButton;  
    3131                addButton = NSButton;  
    3232                buddies = MVTableView;  
  • trunk/Languages/Spanish.lproj/MVBuddyList.nib/info.nib

    r3501 r3544  
    99                <key>148</key> 
    1010                <string>552 603 220 194 0 0 1280 832 </string> 
    11                 <key>168</key> 
    12                 <string>460 587 177 99 0 0 1440 878 </string> 
    1311        </dict> 
    1412        <key>IBFramework Version</key> 
     
    1816        <key>IBOpenObjects</key> 
    1917        <array> 
    20                 <integer>115</integer> 
    21                 <integer>168</integer> 
    2218                <integer>41</integer> 
    23                 <integer>80</integer> 
    2419        </array> 
    2520        <key>IBSystem Version</key> 
  • trunk/Languages/pt_PT.lproj/MVBuddyList.nib/classes.nib

    r3501 r3544  
    2828            LANGUAGE = ObjC;  
    2929            OUTLETS = { 
    30                 actionMenu = NSMenu;  
     30                actionButton = NSButton;  
    3131                addButton = NSButton;  
    3232                buddies = MVTableView;  
  • trunk/Languages/pt_PT.lproj/MVBuddyList.nib/info.nib

    r3501 r3544  
    99                <key>148</key> 
    1010                <string>552 603 220 194 0 0 1280 832 </string> 
    11                 <key>168</key> 
    12                 <string>460 587 132 99 0 0 1440 878 </string> 
    1311        </dict> 
    1412        <key>IBFramework Version</key> 
     
    1816        <key>IBOpenObjects</key> 
    1917        <array> 
    20                 <integer>115</integer> 
    21                 <integer>80</integer> 
    2218                <integer>41</integer> 
    2319        </array> 
  • trunk/Languages/zh_TW.lproj/MVBuddyList.nib/classes.nib

    r3501 r3544  
    2828            LANGUAGE = ObjC;  
    2929            OUTLETS = { 
    30                 actionMenu = NSMenu;  
     30                actionButton = NSButton;  
    3131                addButton = NSButton;  
    3232                buddies = MVTableView;  
  • trunk/Languages/zh_TW.lproj/MVBuddyList.nib/info.nib

    r3501 r3544  
    99                <key>148</key> 
    1010                <string>552 603 220 194 0 0 1280 832 </string> 
    11                 <key>168</key> 
    12                 <string>460 587 132 99 0 0 1440 878 </string> 
    1311        </dict> 
    1412        <key>IBFramework Version</key> 
     
    1614        <key>IBLockedObjects</key> 
    1715        <array/> 
     16        <key>IBOpenObjects</key> 
     17        <array> 
     18                <integer>41</integer> 
     19        </array> 
    1820        <key>IBSystem Version</key> 
    1921        <string>9A321</string> 
  • trunk/Panels/JVDirectChatPanel.h

    r3072 r3544  
    4545- (id) initWithTarget:(id) target; 
    4646- (id) target; 
     47- (MVChatUser *) user; 
    4748- (NSURL *) url; 
    4849 
  • trunk/Panels/JVDirectChatPanel.m

    r3539 r3544  
     1#import "JVDirectChatPanel.h" 
     2 
     3#import "JVBuddy.h" 
    14#import "JVChatController.h" 
     5#import "JVChatEvent.h" 
     6#import "JVChatMessage.h" 
     7#import "JVChatRoomMember.h" 
     8#import "JVChatRoomPanel.h" 
     9#import "JVChatTranscript.h" 
     10#import "JVChatUserInspector.h" 
     11#import "JVEmoticonSet.h" 
     12#import "JVMarkedScroller.h" 
     13#import "JVNotificationController.h" 
     14#import "JVSQLChatTranscript.h" 
     15#import "JVSpeechController.h" 
     16#import "JVSplitView.h" 
     17#import "JVStyle.h" 
     18#import "JVStyleView.h" 
     19#import "JVTabbedChatWindowController.h" 
    220#import "KAIgnoreRule.h" 
    3 #import "JVTabbedChatWindowController.h" 
    4 #import "JVStyle.h" 
    5 #import "JVEmoticonSet.h" 
    6 #import "JVChatRoomPanel.h" 
    7 #import "JVChatRoomMember.h" 
    8 #import "JVChatTranscript.h" 
    9 #import "JVSQLChatTranscript.h" 
    10 #import "JVChatMessage.h" 
    11 #import "JVChatEvent.h" 
    12 #import "JVNotificationController.h" 
     21#import "MVBuddyListController.h" 
     22#import "MVChatUserAdditions.h" 
    1323#import "MVConnectionsController.h" 
    14 #import "JVDirectChatPanel.h" 
    15 #import "MVBuddyListController.h" 
    1624#import "MVFileTransferController.h" 
    17 #import "JVBuddy.h" 
     25#import "MVMenuButton.h" 
    1826#import "MVTextView.h" 
    19 #import "MVMenuButton.h" 
    20 #import "JVMarkedScroller.h" 
    21 #import "JVSplitView.h" 
    22 #import "JVStyleView.h" 
     27#import "NSAttributedStringMoreAdditions.h" 
    2328#import "NSBundleAdditions.h" 
    2429#import "NSURLAdditions.h" 
    25 #import "NSAttributedStringMoreAdditions.h" 
    26 #import "JVSpeechController.h" 
    27 #import "JVChatUserInspector.h" 
    2830 
    2931static NSSet *actionVerbs = nil; 
     
    334336} 
    335337 
     338- (MVChatUser *) user { 
     339        if( [[self target] isKindOfClass:[MVChatUser class]] ) 
     340                return [self target]; 
     341        if( [[self target] isKindOfClass:[MVDirectChatConnection class]] ) 
     342                return [(MVDirectChatConnection *)[self target] user]; 
     343        return nil; 
     344} 
     345 
    336346- (NSURL *) url { 
    337347        NSString *server = [[[self connection] url] absoluteString]; 
     
    407417 
    408418- (NSMenu *) menu { 
    409         NSMenu *menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; 
     419        NSMenu *menu = [[NSMenu alloc] initWithTitle:@""]; 
    410420        NSMenuItem *item = nil; 
    411421 
    412         item = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Get Info", "get info contextual menu item title" ) action:@selector( getInfo: ) keyEquivalent:@""] autorelease]; 
    413         [item setTarget:self]; 
    414         [menu addItem:item]; 
    415  
    416 /*      item = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Add to Favorites", "add to favorites contextual menu") action:@selector( addToFavorites: ) keyEquivalent:@""] autorelease]; 
    417         [item setTarget:self]; 
    418         [menu addItem:item]; */ 
    419  
    420         if( ! [[MVBuddyListController sharedBuddyList] buddyForUser:[self target]] ) { 
    421                 item = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Add To Buddy List", "add to buddy list contextual menu") action:@selector( addBuddy: ) keyEquivalent:@""] autorelease]; 
    422                 [item setTarget:self]; 
    423                 [menu addItem:item]; 
    424         } 
    425  
    426         item = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Send File...", "send file contextual menu") action:@selector( _sendFile: ) keyEquivalent:@""] autorelease]; 
    427         [item setTarget:self]; 
    428         [menu addItem:item]; 
     422        NSArray *standardItems = [[self user] standardMenuItems]; 
     423        NSEnumerator *enumerator = [standardItems objectEnumerator]; 
     424        while( ( item = [enumerator nextObject] ) ) 
     425                if( [item action] != @selector( startDirectChat: ) ) 
     426                        [menu addItem:item]; 
    429427 
    430428        [menu addItem:[NSMenuItem separatorItem]]; 
    431429 
    432430        if( [[[self windowController] allChatViewControllers] count] > 1 ) { 
    433                 item = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Detach From Window", "detach from window contextual menu item title" ) action:@selector( detachView: ) keyEquivalent:@""] autorelease]; 
     431                item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Detach From Window", "detach from window contextual menu item title" ) action:@selector( detachView: ) keyEquivalent:@""]; 
    434432                [item setRepresentedObject:self]; 
    435433                [item setTarget:[JVChatController defaultController]]; 
    436434                [menu addItem:item]; 
    437         } 
    438  
    439         item = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Close", "close contextual menu item title" ) action:@selector( close: ) keyEquivalent:@""] autorelease]; 
     435                [item release]; 
     436        } 
     437 
     438        if( [[self target] isKindOfClass:[MVDirectChatConnection class]] ) { 
     439                item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Disconnect", "disconnect contextual menu item title" ) action:@selector( disconnect ) keyEquivalent:@""]; 
     440                [item setTarget:[self target]]; 
     441                [menu addItem:item]; 
     442                [item release]; 
     443        } 
     444 
     445        item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Close", "close contextual menu item title" ) action:@selector( close: ) keyEquivalent:@""]; 
    440446        [item setTarget:self]; 
    441447        [menu addItem:item]; 
    442  
    443         return menu; 
     448        [item release]; 
     449 
     450        return [menu autorelease]; 
    444451} 
    445452 
     
    13661373                [toolbarItem setImage:[NSImage imageNamed:@"fileSend"]]; 
    13671374 
    1368                 [toolbarItem setTarget:self]; 
    1369                 [toolbarItem setAction:@selector( _sendFile: )]; 
     1375                [toolbarItem setTarget:[self user]]; 
     1376                [toolbarItem setAction:@selector( sendFile: )]; 
    13701377 
    13711378                return [toolbarItem autorelease]; 
     
    17371744} 
    17381745 
    1739 - (IBAction) _sendFile:(id) sender { 
    1740         BOOL passive = [[NSUserDefaults standardUserDefaults] boolForKey:@"JVSendFilesPassively"]; 
    1741         NSString *path = nil; 
    1742         NSOpenPanel *panel = [NSOpenPanel openPanel]; 
    1743         [panel setResolvesAliases:YES]; 
    1744         [panel setCanChooseFiles:YES]; 
    1745         [panel setCanChooseDirectories:NO]; 
    1746         [panel setAllowsMultipleSelection:YES]; 
    1747  
    1748         NSView *view = [[[NSView alloc] initWithFrame:NSMakeRect( 0., 0., 200., 28. )] autorelease]; 
    1749         [view setAutoresizingMask:( NSViewWidthSizable | NSViewMaxXMargin )]; 
    1750  
    1751         NSButton *passiveButton = [[[NSButton alloc] initWithFrame:NSMakeRect( 0., 6., 200., 18. )] autorelease]; 
    1752         [[passiveButton cell] setButtonType:NSSwitchButton]; 
    1753         [passiveButton setState:passive]; 
    1754         [passiveButton setTitle:NSLocalizedString( @"Send File Passively", "send files passively file send open dialog button" )]; 
    1755         [passiveButton sizeToFit]; 
    1756  
    1757         NSRect frame = [view frame]; 
    1758         frame.size.width = NSWidth( [passiveButton frame] ); 
    1759  
    1760         [view setFrame:frame]; 
    1761         [view addSubview:passiveButton]; 
    1762  
    1763         [panel setAccessoryView:view]; 
    1764  
    1765         if( [panel runModalForTypes:nil] == NSOKButton ) { 
    1766                 NSEnumerator *enumerator = [[panel filenames] objectEnumerator]; 
    1767                 passive = [passiveButton state]; 
    1768                 while( ( path = [enumerator nextObject] ) ) 
    1769                         [[MVFileTransferController defaultController] addFileTransfer:[[self target] sendFile:path passively:passive]]; 
    1770         } 
    1771 } 
    1772  
    17731746- (void) _setCurrentMessage:(JVMutableChatMessage *) message { 
    17741747        [_currentMessage setObjectSpecifier:nil]; 
  • trunk/Panels/MVChatUserAdditions.m

    r3543 r3544  
    131131        [panel setAllowsMultipleSelection:YES]; 
    132132 
    133         NSView *view = [[[NSView alloc] initWithFrame:NSMakeRect( 0., 0., 200., 28. )] autorelease]; 
     133        NSView *view = [[NSView alloc] initWithFrame:NSMakeRect( 0., 0., 200., 28. )]; 
    134134        [view setAutoresizingMask:( NSViewWidthSizable | NSViewMaxXMargin )]; 
    135135 
    136         NSButton *passiveButton = [[[NSButton alloc] initWithFrame:NSMakeRect( 0., 6., 200., 18. )] autorelease]; 
     136        NSButton *passiveButton = [[NSButton alloc] initWithFrame:NSMakeRect( 0., 6., 200., 18. )]; 
    137137        [[passiveButton cell] setButtonType:NSSwitchButton]; 
    138138        [passiveButton setState:passive]; 
     
    145145        [view setFrame:frame]; 
    146146        [view addSubview:passiveButton]; 
     147        [passiveButton release]; 
    147148 
    148149        [panel setAccessoryView:view]; 
     150        [view release]; 
    149151 
    150152        if( [panel runModalForTypes:nil] == NSOKButton ) { 
  • trunk/Plug-Ins/Standard Commands/JVStandardCommands.m

    r3539 r3544  
    433433 
    434434        if( ! [path length] ) { 
    435                 NSOpenPanel *panel = [NSOpenPanel openPanel]; 
    436                 [panel setResolvesAliases:YES]; 
    437                 [panel setCanChooseFiles:YES]; 
    438                 [panel setCanChooseDirectories:NO]; 
    439                 [panel setAllowsMultipleSelection:YES]; 
    440                 if( [panel runModalForTypes:nil] == NSOKButton ) { 
    441                         NSEnumerator *enumerator = [[panel filenames] objectEnumerator]; 
    442                         while( ( path = [enumerator nextObject] ) ) 
    443                                 [[MVFileTransferController defaultController] addFileTransfer:[user sendFile:path passively:passive]]; 
    444                 } 
     435                [user sendFile:nil]; 
    445436        } else [[MVFileTransferController defaultController] addFileTransfer:[user sendFile:path passively:passive]]; 
     437 
    446438        return YES; 
    447439}