Changeset 2117

Show
Ignore:
Timestamp:
11/14/04 21:47:24 (4 years ago)
Author:
timothy
Message:

Enabled the Send File context menu for private chat panels.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/overhaul/JVDirectChat.m

    r2110 r2117  
    2626#import "JVDirectChat.h" 
    2727#import "MVBuddyListController.h" 
     28#import "MVFileTransferController.h" 
    2829#import "JVBuddy.h" 
    2930#import "MVTextView.h" 
     
    414415        NSMenuItem *item = nil; 
    415416 
    416       item = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Get Info", "get info contextual menu item title" ) action:NULL keyEquivalent:@""] autorelease]; 
     417/*    item = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Get Info", "get info contextual menu item title" ) action:NULL keyEquivalent:@""] autorelease]; 
    417418        [item setTarget:self]; 
    418419        [menu addItem:item]; 
     
    420421        item = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Add to Favorites", "add to favorites contextual menu") action:@selector( addToFavorites: ) keyEquivalent:@""] autorelease]; 
    421422        [item setTarget:self]; 
    422         [menu addItem:item]; 
    423  
    424         item = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Send File...", "send file contextual menu") action:@selector( sendFileToSelectedUser: ) keyEquivalent:@""] autorelease]; 
     423        [menu addItem:item]; */ 
     424 
     425        item = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString( @"Send File...", "send file contextual menu") action:@selector( _sendFile: ) keyEquivalent:@""] autorelease]; 
    425426        [item setTarget:self]; 
    426427        [menu addItem:item]; 
     
    20432044        [_windowController reloadListItem:self andChildren:NO]; 
    20442045} 
     2046 
     2047- (IBAction) _sendFile:(id) sender { 
     2048        BOOL passive = [[NSUserDefaults standardUserDefaults] boolForKey:@"JVSendFilesPassively"]; 
     2049        NSString *path = nil; 
     2050        NSOpenPanel *panel = [NSOpenPanel openPanel]; 
     2051        [panel setResolvesAliases:YES]; 
     2052        [panel setCanChooseFiles:YES]; 
     2053        [panel setCanChooseDirectories:NO]; 
     2054        [panel setAllowsMultipleSelection:YES]; 
     2055 
     2056        NSView *view = [[[NSView alloc] initWithFrame:NSMakeRect( 0., 0., 200., 28. )] autorelease]; 
     2057        [view setAutoresizingMask:( NSViewWidthSizable | NSViewMaxXMargin )]; 
     2058 
     2059        NSButton *passiveButton = [[[NSButton alloc] initWithFrame:NSMakeRect( 0., 6., 200., 18. )] autorelease]; 
     2060        [[passiveButton cell] setButtonType:NSSwitchButton]; 
     2061        [passiveButton setState:passive]; 
     2062        [passiveButton setTitle:NSLocalizedString( @"Send File Passively", "send files passively file send open dialog button" )]; 
     2063        [passiveButton sizeToFit]; 
     2064 
     2065        NSRect frame = [view frame]; 
     2066        frame.size.width = NSWidth( [passiveButton frame] ); 
     2067 
     2068        [view setFrame:frame]; 
     2069        [view addSubview:passiveButton]; 
     2070 
     2071        [panel setAccessoryView:view]; 
     2072 
     2073        if( [panel runModalForTypes:nil] == NSOKButton ) { 
     2074                NSEnumerator *enumerator = [[panel filenames] objectEnumerator]; 
     2075                passive = [passiveButton state]; 
     2076                while( ( path = [enumerator nextObject] ) ) 
     2077                        [[MVFileTransferController defaultManager] addFileTransfer:[[self target] sendFile:path passively:passive]]; 
     2078        } 
     2079} 
    20452080@end 
    20462081