1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

Menu item to switch between filters.

Enable some menu items a little differently.
This commit is contained in:
Mitchell Livingston 2006-09-08 01:14:31 +00:00
parent 8aeb2fba5a
commit ef389beaed
5 changed files with 48 additions and 19 deletions

View file

@ -78,6 +78,7 @@
IBOutlet BarButton * fNoFilterButton, * fPauseFilterButton,
* fSeedFilterButton, * fDownloadFilterButton;
IBOutlet NSSearchField * fSearchFilterField;
IBOutlet NSMenuItem * fNextFilterItem, * fPrevFilterItem;
IBOutlet NSMenuItem * fNextInfoTabItem, * fPrevInfoTabItem;
@ -147,6 +148,7 @@
- (void) setSort: (id) sender;
- (void) applyFilter: (id) sender;
- (void) setFilter: (id) sender;
- (void) switchFilter: (id) sender;
- (void) toggleSpeedLimit: (id) sender;
- (void) autoSpeedLimitChange: (NSNotification *) notification;

View file

@ -148,11 +148,15 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
+ [fTableView rowHeight] + [fTableView intercellSpacing].height;
[fWindow setContentMinSize: contentMinSize];
//set info keyboard shortcuts
unichar ch = NSRightArrowFunctionKey;
[fNextInfoTabItem setKeyEquivalent: [NSString stringWithCharacters: & ch length: 1]];
ch = NSLeftArrowFunctionKey;
[fPrevInfoTabItem setKeyEquivalent: [NSString stringWithCharacters: & ch length: 1]];
//set info and filter keyboard shortcuts
unichar rightChar = NSRightArrowFunctionKey, leftChar = NSLeftArrowFunctionKey;
[fNextInfoTabItem setKeyEquivalent: [NSString stringWithCharacters: & rightChar length: 1]];
[fPrevInfoTabItem setKeyEquivalent: [NSString stringWithCharacters: & leftChar length: 1]];
[fNextFilterItem setKeyEquivalent: [NSString stringWithCharacters: & rightChar length: 1]];
[fNextFilterItem setKeyEquivalentModifierMask: NSCommandKeyMask + NSAlternateKeyMask];
[fPrevFilterItem setKeyEquivalent: [NSString stringWithCharacters: & leftChar length: 1]];
[fPrevFilterItem setKeyEquivalentModifierMask: NSCommandKeyMask + NSAlternateKeyMask];
//set up filter bar
NSView * contentView = [fWindow contentView];
@ -1245,6 +1249,23 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[self applyFilter: nil];
}
- (void) switchFilter: (id) sender
{
NSButton * button;
if ([fFilterType isEqualToString: @"None"])
button = sender == fNextFilterItem ? fDownloadFilterButton : fPauseFilterButton;
else if ([fFilterType isEqualToString: @"Download"])
button = sender == fNextFilterItem ? fSeedFilterButton : fNoFilterButton;
else if ([fFilterType isEqualToString: @"Seed"])
button = sender == fNextFilterItem ? fPauseFilterButton : fDownloadFilterButton;
else if ([fFilterType isEqualToString: @"Pause"])
button = sender == fNextFilterItem ? fNoFilterButton : fSeedFilterButton;
else
button = fNoFilterButton;
[self setFilter: button];
}
- (void) toggleSpeedLimit: (id) sender
{
fSpeedLimitEnabled = !fSpeedLimitEnabled;
@ -2004,12 +2025,16 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
SEL action = [menuItem action];
//only enable some items if it is in a context menu or the window is useable
BOOL canUseMenu = [fWindow isKeyWindow] || [[[menuItem menu] title] isEqualToString: @"Context"];
BOOL canUseTable = [fWindow isKeyWindow] || [[[menuItem menu] title] isEqualToString: @"Context"];
//enable open items
if (action == @selector(openShowSheet:))
return [fWindow attachedSheet] == nil;
//enable sort and advanced bar items
if (action == @selector(setSort:) || action == @selector(toggleAdvancedBar:) || action == @selector(toggleSmallView:))
return [fWindow isVisible];
//enable show info
if (action == @selector(showInfo:))
{
@ -2031,7 +2056,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
if (![[menuItem title] isEqualToString: title])
[menuItem setTitle: title];
return canUseMenu;
return [fWindow isVisible];
}
//enable toggle filter bar
@ -2041,12 +2066,16 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
if (![[menuItem title] isEqualToString: title])
[menuItem setTitle: title];
return canUseMenu;
return [fWindow isVisible];
}
//enable prev/next filter button
if (action == @selector(switchFilter:))
return [fWindow isVisible];
//enable reveal in finder
if (action == @selector(revealFile:))
return canUseMenu && [fTableView numberOfSelectedRows] > 0;
return canUseTable && [fTableView numberOfSelectedRows] > 0;
//enable remove items
if (action == @selector(removeNoDelete:) || action == @selector(removeDeleteData:)
@ -2089,7 +2118,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[menuItem setTitle: [title substringToIndex: [title rangeOfString: ellipsis].location]];
}
return canUseMenu && canDelete && [fTableView numberOfSelectedRows] > 0;
return canUseTable && canDelete && [fTableView numberOfSelectedRows] > 0;
}
//enable pause all item
@ -2131,7 +2160,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
//enable pause item
if (action == @selector(stopSelectedTorrents:))
{
if (!canUseMenu)
if (!canUseTable)
return NO;
Torrent * torrent;
@ -2150,7 +2179,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
//enable resume item
if (action == @selector(resumeSelectedTorrents:))
{
if (!canUseMenu)
if (!canUseTable)
return NO;
Torrent * torrent;
@ -2166,14 +2195,9 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
return NO;
}
//enable sort and advanced bar items
if (action == @selector(setSort:) || action == @selector(toggleAdvancedBar:)
|| action == @selector(toggleSmallView:))
return canUseMenu;
//enable copy torrent file item
if (action == @selector(copyTorrentFile:))
return canUseMenu && [fTableView numberOfSelectedRows] > 0;
return canUseTable && [fTableView numberOfSelectedRows] > 0;
return YES;
}

View file

@ -30,6 +30,7 @@
showPreferenceWindow = id;
stopAllTorrents = id;
stopSelectedTorrents = id;
switchFilter = id;
toggleAdvancedBar = id;
toggleFilterBar = id;
toggleSmallView = id;
@ -50,12 +51,14 @@
fFilterBar = ImageBackgroundView;
fNameSortActionItem = NSMenuItem;
fNameSortItem = NSMenuItem;
fNextFilterItem = NSMenuItem;
fNextInfoTabItem = NSMenuItem;
fNoFilterButton = BarButton;
fOpenIgnoreDownloadFolder = NSMenuItem;
fOrderSortActionItem = NSMenuItem;
fOrderSortItem = NSMenuItem;
fPauseFilterButton = BarButton;
fPrevFilterItem = NSMenuItem;
fPrevInfoTabItem = NSMenuItem;
fProgressSortActionItem = NSMenuItem;
fProgressSortItem = NSMenuItem;

View file

@ -31,8 +31,8 @@
<integer>3</integer>
<key>IBOpenObjects</key>
<array>
<integer>29</integer>
<integer>21</integer>
<integer>29</integer>
</array>
<key>IBSystem Version</key>
<string>8J135</string>

Binary file not shown.