Changeset 2824


Ignore:
Timestamp:
Aug 17, 2007, 11:58:21 PM (15 years ago)
Author:
livings124
Message:

preliminary support for setting speed limits through the action menu

Location:
trunk/macosx
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/English.lproj/MainMenu.nib/classes.nib

    r2787 r2824  
    180180        },
    181181        {
     182            ACTIONS = {checkFile = id; setQuickLimit = id; setQuickLimitMode = id; };
    182183            CLASS = TorrentTableView;
    183184            LANGUAGE = ObjC;
    184             OUTLETS = {fContextNoRow = NSMenu; fContextRow = NSMenu; fController = Controller; };
     185            OUTLETS = {
     186                fActionMenu = NSMenu;
     187                fContextNoRow = NSMenu;
     188                fContextRow = NSMenu;
     189                fController = Controller;
     190                fDownloadMenu = NSMenu;
     191                fUploadMenu = NSMenu;
     192            };
    185193            SUPERCLASS = NSTableView;
    186194        }
  • trunk/macosx/English.lproj/MainMenu.nib/info.nib

    r2787 r2824  
    88        <dict>
    99                <key>1041</key>
    10                 <string>308 271 208 149 0 0 1152 842 </string>
     10                <string>480 344 208 149 0 0 1680 1028 </string>
    1111                <key>1480</key>
    1212                <string>366 546 420 63 0 0 1152 842 </string>
    1313                <key>1603</key>
    1414                <string>337 544 477 67 0 0 1152 842 </string>
     15                <key>1936</key>
     16                <string>785 583 166 80 0 0 1680 1028 </string>
    1517                <key>29</key>
    16                 <string>149 756 451 44 0 0 1152 842 </string>
     18                <string>261 932 451 44 0 0 1680 1028 </string>
    1719                <key>456</key>
    1820                <string>396 374 240 225 0 0 1152 842 </string>
     
    3234        <key>IBOpenObjects</key>
    3335        <array>
     36                <integer>1936</integer>
    3437                <integer>21</integer>
    3538                <integer>29</integer>
     39                <integer>1041</integer>
    3640        </array>
    3741        <key>IBSystem Version</key>
    38         <string>8R218</string>
     42        <string>8R4031</string>
    3943</dict>
    4044</plist>
  • trunk/macosx/InfoWindowController.m

    r2822 r2824  
    107107   
    108108    //allow for update notifications
    109     [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updateInfoStats) name: @"UpdateStats" object: nil];
     109    NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
     110    [nc addObserver: self selector: @selector(updateInfoStats)
     111            name: @"UpdateStats" object: nil];
     112   
     113    [nc addObserver: self selector: @selector(updateInfoSettings)
     114            name: @"UpdateSettings" object: nil];
    110115}
    111116
  • trunk/macosx/Torrent.h

    r2794 r2824  
    6363    NSArray * fFileList, * fFlatFileList;
    6464   
    65     NSMenu * fTorrentMenu;
     65    NSMenu * fFileMenu;
    6666   
    6767    float   fRatioLimit;
     
    214214- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
    215215
    216 - (NSMenu *) torrentMenu;
     216- (NSMenu *) fileMenu;
    217217
    218218- (NSDate *) dateAdded;
  • trunk/macosx/Torrent.m

    r2810 r2824  
    166166    [fFlatFileList release];
    167167   
    168     [fTorrentMenu release];
     168    [fFileMenu release];
    169169   
    170170    [fQuickPauseDict release];
     
    564564}
    565565
     566#warning use enum value
    566567- (int) speedMode: (BOOL) upload
    567568{
     
    13151316}
    13161317
    1317 - (NSMenu *) torrentMenu
    1318 {
    1319     if (!fTorrentMenu)
    1320     {
    1321         fTorrentMenu = [[NSMenu alloc] initWithTitle: [@"TorrentMenu:" stringByAppendingString: [self name]]];
    1322         [fTorrentMenu setAutoenablesItems: NO];
    1323     }
    1324     return fTorrentMenu;
     1318- (NSMenu *) fileMenu
     1319{
     1320    if (!fFileMenu)
     1321    {
     1322        fFileMenu = [[NSMenu alloc] initWithTitle: [@"TorrentMenu:" stringByAppendingString: [self name]]];
     1323        [fFileMenu setAutoenablesItems: NO];
     1324    }
     1325    return fFileMenu;
    13251326}
    13261327
  • trunk/macosx/TorrentTableView.h

    r2822 r2824  
    5252   
    5353    NSDictionary * fSmallStatusAttributes;
    54 
     54   
     55    IBOutlet NSMenu * fActionMenu, * fUploadMenu, * fDownloadMenu;
    5556    Torrent * fMenuTorrent;
    56     NSEvent * fMenuEvent;
    5757}
    5858
     
    6060
    6161- (void) displayTorrentMenuForEvent: (NSEvent *) event;
     62
     63- (void) setQuickLimitMode: (id) sender;
     64- (void) setQuickLimit: (id) sender;
     65
    6266- (void) checkFile: (id) sender;
    6367
  • trunk/macosx/TorrentTableView.m

    r2811 r2824  
    3535#define ACTION_BUTTON_TO_TOP 47.0
    3636
     37#define ACTION_MENU_GLOBAL_TAG 101
     38#define ACTION_MENU_UNLIMITED_TAG 102
     39#define ACTION_MENU_LIMIT_TAG 103
     40
     41#define ACTION_MENU_FILE_TAG 201
     42
    3743@interface TorrentTableView (Private)
    3844
     
    305311        return;
    306312   
     313    //get file menu
    307314    fMenuTorrent = [[fTorrents objectAtIndex: row] retain];
    308     NSMenu * torrentMenu = [fMenuTorrent torrentMenu];
    309     [torrentMenu setDelegate: self];
     315    NSMenu * fileMenu = [fMenuTorrent fileMenu];
     316    [fileMenu setDelegate: self];
     317   
     318    //remove old file menu
     319    NSMenuItem * oldFileMenuItem;
     320    if ((oldFileMenuItem = [fActionMenu itemWithTag: ACTION_MENU_FILE_TAG]))
     321        [fActionMenu removeItem: oldFileMenuItem];
     322   
     323    //set file menu
     324    #warning localize
     325    NSMenuItem * fileMenuItem = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Files",
     326                                    "torrent action context menu -> files menu") action: NULL keyEquivalent: @""];
     327    [fileMenuItem setTag: ACTION_MENU_FILE_TAG];
     328    [fileMenuItem setSubmenu: fileMenu];
     329    [fActionMenu addItem: fileMenuItem];
     330   
     331    [fileMenuItem release];
    310332   
    311333    NSRect rect = [self actionRectForRow: row];
     
    318340        context: [event context] eventNumber: [event eventNumber] clickCount: [event clickCount] pressure: [event pressure]];
    319341   
    320     [NSMenu popUpContextMenu: torrentMenu withEvent: newEvent forView: self];
     342    [NSMenu popUpContextMenu: fActionMenu withEvent: newEvent forView: self];
    321343   
    322344    [fMenuTorrent release];
     
    327349{
    328350    //this method seems to be called when it shouldn't be
    329     if (!fMenuTorrent)
     351    if (!fMenuTorrent || ![menu supermenu])
    330352        return;
    331353   
     
    334356    NSMenu * supermenu = [menu supermenu];
    335357    NSArray * items;
    336     if (supermenu)
     358    NSDictionary * folderDict;
     359    #warning move to submethod
     360    if (menu == fUploadMenu || menu == fDownloadMenu)
     361    {
     362        BOOL upload = menu == fUploadMenu;
     363        tr_speedlimit_t mode = [fMenuTorrent speedMode: upload];
     364       
     365        NSMenuItem * item = [menu itemWithTag: ACTION_MENU_LIMIT_TAG];
     366        [item setState: mode == TR_SPEEDLIMIT_SINGLE ? NSOnState : NSOffState];
     367        [item setTitle: [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)",
     368                    "torrent action context menu -> upload/download limit"), [fMenuTorrent speedLimit: upload]]];
     369       
     370        item = [menu itemWithTag: ACTION_MENU_UNLIMITED_TAG];
     371        [item setState: mode == TR_SPEEDLIMIT_UNLIMITED ? NSOnState : NSOffState];
     372       
     373        item = [menu itemWithTag: ACTION_MENU_GLOBAL_TAG];
     374        [item setState: mode == TR_SPEEDLIMIT_GLOBAL ? NSOnState : NSOffState];
     375       
     376        return;
     377    }
     378    else if ((folderDict = [[supermenu itemAtIndex: [supermenu indexOfItemWithSubmenu: menu]] representedObject]))
    337379        items = [[[supermenu itemAtIndex: [supermenu indexOfItemWithSubmenu: menu]] representedObject] objectForKey: @"Children"];
    338380    else
    339381        items = [fMenuTorrent fileList];
     382   
     383    #warning move rest to submethod
    340384    NSEnumerator * enumerator = [items objectEnumerator];
    341385    NSDictionary * dict;
     
    389433}
    390434
     435- (void) setQuickLimitMode: (id) sender
     436{
     437    int tag = [sender tag];
     438    tr_speedlimit_t mode;
     439    if (tag == ACTION_MENU_UNLIMITED_TAG)
     440        mode = TR_SPEEDLIMIT_UNLIMITED;
     441    else if (tag == ACTION_MENU_LIMIT_TAG)
     442        mode = TR_SPEEDLIMIT_SINGLE;
     443    else
     444        mode = TR_SPEEDLIMIT_GLOBAL;
     445   
     446    [fMenuTorrent setSpeedMode: mode upload: [sender menu] == fUploadMenu];
     447   
     448    [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateSettings" object: nil];
     449}
     450
     451- (void) setQuickLimit: (id) sender
     452{
     453   
     454}
     455
    391456- (void) checkFile: (id) sender
    392457{
Note: See TracChangeset for help on using the changeset viewer.