Changeset 4183


Ignore:
Timestamp:
Dec 17, 2007, 4:06:20 PM (14 years ago)
Author:
livings124
Message:

preliminary commit of group code

Location:
trunk
Files:
5 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r4165 r4183  
    8383                A21F5B890AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A21F5B870AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m */; };
    8484                A21F5C040AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A21F5C020AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m */; };
     85                A22180980D148A71007D09ED /* GroupsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A22180970D148A71007D09ED /* GroupsWindowController.m */; };
     86                A22180B60D148F0F007D09ED /* GroupsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A22180B50D148F0F007D09ED /* GroupsWindow.xib */; };
     87                A22180F60D14A32F007D09ED /* GradientCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A22180F40D14A32F007D09ED /* GradientCell.m */; };
    8588                A2265F420B5EF5F40093DDA5 /* FileNameCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A2265F400B5EF5F40093DDA5 /* FileNameCell.m */; };
    8689                A226FDAC0D0CDF20005A7F71 /* libnatpmp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C7A118D0D0B2EB800B5701F /* libnatpmp.a */; };
     
    434437                A21F5C010AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ActionMenuSpeedToDisplayLimitTransformer.h; path = macosx/ActionMenuSpeedToDisplayLimitTransformer.h; sourceTree = "<group>"; };
    435438                A21F5C020AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ActionMenuSpeedToDisplayLimitTransformer.m; path = macosx/ActionMenuSpeedToDisplayLimitTransformer.m; sourceTree = "<group>"; };
     439                A22180960D148A71007D09ED /* GroupsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GroupsWindowController.h; path = macosx/GroupsWindowController.h; sourceTree = "<group>"; };
     440                A22180970D148A71007D09ED /* GroupsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GroupsWindowController.m; path = macosx/GroupsWindowController.m; sourceTree = "<group>"; };
     441                A22180B50D148F0F007D09ED /* GroupsWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = GroupsWindow.xib; path = macosx/GroupsWindow.xib; sourceTree = "<group>"; };
     442                A22180F40D14A32F007D09ED /* GradientCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GradientCell.m; path = macosx/GradientCell.m; sourceTree = "<group>"; };
     443                A22180F50D14A32F007D09ED /* GradientCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GradientCell.h; path = macosx/GradientCell.h; sourceTree = "<group>"; };
    436444                A2265F3F0B5EF5F40093DDA5 /* FileNameCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FileNameCell.h; path = macosx/FileNameCell.h; sourceTree = "<group>"; };
    437445                A2265F400B5EF5F40093DDA5 /* FileNameCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = FileNameCell.m; path = macosx/FileNameCell.m; sourceTree = "<group>"; };
     
    807815                                A2E23AC30CB5E1930002BB25 /* InfoTabButtonCell.h */,
    808816                                A2E23AC40CB5E1930002BB25 /* InfoTabButtonCell.m */,
     817                                A22180960D148A71007D09ED /* GroupsWindowController.h */,
     818                                A22180970D148A71007D09ED /* GroupsWindowController.m */,
     819                                A22180F40D14A32F007D09ED /* GradientCell.m */,
     820                                A22180F50D14A32F007D09ED /* GradientCell.h */,
    809821                        );
    810822                        name = Sources;
     
    859871                                A29576060D11D70E0093B167 /* MessageWindow.xib */,
    860872                                A25892750CF1FCE800CCCDDF /* StatsWindow.xib */,
     873                                A22180B50D148F0F007D09ED /* GroupsWindow.xib */,
    861874                                A231274B0D11D0B7003F9AFF /* AboutWindow.xib */,
    862875                                A20B6FA40C4D97840034AB1D /* PriorityNone.png */,
     
    15621575                                A29576080D11D70E0093B167 /* MessageWindow.xib in Resources */,
    15631576                                A29576130D11D8DD0093B167 /* InfoWindow.xib in Resources */,
     1577                                A22180B60D148F0F007D09ED /* GroupsWindow.xib in Resources */,
    15641578                        );
    15651579                        runOnlyForDeploymentPostprocessing = 0;
     
    17101724                                A26397550D0F714300D36DF2 /* ActionPopUpButton.m in Sources */,
    17111725                                A25AFDE90D1038AD0092A1BA /* MenuLabel.m in Sources */,
     1726                                A22180980D148A71007D09ED /* GroupsWindowController.m in Sources */,
     1727                                A22180F60D14A32F007D09ED /* GradientCell.m in Sources */,
    17121728                        );
    17131729                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/macosx/Controller.h

    r4148 r4183  
    8181                                    * fDownloadLimitItem, * fDownloadNoLimitItem;
    8282   
     83    IBOutlet NSMenu                 * fGroupsSetMenu;
     84   
    8385    IBOutlet NSWindow               * fURLSheetWindow;
    8486    IBOutlet NSTextField            * fURLSheetTextField;
     
    188190- (void) setStatusLabel: (id) sender;
    189191
     192- (void) showGroups: (id) sender;
     193- (void) setGroup: (id) sender;
     194
    190195- (void) toggleSpeedLimit: (id) sender;
    191196- (void) autoSpeedLimitChange: (NSNotification *) notification;
  • trunk/macosx/Controller.m

    r4178 r4183  
    3131#import "CreatorWindowController.h"
    3232#import "StatsWindowController.h"
     33#import "GroupsWindowController.h"
    3334#import "AboutWindowController.h"
    3435#import "ButtonToolbarItem.h"
     
    3738#import "NSApplicationAdditions.h"
    3839#import "NSStringAdditions.h"
     40#import "NSMenuAdditions.h"
    3941#import "UKKQueue.h"
    4042#import "ActionMenuSpeedToDisplayLimitTransformer.h"
     
    20252027}
    20262028
     2029- (void) showGroups: (id) sender
     2030{
     2031    [[GroupsWindowController groupsController] showWindow: self];
     2032}
     2033
     2034- (void) menuNeedsUpdate: (NSMenu *) menu
     2035{
     2036    #warning if not group menu, return
     2037    int i, keep = menu == fGroupsSetMenu ? 2 : 0;
     2038    for (i = [menu numberOfItems]-1 - keep; i >= 0; i--)
     2039        [menu removeItemAtIndex: i];
     2040   
     2041    NSMenu * groupMenu = [[GroupsWindowController groupsController] groupMenuWithTarget: self action: @selector(setGroup:)];
     2042    [menu appendItemsFromMenu: groupMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [groupMenu numberOfItems])]
     2043            atBottom: NO];
     2044}
     2045
     2046- (void) setGroup: (id) sender
     2047{
     2048    NSEnumerator * enumerator = [[fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]] objectEnumerator];
     2049    Torrent * torrent;
     2050    while ((torrent = [enumerator nextObject]))
     2051        [torrent setGroupValue: [[sender representedObject] intValue]];
     2052   
     2053    [self updateUI];
     2054    [self applyFilter: nil];
     2055    [self updateTorrentHistory];
     2056}
     2057
    20272058- (void) toggleSpeedLimit: (id) sender
    20282059{
  • trunk/macosx/DragOverlayWindow.m

    r4058 r4183  
    139139}
    140140
    141 
    142141- (void) setURL: (NSString *) url
    143142{
  • trunk/macosx/English.lproj/MainMenu.nib/classes.nib

    r4148 r4183  
    126126                                <string>id</string>
    127127                                <key>showAboutWindow</key>
     128                                <string>id</string>
     129                                <key>showGroups</key>
    128130                                <string>id</string>
    129131                                <key>showInfo</key>
     
    180182                                <key>fFilterBar</key>
    181183                                <string>StatusBarView</string>
     184                                <key>fGroupsSetMenu</key>
     185                                <string>NSMenu</string>
    182186                                <key>fNextFilterItem</key>
    183187                                <string>NSMenuItem</string>
  • trunk/macosx/English.lproj/MainMenu.nib/info.nib

    r4150 r4183  
    1111        <key>IBOpenObjects</key>
    1212        <array>
    13                 <integer>1480</integer>
     13                <integer>1400</integer>
    1414        </array>
    1515        <key>IBSystem Version</key>
  • trunk/macosx/InfoWindowController.m

    r4071 r4183  
    5050{
    5151    TAB_INFO_TAG = 0,
    52     TAB_ACTIVITY_TAG,
    53     TAB_PEERS_TAG,
    54     TAB_FILES_TAG,
    55     TAB_OPTIONS_TAG,
     52    TAB_ACTIVITY_TAG = 1,
     53    TAB_PEERS_TAG = 2,
     54    TAB_FILES_TAG = 3,
     55    TAB_OPTIONS_TAG = 4
    5656} tabTag;
    5757
  • trunk/macosx/NSMenuAdditions.h

    r3083 r4183  
    2727@interface NSMenu (NSMenuAdditions)
    2828
    29 - (void) appendItemsFromMenu: (NSMenu *) menu atIndexes: (NSIndexSet *) indexes;
     29- (void) appendItemsFromMenu: (NSMenu *) menu atIndexes: (NSIndexSet *) indexes atBottom: (BOOL) bottom;
    3030
    3131@end
  • trunk/macosx/NSMenuAdditions.m

    r3083 r4183  
    2727@implementation NSMenu (NSMenuAdditions)
    2828
    29 - (void) appendItemsFromMenu: (NSMenu *) menu atIndexes: (NSIndexSet *) indexes
     29- (void) appendItemsFromMenu: (NSMenu *) menu atIndexes: (NSIndexSet *) indexes atBottom: (BOOL) bottom
    3030{
    31     int bottom = [self numberOfItems];
     31    int bottomIndex = bottom ? [self numberOfItems] : 0;
    3232   
    3333    NSMenuItem * item;
     
    3737        item = [[menu itemAtIndex:i] retain];
    3838        [menu removeItemAtIndex: i];
    39         [self insertItem: item atIndex: bottom];
     39        [self insertItem: item atIndex: bottomIndex];
    4040        [item release];
    4141    }
  • trunk/macosx/Torrent.h

    r3955 r4183  
    6666    BOOL fFinishedSeeding, fWaitToStart, fError, fChecking, fStalled;
    6767   
    68     int fOrderValue;
     68    int fOrderValue, fGroupValue;
    6969   
    7070    NSDictionary * fQuickPauseDict;
     
    209209- (void) setOrderValue: (int) orderValue;
    210210
     211- (int) groupValue;
     212- (void) setGroupValue: (int) groupValue;
     213- (void) checkGroupValue: (NSNotification *) notification;
     214
    211215- (NSArray *) fileList;
    212216- (int) fileCount;
  • trunk/macosx/Torrent.m

    r4090 r4183  
    3838        dateActivity: (NSDate *) dateActivity
    3939        ratioSetting: (NSNumber *) ratioSetting ratioLimit: (NSNumber *) ratioLimit
    40         waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
     40        waitToStart: (NSNumber *) waitToStart
     41        orderValue: (NSNumber *) orderValue groupValue: (NSNumber *) groupValue;
    4142
    4243- (BOOL) shouldUseIncompleteFolderForName: (NSString *) name;
     
    7576            dateActivity: nil
    7677            ratioSetting: nil ratioLimit: nil
    77             waitToStart: nil orderValue: nil];
     78            waitToStart: nil orderValue: nil groupValue: nil];
    7879   
    7980    if (self)
     
    99100                ratioLimit: [history objectForKey: @"RatioLimit"]
    100101                waitToStart: [history objectForKey: @"WaitToStart"]
    101                 orderValue: [history objectForKey: @"OrderValue"]];
     102                orderValue: [history objectForKey: @"OrderValue"]
     103                groupValue: [history objectForKey: @"GroupValue"]];
    102104   
    103105    if (self)
     
    126128                    [NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
    127129                    [NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
    128                     [NSNumber numberWithInt: fOrderValue], @"OrderValue", nil];
     130                    [NSNumber numberWithInt: fOrderValue], @"OrderValue",
     131                    [NSNumber numberWithInt: fGroupValue], @"GroupValue", nil];
    129132   
    130133    if (fIncompleteFolder)
     
    146149- (void) dealloc
    147150{
     151    [[NSNotificationCenter defaultCenter] removeObserver: self];
     152   
    148153    if (fileStat)
    149154        tr_torrentFilesFree(fileStat, [self fileCount]);
     
    11821187}
    11831188
     1189- (int) groupValue
     1190{
     1191    return fGroupValue;
     1192}
     1193
     1194- (void) setGroupValue: (int) goupValue
     1195{
     1196    fGroupValue = goupValue;
     1197}
     1198
     1199- (void) checkGroupValue: (NSNotification *) notification
     1200{
     1201    if (fGroupValue != -1 && [[[notification userInfo] objectForKey: @"Indexes"] containsIndex: fGroupValue])
     1202        fGroupValue = -1;
     1203}
     1204
    11841205- (NSArray *) fileList
    11851206{
     
    14131434        dateActivity: (NSDate *) dateActivity
    14141435        ratioSetting: (NSNumber *) ratioSetting ratioLimit: (NSNumber *) ratioLimit
    1415         waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
     1436        waitToStart: (NSNumber *) waitToStart
     1437        orderValue: (NSNumber *) orderValue groupValue: (NSNumber *) groupValue;
    14161438{
    14171439    if (!(self = [super init]))
     
    14851507   
    14861508    fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(fLib) - 1;
     1509    fGroupValue = groupValue ? [groupValue intValue] : -1;;
     1510   
    14871511    fError = NO;
    14881512   
    14891513    [self createFileList];
     1514   
     1515    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValue:)
     1516        name: @"GroupValueRemoved" object: nil];
    14901517   
    14911518    [self update];
  • trunk/macosx/TorrentCell.m

    r4132 r4183  
    2525#import "TorrentCell.h"
    2626#import "TorrentTableView.h"
     27#import "GroupsWindowController.h"
    2728#import "NSApplicationAdditions.h"
    2829#import "NSStringAdditions.h"
     30#import "NSBezierPathAdditions.h"
    2931#import "CTGradientAdditions.h"
    3032
     
    5052#define PADDING_BETWEEN_BAR_AND_STATUS 2.0
    5153
     54#define GROUP_BORDER_X -4.0
     55#define GROUP_BORDER_Y -1.0
     56
    5257#define MAX_PIECES 324
    5358#define BLANK_PIECE -99
     
    224229   
    225230    //text color
    226     NSColor * titleColor, * statusColor;
    227     if ([NSApp isOnLeopardOrBetter] ? [self backgroundStyle] == NSBackgroundStyleDark : [self isHighlighted]
    228         && [[self highlightColorWithFrame: cellFrame inView: controlView] isEqual: [NSColor alternateSelectedControlColor]])
    229     {
    230         titleColor = [NSColor whiteColor];
    231         statusColor = [NSColor whiteColor];
    232     }
    233     else
    234     {
    235         titleColor = [NSColor controlTextColor];
    236         statusColor = [NSColor darkGrayColor];
    237     }
     231    BOOL selected = [NSApp isOnLeopardOrBetter] ? [self backgroundStyle] == NSBackgroundStyleDark : [self isHighlighted]
     232                    && [[self highlightColorWithFrame: cellFrame inView: controlView] isEqual: [NSColor alternateSelectedControlColor]];
     233    int groupIndex = [torrent groupValue];
     234   
     235    NSColor * titleColor = selected && groupIndex == -1 ? [NSColor whiteColor] : [NSColor controlTextColor],
     236            * statusColor = selected ? [NSColor whiteColor] : [NSColor darkGrayColor];
    238237   
    239238    //minimal status
     
    252251    NSAttributedString * titleString = [self attributedTitleWithColor: titleColor];
    253252    NSRect titleRect = [self rectForTitleWithString: titleString basedOnMinimalStatusRect: minimalStatusRect inBounds: cellFrame];
     253   
     254    if (groupIndex != -1)
     255        [[[GroupsWindowController groupsController] gradientForIndex: [torrent groupValue]] fillBezierPath:
     256            [NSBezierPath bezierPathWithRoundedRect: NSInsetRect(titleRect, GROUP_BORDER_X, GROUP_BORDER_Y) radius: 7.0] angle: 90];
     257   
    254258    [titleString drawInRect: titleRect];
    255259   
  • trunk/macosx/TorrentTableView.m

    r4032 r4183  
    8989}
    9090
    91 - (void) tableView: (NSTableView *) tableView willDisplayCell: (id) cell
    92         forTableColumn: (NSTableColumn *) tableColumn row: (int) row
     91- (void) tableView: (NSTableView *) tableView willDisplayCell: (id) cell forTableColumn: (NSTableColumn *) tableColumn row: (int) row
    9392{
    9493    [cell setRepresentedObject: [fTorrents objectAtIndex: row]];
     
    293292}
    294293
     294#warning get rect to actually change
     295- (NSString *) tableView: (NSTableView *) tableView toolTipForCell: (NSCell *) cell rect: (NSRectPointer) rect
     296    tableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row mouseLocation: (NSPoint) mousePoint
     297{
     298    if ([self pointInActionRect: mousePoint])
     299    {
     300        *rect = [self actionRectForRow: row];
     301       
     302        return NSLocalizedString(@"Shortcuts for changing transfer settings.", "Torrent Table -> tooltip");
     303    }
     304    else if ([self pointInPauseRect: mousePoint])
     305    {
     306        *rect = [self pauseRectForRow: row];
     307       
     308        Torrent * torrent = [fTorrents objectAtIndex: row];
     309        if ([torrent isActive])
     310            return NSLocalizedString(@"Pause the transfer.", "Torrent Table -> tooltip");
     311        else
     312        {
     313            if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask && [fDefaults boolForKey: @"Queue"])
     314                return NSLocalizedString(@"Resume the transfer right away.", "Torrent Table -> tooltip");
     315            else if ([torrent waitingToStart])
     316                return NSLocalizedString(@"Stop waiting to start.", "Torrent Table -> tooltip");
     317            else
     318                return NSLocalizedString(@"Resume the transfer.", "Torrent Table -> tooltip");
     319        }
     320    }
     321    else if ([self pointInRevealRect: mousePoint])
     322    {
     323        *rect = [self revealRectForRow: row];
     324       
     325        return NSLocalizedString(@"Reveal the data file in Finder.", "Torrent Table -> tooltip");
     326    }
     327   
     328    return nil;
     329}
     330
    295331- (void) displayTorrentMenuForEvent: (NSEvent *) event
    296332{
     
    306342    //add file menu items to action menu
    307343    NSRange range = NSMakeRange(0, [fileMenu numberOfItems]);
    308     [fActionMenu appendItemsFromMenu: fileMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange: range]];
     344    [fActionMenu appendItemsFromMenu: fileMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange: range] atBottom: YES];
    309345   
    310346    //place menu below button
     
    322358    //move file menu items back to the torrent's file menu
    323359    range.location = [fActionMenu numberOfItems] - range.length;
    324     [fileMenu appendItemsFromMenu: fActionMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange: range]];
     360    [fileMenu appendItemsFromMenu: fActionMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange: range] atBottom: YES];
    325361   
    326362    [fMenuTorrent release];
     
    605641        if (create)
    606642        {
    607             item = [[NSMenuItem alloc] initWithTitle: name action: NULL keyEquivalent: @""];
     643            item = [[NSMenuItem alloc] initWithTitle: name action: @selector(checkFile:) keyEquivalent: @""];
    608644           
    609645            NSImage * icon;
     
    627663            [item setImage: icon];
    628664           
    629             [item setAction: @selector(checkFile:)];
    630            
    631665            [menu addItem: item];
    632666            [item release];
Note: See TracChangeset for help on using the changeset viewer.