Changeset 1102 for trunk/macosx


Ignore:
Timestamp:
Nov 18, 2006, 3:47:20 PM (15 years ago)
Author:
livings124
Message:

show sheet where torrent url can be entered, with some basic string to url conversion

Location:
trunk/macosx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r1093 r1102  
    8282    IBOutlet NSMenuItem             * fUploadLimitItem, * fUploadNoLimitItem,
    8383                                    * fDownloadLimitItem, * fDownloadNoLimitItem;
     84   
     85    IBOutlet NSWindow               * fURLSheetWindow;
     86    IBOutlet NSTextField            * fURLSheetTextField;
    8487
    8588    io_connect_t                    fRootPort;
     
    101104- (void) openShowSheet:         (id) sender;
    102105- (void) openURL:               (NSURL *) torrentURL;
     106- (void) openURLEndSheet:       (id) sender;
     107- (void) openURLCancelEndSheet: (id) sender;
     108- (void) openURLShowSheet:      (id) sender;
    103109
    104110- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo;
  • trunk/macosx/Controller.m

    r1099 r1102  
    485485}
    486486
    487 - (void) openURL: (NSURL *) url
    488 {
    489     NSURLDownload * torrentDownload = [[NSURLDownload alloc] initWithRequest: [NSURLRequest requestWithURL: url]
    490                                         delegate: self];
    491 }
    492 
    493487- (void) download: (NSURLDownload *) download decideDestinationWithSuggestedFilename: (NSString *) suggestedName
    494488{
     
    499493        NSRunAlertPanel(NSLocalizedString(@"Torrent download failed",
    500494            @"Download not a torrent -> title"), [NSString stringWithFormat:
    501             NSLocalizedString(@"It appears that the file from %@ is not a torrent file",
     495            NSLocalizedString(@"It appears that the file from %@ is not a torrent file.",
    502496            @"Download not a torrent -> message"), [[[download request] URL] absoluteString]],
    503497            NSLocalizedString(@"OK", @"Download not a torrent -> button"), nil, nil);
     
    520514    NSRunAlertPanel(NSLocalizedString(@"Torrent download failed",
    521515        @"Torrent download error -> title"), [NSString stringWithFormat:
    522         NSLocalizedString(@"The torrent could not be downloaded from %@ because an error occurred (%@)",
     516        NSLocalizedString(@"The torrent could not be downloaded from %@ because an error occurred (%@).",
    523517        @"Torrent download failed -> message"), [[[download request] URL] absoluteString],
    524518        [error localizedDescription]], NSLocalizedString(@"OK", @"Torrent download failed -> button"), nil, nil);
     
    695689   
    696690    [dictionary release];
     691}
     692
     693- (void) openURL: (NSURL *) url
     694{
     695    [[NSURLDownload alloc] initWithRequest: [NSURLRequest requestWithURL: url] delegate: self];
     696}
     697
     698- (void) openURLShowSheet: (id) sender
     699{
     700    [NSApp beginSheet: fURLSheetWindow modalForWindow: fWindow modalDelegate: self
     701            didEndSelector: @selector(urlSheetDidEnd:returnCode:contextInfo:) contextInfo: nil];
     702}
     703
     704- (void) openURLEndSheet: (id) sender
     705{
     706    [fURLSheetWindow orderOut: sender];
     707    [NSApp endSheet: fURLSheetWindow returnCode: 1];
     708}
     709
     710- (void) openURLCancelEndSheet: (id) sender
     711{
     712    [fURLSheetWindow orderOut: sender];
     713    [NSApp endSheet: fURLSheetWindow returnCode: 0];
     714}
     715
     716- (void) urlSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo
     717{
     718    [fURLSheetTextField selectText: self];
     719    if (returnCode != 1)
     720        return;
     721   
     722    NSString * urlString = [fURLSheetTextField stringValue];
     723    if (![urlString isEqualToString: @""])
     724    {
     725        if ([urlString rangeOfString: @"://"].location == NSNotFound)
     726            urlString = [@"http://" stringByAppendingString: urlString];
     727       
     728        if ([urlString rangeOfString: @"."].location == NSNotFound)
     729        {
     730            int start = NSMaxRange([urlString rangeOfString: @"://"]);
     731            urlString = [NSString stringWithFormat: @"%@www.%@.com", [urlString substringToIndex: start],
     732                                    [urlString substringFromIndex: start]];
     733        }
     734       
     735        NSURL * url = [NSURL URLWithString: urlString];
     736        [self performSelectorOnMainThread: @selector(openURL:) withObject: url waitUntilDone: NO];
     737    }
    697738}
    698739
     
    22082249
    22092250    //enable open items
    2210     if (action == @selector(openShowSheet:))
     2251    if (action == @selector(openShowSheet:) || action == @selector(openURLShowSheet:))
    22112252        return [fWindow attachedSheet] == nil;
    22122253   
  • trunk/macosx/English.lproj/MainMenu.nib/classes.nib

    r1080 r1102  
    1111                linkHomepage = id;
    1212                openShowSheet = id;
     13                openURLCancelEndSheet = id;
     14                openURLEndSheet = id;
     15                openURLShowSheet = id;
    1316                removeDeleteData = id;
    1417                removeDeleteDataAndTorrent = id;
     
    7477                fTotalTorrentsField = NSTextField;
    7578                fTotalULField = NSTextField;
     79                fURLSheetTextField = NSTextField;
     80                fURLSheetWindow = NSWindow;
    7681                fUpdater = SUUpdater;
    7782                fUploadLimitItem = NSMenuItem;
  • trunk/macosx/English.lproj/MainMenu.nib/info.nib

    r1080 r1102  
    1414                <string>337 545 477 67 0 0 1152 842 </string>
    1515                <key>29</key>
    16                 <string>280 699 451 44 0 0 1152 842 </string>
     16                <string>242 698 451 44 0 0 1152 842 </string>
    1717                <key>456</key>
    1818                <string>396 374 240 225 0 0 1152 842 </string>
     
    3232        <key>IBOpenObjects</key>
    3333        <array>
    34                 <integer>581</integer>
    3534                <integer>21</integer>
     35                <integer>29</integer>
     36                <integer>1848</integer>
    3637        </array>
    3738        <key>IBSystem Version</key>
  • trunk/macosx/Torrent.m

    r1100 r1102  
    620620}
    621621
    622 - (void) destinationChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (NSDictionary *) context
     622- (void) destinationChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) context
    623623{
    624624    NSString * folder = [[openPanel filenames] objectAtIndex: 0];
Note: See TracChangeset for help on using the changeset viewer.