Changeset 151


Ignore:
Timestamp:
Mar 12, 2006, 3:45:55 PM (16 years ago)
Author:
titer
Message:

Moved 'reveal in finder' to the Torrent class, and do it in a PathFinder?-
compatible way (fixes #6)

Location:
branches/new_api/macosx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/new_api/macosx/Controller.h

    r141 r151  
    127127- (void) notifyGrowl:       (NSString *) file;
    128128- (void) revealFromMenu:    (id) sender;
    129 - (void) finderReveal:      (NSString *) path;
    130129- (void) finderTrash:       (NSString *) path;
    131130- (void) growlRegister:     (id) sender;
  • branches/new_api/macosx/Controller.m

    r148 r151  
    8888    [fWindow setDelegate: self];
    8989
     90    [fTableView setTorrents: fTorrents];
    9091    [[fTableView tableColumnWithIdentifier: @"Torrent"] setDataCell:
    9192        [[TorrentCell alloc] init]];
     
    11051106- (void) revealFromMenu: (id) sender
    11061107{
    1107 #if 0
    1108     int row = [fTableView selectedRow];
    1109     if (row >= 0)
    1110     {
    1111         [self finderReveal: [NSString stringWithFormat: @"%@/%@",
    1112             [NSString stringWithUTF8String: fStat[row].folder],
    1113             [NSString stringWithUTF8String: fStat[row].info.name]]];
    1114     }
    1115 #endif
    1116 }
    1117 
    1118 - (void) finderReveal: (NSString *) path
    1119 {
    1120     NSString * string;
    1121     NSAppleScript * appleScript;
    1122     NSDictionary * error;
    1123 
    1124     string = [NSString stringWithFormat:
    1125         @"tell application \"Finder\"\n"
    1126          "  activate\n"
    1127          "  reveal (POSIX file \"%@\")\n"
    1128          "end tell", path];
    1129 
    1130     appleScript = [[NSAppleScript alloc] initWithSource: string];
    1131     if( ![appleScript executeAndReturnError: &error] )
    1132     {
    1133         printf( "finderReveal failed\n" );
    1134     }
    1135     [appleScript release];
     1108    Torrent * torrent;
     1109    torrent = [fTorrents objectAtIndex: [fTableView selectedRow]];
     1110    [torrent reveal];
    11361111}
    11371112
  • branches/new_api/macosx/Torrent.h

    r148 r151  
    4949- (void)       sleep;
    5050- (void)       wakeUp;
     51- (void)       reveal;
    5152
    5253- (NSImage *)  icon;
  • branches/new_api/macosx/Torrent.m

    r148 r151  
    200200}
    201201
     202- (void) reveal
     203{
     204    NSString * path = [NSString stringWithFormat: @"%@/%@",
     205                        [self getFolder], [self name]];
     206    NSURL * url = [NSURL fileURLWithPath: path];
     207
     208    [[NSWorkspace sharedWorkspace] selectFile: [url path]
     209        inFileViewerRootedAtPath: nil];
     210}
     211
    202212- (NSImage *) icon
    203213{
  • branches/new_api/macosx/TorrentTableView.h

    r142 r151  
    77
    88{
    9     IBOutlet Controller  * fController;
     9    IBOutlet Controller * fController;
     10    NSArray             * fTorrents;
    1011
    11     NSPoint                fClickPoint;
     12    NSPoint               fClickPoint;
    1213   
    1314    IBOutlet NSMenu     * fContextRow;
    1415    IBOutlet NSMenu     * fContextNoRow;
    1516}
     17- (void) setTorrents: (NSArray *) torrents;
    1618
    1719@end
  • branches/new_api/macosx/TorrentTableView.m

    r150 r151  
    2323#import "TorrentTableView.h"
    2424#import "Controller.h"
     25#import "Torrent.h"
    2526
    2627@implementation TorrentTableView
     28
     29- (void) setTorrents: (NSArray *) torrents
     30{
     31    fTorrents = torrents;
     32}
    2733
    2834- (void) pauseOrResume: (int) row
     
    8995    NSPoint point;
    9096    int row, col;
     97    Torrent * torrent;
    9198
    9299    point = [self convertPoint: [e locationInWindow] fromView: NULL];
     
    104111    else if( [self pointInRevealRect: point] )
    105112    {
    106 #if 0
    107         [fController finderReveal: [NSString stringWithFormat:
    108             @"%@/%@", [NSString stringWithUTF8String: fStat[row].folder],
    109             [NSString stringWithUTF8String: fStat[row].info.name]]];
     113        torrent = [fTorrents objectAtIndex: row];
     114        [torrent reveal];
    110115        [self display];
    111 #endif
    112116    }
    113117    else if( row >= 0 && ( [e modifierFlags] & NSAlternateKeyMask ) )
Note: See TracChangeset for help on using the changeset viewer.