mirror of
https://github.com/transmission/transmission.git
synced 2026-05-08 09:39:08 +01:00
initial group filtering
This commit is contained in:
@@ -8,7 +8,7 @@ NEWS file for Transmission <http://transmission.m0k.org/>
|
||||
+ Updated icon
|
||||
- OS X:
|
||||
+ Redesigned Leopard-like look
|
||||
+ Group labels
|
||||
+ Group labeling, filtering, and sorting
|
||||
+ Statistics window
|
||||
+ Pieces Bar (return of Advanced Bar)
|
||||
+ Display not available overlay on the regular bar
|
||||
|
||||
+4
-1
@@ -80,7 +80,8 @@
|
||||
IBOutlet NSMenuItem * fUploadLimitItem, * fUploadNoLimitItem,
|
||||
* fDownloadLimitItem, * fDownloadNoLimitItem;
|
||||
|
||||
IBOutlet NSMenu * fGroupsSetMenu, * fGroupsSetContextMenu;
|
||||
IBOutlet NSMenu * fGroupsSetMenu, * fGroupsSetContextMenu, * fGroupFilterMenu;
|
||||
IBOutlet NSPopUpButton * fGroupsButton;
|
||||
|
||||
IBOutlet NSWindow * fURLSheetWindow;
|
||||
IBOutlet NSTextField * fURLSheetTextField;
|
||||
@@ -193,6 +194,8 @@
|
||||
|
||||
- (void) showGroups: (id) sender;
|
||||
- (void) setGroup: (id) sender;
|
||||
- (void) setGroupFilter: (id) sender;
|
||||
- (void) updateGroupFilterButton;
|
||||
|
||||
- (void) toggleSpeedLimit: (id) sender;
|
||||
- (void) autoSpeedLimitChange: (NSNotification *) notification;
|
||||
|
||||
+73
-2
@@ -95,6 +95,8 @@ typedef enum
|
||||
#define FILTER_TYPE_TAG_NAME 401
|
||||
#define FILTER_TYPE_TAG_TRACKER 402
|
||||
|
||||
#define GROUP_FILTER_ALL_TAG -2
|
||||
|
||||
#define STATUS_RATIO_TOTAL @"RatioTotal"
|
||||
#define STATUS_RATIO_SESSION @"RatioSession"
|
||||
#define STATUS_TRANSFER_TOTAL @"TransferTotal"
|
||||
@@ -289,6 +291,8 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||
[fPauseFilterButton setFrame: pauseRect];
|
||||
}
|
||||
|
||||
[self updateGroupFilterButton];
|
||||
|
||||
//set up filter bar
|
||||
NSView * contentView = [fWindow contentView];
|
||||
NSSize windowSize = [contentView convertSize: [fWindow frame].size fromView: nil];
|
||||
@@ -1858,8 +1862,21 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||
[fSeedFilterButton setCount: seeding];
|
||||
[fPauseFilterButton setCount: paused];
|
||||
|
||||
//remove for groups
|
||||
int groupFilter = [fDefaults integerForKey: @"FilterGroup"];
|
||||
if (groupFilter != GROUP_FILTER_ALL_TAG)
|
||||
{
|
||||
filtering = YES;
|
||||
|
||||
int i;
|
||||
for (i = [tempTorrents count]-1; i >= 0; i--)
|
||||
if ([[tempTorrents objectAtIndex: i] groupValue] != groupFilter)
|
||||
[tempTorrents removeObjectAtIndex: i];
|
||||
}
|
||||
|
||||
//remove from text field
|
||||
NSString * searchString = [fSearchFilterField stringValue];
|
||||
if ([searchString length] > 0)
|
||||
if ([tempTorrents count] > 0 && [searchString length] > 0)
|
||||
{
|
||||
filtering = YES;
|
||||
|
||||
@@ -2054,10 +2071,23 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||
for (i = [menu numberOfItems]-1 - keep; i >= 0; i--)
|
||||
[menu removeItemAtIndex: i];
|
||||
|
||||
NSMenu * groupMenu = [[GroupsWindowController groupsController] groupMenuWithTarget: self action: @selector(setGroup:)];
|
||||
NSMenu * groupMenu = [[GroupsWindowController groupsController] groupMenuWithTarget: self action: @selector(setGroup:)
|
||||
isSmall: NO];
|
||||
[menu appendItemsFromMenu: groupMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange:
|
||||
NSMakeRange(0, [groupMenu numberOfItems])] atBottom: NO];
|
||||
}
|
||||
else if (menu == fGroupFilterMenu)
|
||||
{
|
||||
int i;
|
||||
for (i = [menu numberOfItems]-1; i >= 3; i--)
|
||||
[menu removeItemAtIndex: i];
|
||||
|
||||
NSMenu * groupMenu = [[GroupsWindowController groupsController] groupMenuWithTarget: self action: @selector(setGroupFilter:)
|
||||
isSmall: YES];
|
||||
[menu appendItemsFromMenu: groupMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange:
|
||||
NSMakeRange(0, [groupMenu numberOfItems])] atBottom: YES];
|
||||
}
|
||||
else;
|
||||
}
|
||||
|
||||
- (void) setGroup: (id) sender
|
||||
@@ -2072,6 +2102,40 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||
[self updateTorrentHistory];
|
||||
}
|
||||
|
||||
- (void) setGroupFilter: (id) sender
|
||||
{
|
||||
[fDefaults setInteger: [sender tag] forKey: @"FilterGroup"];
|
||||
[self updateGroupFilterButton];
|
||||
[self applyFilter: nil];
|
||||
}
|
||||
|
||||
- (void) updateGroupFilterButton
|
||||
{
|
||||
int index = [fDefaults integerForKey: @"FilterGroup"];
|
||||
|
||||
NSImage * icon;
|
||||
if (index >= 0)
|
||||
icon = [[GroupsWindowController groupsController] imageForIndex: index isSmall: YES];
|
||||
else
|
||||
icon = [NSImage imageNamed: NSImageNameRemoveTemplate];
|
||||
[[fGroupFilterMenu itemAtIndex: 0] setImage: icon];
|
||||
|
||||
NSString * toolTip;
|
||||
switch (index)
|
||||
{
|
||||
case GROUP_FILTER_ALL_TAG:
|
||||
toolTip = NSLocalizedString(@"All Groups", "Groups -> Button");
|
||||
break;
|
||||
case -1:
|
||||
toolTip = NSLocalizedString(@"Group: No Label", "Groups -> Button");
|
||||
break;
|
||||
default:
|
||||
toolTip = [NSLocalizedString(@"Group: ", "Groups -> Button") stringByAppendingString:
|
||||
[[GroupsWindowController groupsController] nameForIndex: index]];
|
||||
}
|
||||
[fGroupsButton setToolTip: toolTip];
|
||||
}
|
||||
|
||||
- (void) toggleSpeedLimit: (id) sender
|
||||
{
|
||||
[fDefaults setBool: ![fDefaults boolForKey: @"SpeedLimit"] forKey: @"SpeedLimit"];
|
||||
@@ -2664,6 +2728,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||
{
|
||||
[fSearchFilterField setStringValue: @""];
|
||||
[self setFilter: fNoFilterButton];
|
||||
[self setGroupFilter: [fGroupFilterMenu itemWithTag: GROUP_FILTER_ALL_TAG]];
|
||||
}
|
||||
|
||||
[self showFilterBar: [fFilterBar isHidden] animate: YES];
|
||||
@@ -3111,6 +3176,12 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||
return canUseTable && [fTableView numberOfSelectedRows] > 0;
|
||||
}
|
||||
|
||||
if (action == @selector(setGroupFilter:))
|
||||
{
|
||||
[menuItem setState: [menuItem tag] == [fDefaults integerForKey: @"FilterGroup"] ? NSOnState : NSOffState];
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (action == @selector(toggleSmallView:))
|
||||
{
|
||||
[menuItem setState: [fDefaults boolForKey: @"SmallView"] ? NSOnState : NSOffState];
|
||||
|
||||
@@ -58,6 +58,8 @@
|
||||
<string>None</string>
|
||||
<key>FilterBar</key>
|
||||
<false/>
|
||||
<key>FilterGroup</key>
|
||||
<integer>-2</integer>
|
||||
<key>FilterSearchType</key>
|
||||
<string>Name</string>
|
||||
<key>IncompleteDownloadFolder</key>
|
||||
|
||||
+14
-8
@@ -112,6 +112,8 @@
|
||||
<string>id</string>
|
||||
<key>setGroup</key>
|
||||
<string>id</string>
|
||||
<key>setGroupFilter</key>
|
||||
<string>id</string>
|
||||
<key>setInfoTab</key>
|
||||
<string>id</string>
|
||||
<key>setLimitGlobalEnabled</key>
|
||||
@@ -185,6 +187,10 @@
|
||||
<string>NSMenuItem</string>
|
||||
<key>fFilterBar</key>
|
||||
<string>StatusBarView</string>
|
||||
<key>fGroupFilterMenu</key>
|
||||
<string>NSMenu</string>
|
||||
<key>fGroupsButton</key>
|
||||
<string>NSPopUpButton</string>
|
||||
<key>fGroupsSetContextMenu</key>
|
||||
<string>NSMenu</string>
|
||||
<key>fGroupsSetMenu</key>
|
||||
@@ -258,6 +264,14 @@
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSObject</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>FilterButton</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSButton</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ACTIONS</key>
|
||||
<dict>
|
||||
@@ -296,14 +310,6 @@
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSTableView</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>FilterButton</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSButton</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>ActionPopUpButton</string>
|
||||
|
||||
+1
-3
@@ -9,9 +9,7 @@
|
||||
<key>IBOldestOS</key>
|
||||
<integer>5</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>2279</integer>
|
||||
</array>
|
||||
<array/>
|
||||
<key>IBSystem Version</key>
|
||||
<string>9B18</string>
|
||||
<key>targetFramework</key>
|
||||
|
||||
BIN
Binary file not shown.
@@ -38,12 +38,13 @@
|
||||
|
||||
+ (GroupsWindowController *) groupsController;
|
||||
|
||||
- (CTGradient *) gradientForIndex: (int) index;
|
||||
|
||||
- (int) orderValueForIndex: (int) index;
|
||||
- (CTGradient *) gradientForIndex: (int) index;
|
||||
- (NSString *) nameForIndex: (int) index;
|
||||
- (NSImage *) imageForIndex: (int) index isSmall: (BOOL) small;
|
||||
|
||||
- (void) addRemoveGroup: (id) sender;
|
||||
|
||||
- (NSMenu *) groupMenuWithTarget: (id) target action: (SEL) action;
|
||||
- (NSMenu *) groupMenuWithTarget: (id) target action: (SEL) action isSmall: (BOOL) small;
|
||||
|
||||
@end
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#import "NSBezierPathAdditions.h"
|
||||
#import "NSApplicationAdditions.h"
|
||||
|
||||
#define ICON_WIDTH 16.0
|
||||
#define ICON_WIDTH_SMALL 12.0
|
||||
|
||||
#define GROUP_TABLE_VIEW_DATA_TYPE @"GroupTableViewDataType"
|
||||
|
||||
typedef enum
|
||||
@@ -133,20 +136,6 @@ GroupsWindowController * fGroupsWindowInstance = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (CTGradient *) gradientForIndex: (int) index
|
||||
{
|
||||
if (index < 0)
|
||||
return nil;
|
||||
|
||||
NSEnumerator * enumerator = [fGroups objectEnumerator];
|
||||
NSDictionary * dict;
|
||||
while ((dict = [enumerator nextObject]))
|
||||
if ([[dict objectForKey: @"Index"] intValue] == index)
|
||||
return [self gradientForColor: [dict objectForKey: @"Color"]];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (int) orderValueForIndex: (int) index
|
||||
{
|
||||
if (index != -1)
|
||||
@@ -159,6 +148,35 @@ GroupsWindowController * fGroupsWindowInstance = nil;
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (CTGradient *) gradientForIndex: (int) index
|
||||
{
|
||||
int orderIndex = [self orderValueForIndex: index];
|
||||
return orderIndex != -1 ? [self gradientForColor: [[fGroups objectAtIndex: orderIndex] objectForKey: @"Color"]] : nil;
|
||||
}
|
||||
|
||||
- (NSString *) nameForIndex: (int) index
|
||||
{
|
||||
int orderIndex = [self orderValueForIndex: index];
|
||||
return orderIndex != -1 ? [[fGroups objectAtIndex: orderIndex] objectForKey: @"Name"] : nil;
|
||||
}
|
||||
|
||||
- (NSImage *) imageForIndex: (int) index isSmall: (BOOL) small
|
||||
{
|
||||
CTGradient * gradient;
|
||||
if (!(gradient = [self gradientForIndex: index]))
|
||||
return nil;
|
||||
|
||||
float width = small ? ICON_WIDTH_SMALL : ICON_WIDTH;
|
||||
NSBezierPath * bp = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(0.0, 0.0, width, width) radius: 4.0];
|
||||
NSImage * icon = [[NSImage alloc] initWithSize: [bp bounds].size];
|
||||
|
||||
[icon lockFocus];
|
||||
[gradient fillBezierPath: bp angle: 270.0];
|
||||
[icon unlockFocus];
|
||||
|
||||
return [icon autorelease];
|
||||
}
|
||||
|
||||
- (NSInteger) numberOfRowsInTableView: (NSTableView *) tableview
|
||||
{
|
||||
return [fGroups count];
|
||||
@@ -329,7 +347,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
|
||||
[self saveGroups];
|
||||
}
|
||||
|
||||
- (NSMenu *) groupMenuWithTarget: (id) target action: (SEL) action
|
||||
- (NSMenu *) groupMenuWithTarget: (id) target action: (SEL) action isSmall: (BOOL) small
|
||||
{
|
||||
NSMenu * menu = [[NSMenu alloc] initWithTitle: @"Groups"];
|
||||
|
||||
@@ -340,8 +358,6 @@ GroupsWindowController * fGroupsWindowInstance = nil;
|
||||
[menu addItem: item];
|
||||
[item release];
|
||||
|
||||
NSBezierPath * bp = [NSBezierPath bezierPathWithRoundedRect: NSMakeRect(0.0, 0.0, 16.0, 16.0) radius: 4.0];
|
||||
|
||||
NSEnumerator * enumerator = [fGroups objectEnumerator];
|
||||
NSDictionary * dict;
|
||||
while ((dict = [enumerator nextObject]))
|
||||
@@ -349,21 +365,17 @@ GroupsWindowController * fGroupsWindowInstance = nil;
|
||||
item = [[NSMenuItem alloc] initWithTitle: [dict objectForKey: @"Name"] action: action keyEquivalent: @""];
|
||||
[item setTarget: target];
|
||||
|
||||
NSImage * icon = [[NSImage alloc] initWithSize: [bp bounds].size];
|
||||
int index = [[dict objectForKey: @"Index"] intValue];
|
||||
|
||||
[icon lockFocus];
|
||||
[[self gradientForColor: [dict objectForKey: @"Color"]] fillBezierPath: bp angle: 270.0];
|
||||
[icon unlockFocus];
|
||||
|
||||
[item setImage: icon];
|
||||
[icon release];
|
||||
|
||||
[item setTag: [[dict objectForKey: @"Index"] intValue]];
|
||||
#warning use dict
|
||||
[item setImage: [self imageForIndex: index isSmall: small]];
|
||||
[item setTag: index];
|
||||
|
||||
[menu addItem: item];
|
||||
[item release];
|
||||
}
|
||||
|
||||
|
||||
return [menu autorelease];
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#import "PortChecker.h"
|
||||
#import "NSApplicationAdditions.h"
|
||||
|
||||
#define CHECKER_URL @"http://transmission.m0k.org/PortCheck.php?port=%d"
|
||||
|
||||
@implementation PortChecker
|
||||
|
||||
- (id) initForPort: (int) portNumber withDelegate: (id) delegate
|
||||
@@ -34,7 +36,7 @@
|
||||
fDelegate = delegate;
|
||||
|
||||
NSURLRequest * portProbeRequest = [NSURLRequest requestWithURL: [NSURL URLWithString:
|
||||
[NSString stringWithFormat: @"http://transmission.m0k.org/PortCheck.php?port=%d", portNumber]] cachePolicy:
|
||||
[NSString stringWithFormat: CHECKER_URL, portNumber]] cachePolicy:
|
||||
[NSApp isOnLeopardOrBetter] ? NSURLRequestReloadIgnoringLocalCacheData : NSURLRequestReloadIgnoringCacheData
|
||||
timeoutInterval: 15.0];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user