Changeset 20


Ignore:
Timestamp:
Jan 12, 2006, 6:58:57 PM (16 years ago)
Author:
root
Message:

Update 2005-12-25

Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/AUTHORS

    r15 r20  
    22=======================================================
    33
    4 Transmission is written is maintained by:
     4Transmission is written and maintained by:
    55
    66Eric Petit <titer@m0k.org>
     
    4545John Blitch
    4646 + Contextual menu patch
     47
     48Mitchell Livingston
     49 + OS X patches
  • trunk/gtk/main.c

    r18 r20  
    160160  tr = tr_init();
    161161
    162   if(cf_init(tr_getPrefsDirectory(tr), &err)) {
     162  if(cf_init(tr_getPrefsDirectory(), &err)) {
    163163    if(cf_lock(&err)) {
    164164      /* create main window now so any error dialogs can be it's children */
  • trunk/libtransmission/fastresume.h

    r3 r20  
    4141static char * fastResumeFileName( tr_io_t * io )
    4242{
    43     tr_torrent_t * tor = io->tor;
    4443    char * ret, * p;
    4544    int i;
    4645
    47     asprintf( &ret, "%s/resume.%40d", tor->prefsDirectory, 0 );
     46    asprintf( &ret, "%s/resume.%40d", tr_getPrefsDirectory(), 0 );
    4847
    4948    p = &ret[ strlen( ret ) - 2 * SHA_DIGEST_LENGTH ];
  • trunk/libtransmission/fdlimit.c

    r3 r20  
    105105    uint64_t date;
    106106
    107     tr_lockLock( f->lock );
     107    tr_lockLock( &f->lock );
    108108
    109109    /* Is it already open? */
     
    116116            {
    117117                /* Wait until the file is closed */
    118                 tr_lockUnlock( f->lock );
     118                tr_lockUnlock( &f->lock );
    119119                tr_wait( 10 );
    120                 tr_lockLock( f->lock );
     120                tr_lockLock( &f->lock );
    121121                i = -1;
    122122                continue;
     
    163163            tr_dbg( "Closing %s", f->open[winner].path );
    164164            f->open[winner].status = STATUS_CLOSING;
    165             tr_lockUnlock( f->lock );
     165            tr_lockUnlock( &f->lock );
    166166            fclose( f->open[winner].file );
    167             tr_lockLock( f->lock );
     167            tr_lockLock( &f->lock );
    168168            goto open;
    169169        }
    170170
    171171        /* All used! Wait a bit and try again */
    172         tr_lockUnlock( f->lock );
     172        tr_lockUnlock( &f->lock );
    173173        tr_wait( 10 );
    174         tr_lockLock( f->lock );
     174        tr_lockLock( &f->lock );
    175175    }
    176176
     
    183183    f->open[winner].status = STATUS_USED;
    184184    f->open[winner].date   = tr_date();
    185     tr_lockUnlock( f->lock );
     185    tr_lockUnlock( &f->lock );
    186186   
    187187    return f->open[winner].file;
     
    194194{
    195195    int i;
    196     tr_lockLock( f->lock );
     196    tr_lockLock( &f->lock );
    197197
    198198    for( i = 0; i < TR_MAX_OPEN_FILES; i++ )
     
    205205    }
    206206   
    207     tr_lockUnlock( f->lock );
     207    tr_lockUnlock( &f->lock );
    208208}
    209209
     
    215215    int i;
    216216
    217     tr_lockLock( f->lock );
     217    tr_lockLock( &f->lock );
    218218
    219219    /* Is it already open? */
     
    233233    }
    234234
    235     tr_lockUnlock( f->lock );
     235    tr_lockUnlock( &f->lock );
    236236}
    237237
     
    240240    int ret;
    241241
    242     tr_lockLock( f->lock );
     242    tr_lockLock( &f->lock );
    243243
    244244    if( reserved )
     
    267267    }
    268268
    269     tr_lockUnlock( f->lock );
     269    tr_lockUnlock( &f->lock );
    270270
    271271    return ret;
     
    274274void tr_fdSocketClosed( tr_fd_t * f, int reserved )
    275275{
    276     tr_lockLock( f->lock );
     276    tr_lockLock( &f->lock );
    277277
    278278    if( reserved )
     
    285285    }
    286286
    287     tr_lockUnlock( f->lock );
     287    tr_lockUnlock( &f->lock );
    288288}
    289289
    290290void tr_fdClose( tr_fd_t * f )
    291291{
    292     tr_lockClose( f->lock );
     292    tr_lockClose( &f->lock );
    293293    free( f );
    294294}
  • trunk/libtransmission/inout.c

    r9 r20  
    369369    /* Release the torrent lock so the UI can still update itself if
    370370       this blocks for a while */
    371     tr_lockUnlock( tor->lock );
     371    tr_lockUnlock( &tor->lock );
    372372
    373373    /* We don't ever read or write more than a piece at a time */
     
    440440    }
    441441
    442     tr_lockLock( tor->lock );
     442    tr_lockLock( &tor->lock );
    443443    return 0;
    444444
    445445fail:
    446     tr_lockLock( tor->lock );
     446    tr_lockLock( &tor->lock );
    447447    return 1;
    448448}
  • trunk/libtransmission/internal.h

    r6 r20  
    7272#define TR_HTONL(a,p) *((uint32_t*)(p)) = htonl((a))
    7373
    74 /* Multithreading support: native threads on BeOS, pthreads elsewhere */
    75 #ifdef SYS_BEOS
    76 #  include <kernel/OS.h>
    77 #  define tr_thread_t             thread_id
    78 #  define tr_threadCreate(pt,f,d) *(pt) = spawn_thread((void*)f,"",10,d); \
    79                                           resume_thread(*(pt));
    80 #  define tr_threadJoin(t)        { long e; wait_for_thread(t,&e); }
    81 #  define tr_lock_t               sem_id
    82 #  define tr_lockInit(pl)         *(pl) = create_sem(1,"")
    83 #  define tr_lockLock(l)          acquire_sem(l)
    84 #  define tr_lockUnlock(l)        release_sem(l)
    85 #  define tr_lockClose(l)         delete_sem(l)
    86 #else
    87 #  include <pthread.h>
    88 #  define tr_thread_t             pthread_t
    89 #  define tr_threadCreate(pt,f,d) pthread_create(pt,NULL,(void*)f,d)
    90 #  define tr_threadJoin(t)        pthread_join(t,NULL)
    91 #  define tr_lock_t               pthread_mutex_t
    92 #  define tr_lockInit(pl)         pthread_mutex_init(pl,NULL)
    93 #  define tr_lockLock(l)          pthread_mutex_lock(&l)
    94 #  define tr_lockUnlock(l)        pthread_mutex_unlock(&l)
    95 #  define tr_lockClose(l)         pthread_mutex_destroy(&l)
    96 #endif
    97 
    9874/* Sometimes the system defines MAX/MIN, sometimes not. In the latter
    9975   case, define those here since we will use them */
     
    11086typedef struct tr_completion_s tr_completion_t;
    11187
     88#include "platform.h"
    11289#include "bencode.h"
    11390#include "metainfo.h"
     
    172149    uint64_t          downloaded[10];
    173150    uint64_t          uploaded[10];
    174 
    175     char            * prefsDirectory;
    176151};
    177152
     
    191166    char           id[21];
    192167    char           key[21];
    193     char           prefsDirectory[256];
    194168};
    195169
  • trunk/libtransmission/platform.c

    r14 r20  
    2121 *****************************************************************************/
    2222
    23 #include "platform.h"
     23#ifdef SYS_BEOS
     24  #include <fs_info.h>
     25  #include <FindDirectory.h>
     26#endif
     27#ifdef SYS_DARWIN
     28  #include <sys/types.h>
     29  #include <dirent.h>
     30#endif
     31
     32#include "transmission.h"
     33
     34char * tr_getPrefsDirectory()
     35{
     36    static char prefsDirectory[MAX_PATH_LENGTH];
     37    static int  init = 0;
     38
     39    if( init )
     40    {
     41        return prefsDirectory;
     42    }
    2443
    2544#ifdef SYS_BEOS
    26 /***********************************************************************
    27  * tr_init_beos
    28  ***********************************************************************
    29  * Puts the prefsDirectory in the right place.
    30  **********************************************************************/
    31 void tr_init_beos( tr_handle_t * h )
    32 {
    33         int32 length = 0;
    34         char path[B_FILE_NAME_LENGTH];
    35        
    3645        find_directory( B_USER_SETTINGS_DIRECTORY, dev_for_path("/boot"),
    37                         true, path, length );
    38        
    39         snprintf( h->prefsDirectory, B_FILE_NAME_LENGTH,
    40                   "%s/Transmission", path );
    41         mkdir( h->prefsDirectory, 0755 );
    42 }
     46                        true, prefsDirectory, MAX_PATH_LENGTH );
     47        strcat( prefsDirectory, "/Transmission" );
     48#elif defined( SYS_DARWIN )
     49    snprintf( prefsDirectory, MAX_PATH_LENGTH,
     50              "%s/Library/Caches/Transmission", getenv( "HOME" ) );
     51#else
     52    snprintf( prefsDirectory, MAX_PATH_LENGTH, "%s/.transmission",
     53              getenv( "HOME" ) );
    4354#endif
    4455
    45 /***********************************************************************
    46  * tr_init_platform
    47  ***********************************************************************
    48  * Setup the prefsDirectory for the current platform.
    49  **********************************************************************/
    50 void tr_init_platform( tr_handle_t *h )
     56        mkdir( prefsDirectory, 0755 );
     57    init = 1;
     58
     59#ifdef SYS_DARWIN
     60    DIR * dirh;
     61    struct dirent * dirp;
     62    char oldDirectory[MAX_PATH_LENGTH];
     63    char oldFile[MAX_PATH_LENGTH];
     64    char newFile[MAX_PATH_LENGTH];
     65    snprintf( oldDirectory, MAX_PATH_LENGTH, "%s/.transmission",
     66              getenv( "HOME" ) );
     67    if( ( dirh = opendir( oldDirectory ) ) )
     68    {
     69        while( ( dirp = readdir( dirh ) ) )
     70        {
     71            if( !strcmp( ".", dirp->d_name ) ||
     72                !strcmp( "..", dirp->d_name ) )
     73            {
     74                continue;
     75            }
     76            snprintf( oldFile, MAX_PATH_LENGTH, "%s/%s",
     77                      oldDirectory, dirp->d_name );
     78            snprintf( newFile, MAX_PATH_LENGTH, "%s/%s",
     79                      prefsDirectory, dirp->d_name );
     80            rename( oldFile, newFile );
     81        }
     82
     83        closedir( dirh );
     84        rmdir( oldDirectory );
     85    }
     86#endif
     87
     88    return prefsDirectory;
     89}
     90
     91void tr_threadCreate( tr_thread_t * t, void (*func)(void *), void * arg )
    5192{
    5293#ifdef SYS_BEOS
    53         tr_init_beos( h );
     94    *t = spawn_thread( (void *) func, "torrent-tx", arg );
     95    resume_thread( *t );
    5496#else
    55     snprintf( h->prefsDirectory, sizeof( h->prefsDirectory ),
    56               "%s/.transmission", getenv( "HOME" ) );
    57     mkdir( h->prefsDirectory, 0755 );
     97    pthread_create( t, NULL, (void *) func, arg );
    5898#endif
    5999}
     100
     101void tr_threadJoin( tr_thread_t * t )
     102{
     103#ifdef SYS_BEOS
     104    long exit;
     105    wait_for_thread( *t, &exit );
     106#else
     107    pthread_join( *t, NULL );
     108#endif
     109}
     110
     111void tr_lockInit( tr_lock_t * l )
     112{
     113#ifdef SYS_BEOS
     114    *l = create_sem( 1, "" );
     115#else
     116    pthread_mutex_init( l, NULL );
     117#endif
     118}
     119
     120void tr_lockClose( tr_lock_t * l )
     121{
     122#ifdef SYS_BEOS
     123    delete_sem( *l );
     124#else
     125    pthread_mutex_destroy( l );
     126#endif
     127}
     128
  • trunk/libtransmission/platform.h

    r14 r20  
    1 #ifndef TR_PLATFORM_H
    2 #define TR_PLATFORM_H 1
    31/******************************************************************************
    42 * Copyright (c) 2005 Eric Petit
     
    2220 * DEALINGS IN THE SOFTWARE.
    2321 *****************************************************************************/
    24 
    25 #include "transmission.h"
    26 
     22#ifndef TR_PLATFORM_H
     23#define TR_PLATFORM_H 1
    2724
    2825#ifdef SYS_BEOS
    29   #include <fs_info.h>
    30   #include <FindDirectory.h>
     26  #include <kernel/OS.h>
     27  typedef thread_id tr_thread_t;
     28  typedef sem_id    tr_lock_t;
     29#else
     30  #include <pthread.h>
     31  typedef pthread_t       tr_thread_t;
     32  typedef pthread_mutex_t tr_lock_t;
    3133#endif
    3234
    33 /***********************************************************************
    34  * tr_init_platform
    35  ***********************************************************************
    36  * Performs some platform specific initialization.
    37  **********************************************************************/
    38 void tr_init_platform( tr_handle_t *h );
     35void tr_threadCreate ( tr_thread_t *, void (*func)(void *), void * arg );
     36void tr_threadJoin   ( tr_thread_t * );
     37void tr_lockInit     ( tr_lock_t * );
     38void tr_lockClose    ( tr_lock_t * );
    3939
     40static inline void tr_lockLock( tr_lock_t * l )
     41{
     42#ifdef SYS_BEOS
     43    acquire_sem( *l );
     44#else
     45    pthread_mutex_lock( l );
     46#endif
     47}
    4048
     49static inline void tr_lockUnlock( tr_lock_t * l )
     50{
     51#ifdef SYS_BEOS
     52    release_sem( *l );
     53#else
     54    pthread_mutex_unlock( l );
     55#endif
     56}
    4157
    4258#endif
  • trunk/libtransmission/tracker.c

    r8 r20  
    441441            tr_err( "Tracker: \"peers\" of size %d",
    442442                    bePeers->val.s.i );
    443             tr_lockUnlock( tor->lock );
     443            tr_lockUnlock( &tor->lock );
    444444            goto cleanup;
    445445        }
  • trunk/libtransmission/transmission.c

    r14 r20  
    2323#include "transmission.h"
    2424
    25 #ifdef __cplusplus
    26 extern "C" {
    27 #endif
    28 
    29 #include "platform.h"
    30 
    3125/***********************************************************************
    3226 * Local prototypes
     
    7468    h->bindPort = TR_DEFAULT_PORT;
    7569
    76     tr_init_platform( h );
    77 
    7870    return h;
    79 }
    80 
    81 /***********************************************************************
    82  * tr_getPrefsDirectory
    83  ***********************************************************************
    84  *
    85  **********************************************************************/
    86 char * tr_getPrefsDirectory( tr_handle_t * h )
    87 {
    88     return (char *) h->prefsDirectory;
    8971}
    9072
     
    126108    {
    127109        tor = h->torrents[i];
    128         tr_lockLock( tor->lock );
     110        tr_lockLock( &tor->lock );
    129111        *dl += rateDownload( tor );
    130112        *ul += rateUpload( tor );
    131         tr_lockUnlock( tor->lock );
     113        tr_lockUnlock( &tor->lock );
    132114    }
    133115}
     
    212194    tor->upload  = h->upload;
    213195    tor->fdlimit = h->fdlimit;
    214     tor->prefsDirectory = (char *) h->prefsDirectory;
    215196 
    216197    /* We have a new torrent */
     
    278259    tr_torrent_t * tor = h->torrents[t];
    279260
    280     tr_lockLock( tor->lock );
     261    tr_lockLock( &tor->lock );
    281262    tr_trackerStopped( tor->tracker );
    282263    tor->status = TR_STATUS_STOPPING;
    283264    tor->stopDate = tr_date();
    284     tr_lockUnlock( tor->lock );
     265    tr_lockUnlock( &tor->lock );
    285266}
    286267
     
    295276
    296277    tor->die = 1;
    297     tr_threadJoin( tor->thread );
     278    tr_threadJoin( &tor->thread );
    298279    tr_dbg( "Thread joined" );
    299280
     
    361342        }
    362343
    363         tr_lockLock( tor->lock );
     344        tr_lockLock( &tor->lock );
    364345
    365346        memcpy( &s[i].info, &tor->info, sizeof( tr_info_t ) );
     
    435416        s[i].folder = tor->destination;
    436417
    437         tr_lockUnlock( tor->lock );
     418        tr_lockUnlock( &tor->lock );
    438419    }
    439420
     
    460441    h->torrentCount--;
    461442
    462     tr_lockClose( tor->lock );
     443    tr_lockClose( &tor->lock );
    463444    tr_cpClose( tor->completion );
    464445
     
    493474
    494475#ifdef SYS_BEOS
    495         rename_thread(tor->thread, "torrent-tx");
    496476    /* This is required because on BeOS, SIGINT is sent to each thread,
    497477       which kills them not nicely */
     
    499479#endif
    500480
    501     tr_lockLock( tor->lock );
     481    tr_lockLock( &tor->lock );
    502482
    503483    tr_cpReset( tor->completion );
     
    535515        if( date2 < date1 + 20 )
    536516        {
    537             tr_lockUnlock( tor->lock );
     517            tr_lockUnlock( &tor->lock );
    538518            tr_wait( date1 + 20 - date2 );
    539             tr_lockLock( tor->lock );
    540         }
    541     }
    542 
    543     tr_lockUnlock( tor->lock );
     519            tr_lockLock( &tor->lock );
     520        }
     521    }
     522
     523    tr_lockUnlock( &tor->lock );
    544524
    545525    tr_ioClose( tor->io );
     
    581561    return rateGeneric( tor->dates, tor->uploaded );
    582562}
    583 
    584 #ifdef __cplusplus
    585 }
    586 #endif
  • trunk/libtransmission/transmission.h

    r14 r20  
    3131
    3232#define SHA_DIGEST_LENGTH    20
    33 #ifdef SYS_BEOS
     33#ifdef __BEOS__
    3434# include <StorageDefs.h>
    3535# define MAX_PATH_LENGTH B_FILE_NAME_LENGTH
     
    5858 * not free it.
    5959 **********************************************************************/
    60 char * tr_getPrefsDirectory( tr_handle_t * );
     60char * tr_getPrefsDirectory();
    6161
    6262/***********************************************************************
     
    231231    int         peersDownloading;
    232232    char        pieces[120];
    233     int                 seeders;
    234         int                     leechers;
     233    int         seeders;
     234    int         leechers;
    235235
    236236    uint64_t    downloaded;
  • trunk/libtransmission/upload.c

    r7 r20  
    4646void tr_uploadSetLimit( tr_upload_t * u, int limit )
    4747{
    48     tr_lockLock( u->lock );
     48    tr_lockLock( &u->lock );
    4949    u->limit = limit;
    50     tr_lockUnlock( u->lock );
     50    tr_lockUnlock( &u->lock );
    5151}
    5252
     
    5555    int ret;
    5656
    57     tr_lockLock( u->lock );
     57    tr_lockLock( &u->lock );
    5858    if( u->limit < 0 )
    5959    {
     
    6666        ret = ( u->count < ( u->limit + 1 ) / 2 );
    6767    }
    68     tr_lockUnlock( u->lock );
     68    tr_lockUnlock( &u->lock );
    6969
    7070    return ret;
     
    7373void tr_uploadChoked( tr_upload_t * u )
    7474{
    75     tr_lockLock( u->lock );
     75    tr_lockLock( &u->lock );
    7676    (u->count)--;
    77     tr_lockUnlock( u->lock );
     77    tr_lockUnlock( &u->lock );
    7878}
    7979
    8080void tr_uploadUnchoked( tr_upload_t * u )
    8181{
    82     tr_lockLock( u->lock );
     82    tr_lockLock( &u->lock );
    8383    (u->count)++;
    84     tr_lockUnlock( u->lock );
     84    tr_lockUnlock( &u->lock );
    8585}
    8686
     
    9090    uint64_t now;
    9191
    92     tr_lockLock( u->lock );
     92    tr_lockLock( &u->lock );
    9393    if( u->limit < 0 )
    9494    {
     
    115115        }
    116116    }
    117     tr_lockUnlock( u->lock );
     117    tr_lockUnlock( &u->lock );
    118118
    119119    return ret;
     
    122122void tr_uploadUploaded( tr_upload_t * u, int size )
    123123{
    124     tr_lockLock( u->lock );
     124    tr_lockLock( &u->lock );
    125125    memmove( &u->dates[1], &u->dates[0], (FOO-1) * sizeof( uint64_t ) );
    126126    memmove( &u->sizes[1], &u->sizes[0], (FOO-1) * sizeof( int ) );
    127127    u->dates[0] = tr_date();
    128128    u->sizes[0] = size;
    129     tr_lockUnlock( u->lock );
     129    tr_lockUnlock( &u->lock );
    130130}
    131131
    132132void tr_uploadClose( tr_upload_t * u )
    133133{
    134     tr_lockClose( u->lock );
     134    tr_lockClose( &u->lock );
    135135    free( u );
    136136}
  • trunk/macosx/Controller.m

    r19 r20  
    247247- (void) showPreferenceWindow: (id) sender
    248248{
    249     NSRect  mainFrame;
    250     NSRect  prefsFrame;
    251     NSRect  screenRect;
    252     NSPoint point;
    253 
    254     /* Place the window */
    255     mainFrame  = [fWindow frame];
    256     prefsFrame = [fPrefsWindow frame];
    257     screenRect = [[NSScreen mainScreen] visibleFrame];
    258     point.x    = mainFrame.origin.x + mainFrame.size.width / 2 -
    259                     prefsFrame.size.width / 2;
    260     point.y    = mainFrame.origin.y + mainFrame.size.height - 30;
    261 
    262     /* Make sure it is in the screen */
    263     if( point.x < screenRect.origin.x )
    264     {
    265         point.x = screenRect.origin.x;
    266     }
    267     if( point.x + prefsFrame.size.width >
    268             screenRect.origin.x + screenRect.size.width )
    269     {
    270         point.x = screenRect.origin.x +
    271             screenRect.size.width - prefsFrame.size.width;
    272     }
    273     if( point.y - prefsFrame.size.height < screenRect.origin.y )
    274     {
    275         point.y = screenRect.origin.y + prefsFrame.size.height;
    276     }
    277 
    278     [fPrefsWindow setFrameTopLeftPoint: point];
     249    //place the window if not open
     250    if (![fPrefsWindow isVisible])
     251    {
     252        NSRect  prefsFrame, screenRect;
     253        NSPoint point;
     254
     255        prefsFrame = [fPrefsWindow frame];
     256        screenRect = [[NSScreen mainScreen] visibleFrame];
     257        point.x    = (screenRect.size.width - prefsFrame.size.width) * 0.5;
     258        point.y    = screenRect.origin.y + screenRect.size.height * 0.67 +
     259                     prefsFrame.size.height * 0.33;
     260
     261        [fPrefsWindow setFrameTopLeftPoint: point];
     262    }
     263   
    279264    [fPrefsWindow makeKeyAndOrderFront:NULL];
    280265}
     
    310295            continue;
    311296
     297        /* Add it to the "File > Open Recent" menu */
     298        [[NSDocumentController sharedDocumentController]
     299            noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
     300
    312301        if( [downloadChoice isEqualToString: @"Constant"] )
    313302        {
     
    315304                                 [downloadFolder UTF8String] );
    316305            tr_torrentStart( fHandle, tr_torrentCount( fHandle ) - 1 );
    317             continue;
    318         }
    319 
    320         if( [downloadChoice isEqualToString: @"Torrent"] )
     306        }
     307        else if( [downloadChoice isEqualToString: @"Torrent"] )
    321308        {
    322309            tr_torrentSetFolder( fHandle, tr_torrentCount( fHandle ) - 1,
    323310                [[torrentPath stringByDeletingLastPathComponent] UTF8String] );
    324311            tr_torrentStart( fHandle, tr_torrentCount( fHandle ) - 1 );
    325             continue;
    326         }
    327 
    328         NSOpenPanel * panel = [NSOpenPanel openPanel];
    329        
    330         [panel setPrompt: @"Select Download Folder"];
    331         [panel setMessage: [NSString stringWithFormat:
    332                             @"Select the download folder for %@",
    333                             [torrentPath lastPathComponent]]];
    334         [panel setAllowsMultipleSelection: NO];
    335         [panel setCanChooseFiles: NO];
    336         [panel setCanChooseDirectories: YES];
    337 
    338         [panel beginSheetForDirectory: NULL file: NULL types: NULL
    339             modalForWindow: fWindow modalDelegate: self didEndSelector:
    340             @selector( folderChoiceClosed:returnCode:contextInfo: )
    341             contextInfo: NULL];
    342         [NSApp runModalForWindow: panel];
     312        }
     313        else
     314        {
     315            NSOpenPanel * panel = [NSOpenPanel openPanel];
     316           
     317            [panel setPrompt: @"Select Download Folder"];
     318            [panel setMessage: [NSString stringWithFormat:
     319                                @"Select the download folder for %@",
     320                                [torrentPath lastPathComponent]]];
     321            [panel setAllowsMultipleSelection: NO];
     322            [panel setCanChooseFiles: NO];
     323            [panel setCanChooseDirectories: YES];
     324
     325            [panel beginSheetForDirectory: NULL file: NULL types: NULL
     326                modalForWindow: fWindow modalDelegate: self didEndSelector:
     327                @selector( folderChoiceClosed:returnCode:contextInfo: )
     328                contextInfo: NULL];
     329            [NSApp runModalForWindow: panel];
     330        }
    343331    }
    344332
  • trunk/macosx/English.lproj/MainMenu.nib/classes.nib

    r19 r20  
    7171            OUTLETS = {
    7272                fBlankView = NSView;
    73                 fFolderMatrix = NSMatrix;
    7473                fFolderPopUp = NSPopUpButton;
    7574                fGeneralView = NSView;
  • trunk/macosx/English.lproj/MainMenu.nib/info.nib

    r19 r20  
    1616                <string>54 521 112 118 0 0 1152 842 </string>
    1717                <key>783</key>
    18                 <string>428 442 385 225 0 0 1280 832 </string>
     18                <string>409 477 420 155 0 0 1280 832 </string>
    1919                <key>796</key>
    20                 <string>479 490 282 129 0 0 1280 832 </string>
     20                <string>409 490 420 129 0 0 1280 832 </string>
    2121                <key>825</key>
    22                 <string>498 523 155 107 0 0 1152 842 </string>
     22                <string>542 501 155 107 0 0 1280 832 </string>
    2323        </dict>
    2424        <key>IBFramework Version</key>
     
    2828        <key>IBOpenObjects</key>
    2929        <array>
     30                <integer>781</integer>
     31                <integer>783</integer>
     32                <integer>21</integer>
     33                <integer>796</integer>
     34                <integer>825</integer>
    3035                <integer>29</integer>
    31                 <integer>783</integer>
    32                 <integer>796</integer>
    33                 <integer>21</integer>
    3436        </array>
    3537        <key>IBSystem Version</key>
  • trunk/macosx/PrefsController.h

    r19 r20  
    3535    IBOutlet NSView         * fBlankView;
    3636   
    37     IBOutlet NSMatrix       * fFolderMatrix;
    3837    IBOutlet NSPopUpButton  * fFolderPopUp;
    3938    IBOutlet NSTextField    * fPortField;
  • trunk/macosx/PrefsController.m

    r19 r20  
    2828
    2929#define DOWNLOAD_FOLDER     0
    30 #define DOWNLOAD_TORRENT    1
    31 #define DOWNLOAD_ASK        2
     30#define DOWNLOAD_TORRENT    2
     31#define DOWNLOAD_ASK        3
    3232
    3333#define TOOLBAR_GENERAL     @"General"
     
    5959        - Port TR_DEFAULT_PORT
    6060        - Upload limit DEFAULT_UPLOAD
    61         - Do not limit upload
     61        - Limit upload
    6262        - Ask before quitting
    6363        - Ask before removing */
     
    106106    if( [downloadChoice isEqualToString: @"Constant"] )
    107107    {
    108         [fFolderMatrix selectCellAtRow: DOWNLOAD_FOLDER column: 0];
     108        [fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
    109109    }
    110110    else if( [downloadChoice isEqualToString: @"Torrent"] )
    111111    {
    112         [fFolderMatrix selectCellAtRow: DOWNLOAD_TORRENT column: 0];
     112        [fFolderPopUp selectItemAtIndex: DOWNLOAD_TORRENT];
    113113    }
    114114    else
    115115    {
    116         [fFolderMatrix selectCellAtRow: DOWNLOAD_ASK column: 0];
     116        [fFolderPopUp selectItemAtIndex: DOWNLOAD_ASK];
    117117    }
    118118    [self updatePopUp];
    119     [fFolderPopUp setEnabled: [fFolderMatrix selectedRow] == 0];
    120119
    121120    //set bind port
     
    270269{
    271270    //Download folder
    272     switch( [fFolderMatrix selectedRow] )
     271    switch( [fFolderPopUp indexOfSelectedItem] )
    273272    {
    274273        case DOWNLOAD_FOLDER:
     
    282281            break;
    283282    }
    284     [fFolderPopUp setEnabled: [fFolderMatrix selectedRow] == 0];
    285283}
    286284
     
    331329    contextInfo: (void *) info
    332330{
    333     [fFolderPopUp selectItemAtIndex: 0];
    334 
    335     if (code != NSOKButton)
    336         return;
    337 
    338     [fDownloadFolder release];
    339     fDownloadFolder = [[openPanel filenames] objectAtIndex: 0];
    340     [fDownloadFolder retain];
    341    
    342     [fDefaults setObject: fDownloadFolder forKey: @"DownloadFolder"];
    343 
    344     [self updatePopUp];
     331   if (code == NSOKButton)
     332   {
     333       [fDownloadFolder release];
     334       fDownloadFolder = [[openPanel filenames] objectAtIndex: 0];
     335       [fDownloadFolder retain];
     336
     337       [fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
     338       [fDefaults setObject: fDownloadFolder forKey: @"DownloadFolder"];
     339       [fDefaults setObject: @"Constant" forKey: @"DownloadChoice"];
     340
     341       [self updatePopUp];
     342   }
     343   else
     344   {
     345       //reset if cancelled
     346       NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
     347       if( [downloadChoice isEqualToString: @"Constant"] )
     348       {
     349           [fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
     350       }
     351       else if( [downloadChoice isEqualToString: @"Torrent"] )
     352       {
     353           [fFolderPopUp selectItemAtIndex: DOWNLOAD_TORRENT];
     354       }
     355       else
     356       {
     357           [fFolderPopUp selectItemAtIndex: DOWNLOAD_ASK];
     358       }
     359   }
    345360}
    346361
Note: See TracChangeset for help on using the changeset viewer.