mirror of
https://github.com/transmission/transmission
synced 2025-03-04 02:28:03 +00:00
keep track of sort menu item by using tag and validate methods instead of storing the current menu items
This commit is contained in:
parent
5e5f83523a
commit
2c4244b540
6 changed files with 72 additions and 165 deletions
|
@ -61,11 +61,6 @@
|
|||
IBOutlet StatusBarView * fStatusBar;
|
||||
IBOutlet NSTextField * fTotalDLField, * fTotalULField, * fTotalTorrentsField;
|
||||
|
||||
IBOutlet NSMenuItem * fNameSortItem, * fStateSortItem, * fProgressSortItem,
|
||||
* fTrackerSortItem, * fDateSortItem, * fOrderSortItem,
|
||||
* fNameSortActionItem, * fStateSortActionItem, * fProgressSortActionItem,
|
||||
* fTrackerSortActionItem, * fDateSortActionItem, * fOrderSortActionItem;
|
||||
|
||||
IBOutlet StatusBarView * fFilterBar;
|
||||
IBOutlet NSButton * fNoFilterButton, * fDownloadFilterButton, * fSeedFilterButton, * fPauseFilterButton;
|
||||
IBOutlet NSSearchField * fSearchFilterField;
|
||||
|
|
|
@ -58,6 +58,16 @@
|
|||
#define SORT_TRACKER @"Tracker"
|
||||
#define SORT_ORDER @"Order"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SORT_ORDER_TAG = 0,
|
||||
SORT_DATE_TAG = 1,
|
||||
SORT_NAME_TAG = 2,
|
||||
SORT_PROGRESS_TAG = 3,
|
||||
SORT_STATE_TAG = 4,
|
||||
SORT_TRACKER_TAG = 5
|
||||
} sortTag;
|
||||
|
||||
#define FILTER_NONE @"None"
|
||||
#define FILTER_DOWNLOAD @"Download"
|
||||
#define FILTER_SEED @"Seed"
|
||||
|
@ -292,47 +302,6 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[history release];
|
||||
}
|
||||
|
||||
//set sort
|
||||
#warning clean up
|
||||
NSString * sortType = [fDefaults stringForKey: @"Sort"];
|
||||
|
||||
NSMenuItem * currentSortItem, * currentSortActionItem;
|
||||
if ([sortType isEqualToString: SORT_NAME])
|
||||
{
|
||||
currentSortItem = fNameSortItem;
|
||||
currentSortActionItem = fNameSortActionItem;
|
||||
}
|
||||
else if ([sortType isEqualToString: SORT_STATE])
|
||||
{
|
||||
currentSortItem = fStateSortItem;
|
||||
currentSortActionItem = fStateSortActionItem;
|
||||
}
|
||||
else if ([sortType isEqualToString: SORT_PROGRESS])
|
||||
{
|
||||
currentSortItem = fProgressSortItem;
|
||||
currentSortActionItem = fProgressSortActionItem;
|
||||
}
|
||||
else if ([sortType isEqualToString: SORT_TRACKER])
|
||||
{
|
||||
currentSortItem = fTrackerSortItem;
|
||||
currentSortActionItem = fTrackerSortActionItem;
|
||||
}
|
||||
else if ([sortType isEqualToString: SORT_ORDER])
|
||||
{
|
||||
currentSortItem = fOrderSortItem;
|
||||
currentSortActionItem = fOrderSortActionItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
//safety
|
||||
if (![sortType isEqualToString: SORT_DATE])
|
||||
[fDefaults setObject: SORT_DATE forKey: @"Sort"];
|
||||
currentSortItem = fDateSortItem;
|
||||
currentSortActionItem = fDateSortActionItem;
|
||||
}
|
||||
[currentSortItem setState: NSOnState];
|
||||
[currentSortActionItem setState: NSOnState];
|
||||
|
||||
//set filter
|
||||
NSString * filterType = [fDefaults stringForKey: @"Filter"];
|
||||
|
||||
|
@ -1709,93 +1678,39 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
|
||||
- (void) setSort: (id) sender
|
||||
{
|
||||
NSString * oldSortType = [fDefaults stringForKey: @"Sort"];
|
||||
|
||||
//get checked items
|
||||
NSMenuItem * prevSortItem, * prevSortActionItem;
|
||||
if ([oldSortType isEqualToString: SORT_NAME])
|
||||
NSString * sortType;
|
||||
switch ([sender tag])
|
||||
{
|
||||
prevSortItem = fNameSortItem;
|
||||
prevSortActionItem = fNameSortActionItem;
|
||||
}
|
||||
else if ([oldSortType isEqualToString: SORT_STATE])
|
||||
{
|
||||
prevSortItem = fStateSortItem;
|
||||
prevSortActionItem = fStateSortActionItem;
|
||||
}
|
||||
else if ([oldSortType isEqualToString: SORT_PROGRESS])
|
||||
{
|
||||
prevSortItem = fProgressSortItem;
|
||||
prevSortActionItem = fProgressSortActionItem;
|
||||
}
|
||||
else if ([oldSortType isEqualToString: SORT_TRACKER])
|
||||
{
|
||||
prevSortItem = fTrackerSortItem;
|
||||
prevSortActionItem = fTrackerSortActionItem;
|
||||
}
|
||||
else if ([oldSortType isEqualToString: SORT_ORDER])
|
||||
{
|
||||
prevSortItem = fOrderSortItem;
|
||||
prevSortActionItem = fOrderSortActionItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
prevSortItem = fDateSortItem;
|
||||
prevSortActionItem = fDateSortActionItem;
|
||||
}
|
||||
|
||||
if (sender != prevSortItem && sender != prevSortActionItem)
|
||||
{
|
||||
//get new items to check
|
||||
NSMenuItem * currentSortItem, * currentSortActionItem;
|
||||
NSString * sortType;
|
||||
if (sender == fNameSortItem || sender == fNameSortActionItem)
|
||||
{
|
||||
currentSortItem = fNameSortItem;
|
||||
currentSortActionItem = fNameSortActionItem;
|
||||
sortType = SORT_NAME;
|
||||
}
|
||||
else if (sender == fStateSortItem || sender == fStateSortActionItem)
|
||||
{
|
||||
currentSortItem = fStateSortItem;
|
||||
currentSortActionItem = fStateSortActionItem;
|
||||
sortType = SORT_STATE;
|
||||
}
|
||||
else if (sender == fProgressSortItem || sender == fProgressSortActionItem)
|
||||
{
|
||||
currentSortItem = fProgressSortItem;
|
||||
currentSortActionItem = fProgressSortActionItem;
|
||||
sortType = SORT_PROGRESS;
|
||||
}
|
||||
else if (sender == fTrackerSortItem || sender == fTrackerSortActionItem)
|
||||
{
|
||||
currentSortItem = fTrackerSortItem;
|
||||
currentSortActionItem = fTrackerSortActionItem;
|
||||
sortType = SORT_TRACKER;
|
||||
}
|
||||
else if (sender == fOrderSortItem || sender == fOrderSortActionItem)
|
||||
{
|
||||
currentSortItem = fOrderSortItem;
|
||||
currentSortActionItem = fOrderSortActionItem;
|
||||
case SORT_ORDER_TAG:
|
||||
sortType = SORT_ORDER;
|
||||
|
||||
[fDefaults setBool: NO forKey: @"SortReverse"];
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSortItem = fDateSortItem;
|
||||
currentSortActionItem = fDateSortActionItem;
|
||||
break;
|
||||
|
||||
case SORT_DATE_TAG:
|
||||
sortType = SORT_DATE;
|
||||
}
|
||||
break;
|
||||
|
||||
[fDefaults setObject: sortType forKey: @"Sort"];
|
||||
|
||||
[prevSortItem setState: NSOffState];
|
||||
[prevSortActionItem setState: NSOffState];
|
||||
[currentSortItem setState: NSOnState];
|
||||
[currentSortActionItem setState: NSOnState];
|
||||
case SORT_NAME_TAG:
|
||||
sortType = SORT_NAME;
|
||||
break;
|
||||
|
||||
case SORT_PROGRESS_TAG:
|
||||
sortType = SORT_PROGRESS;
|
||||
break;
|
||||
|
||||
case SORT_STATE_TAG:
|
||||
sortType = SORT_STATE;
|
||||
break;
|
||||
|
||||
case SORT_TRACKER_TAG:
|
||||
sortType = SORT_TRACKER;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
[fDefaults setObject: sortType forKey: @"Sort"];
|
||||
[self sortTorrents];
|
||||
}
|
||||
|
||||
|
@ -2001,7 +1916,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
[self applyFilter: nil];
|
||||
}
|
||||
|
||||
#warning improve
|
||||
#warning improve with matrix
|
||||
- (void) switchFilter: (id) sender
|
||||
{
|
||||
NSString * filterType = [fDefaults stringForKey: @"Filter"];
|
||||
|
@ -2858,7 +2773,35 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
|
||||
//enable sort options
|
||||
if (action == @selector(setSort:))
|
||||
{
|
||||
NSString * sortType;
|
||||
switch ([menuItem tag])
|
||||
{
|
||||
case SORT_ORDER_TAG:
|
||||
sortType = SORT_ORDER;
|
||||
break;
|
||||
case SORT_DATE_TAG:
|
||||
sortType = SORT_DATE;
|
||||
break;
|
||||
case SORT_NAME_TAG:
|
||||
sortType = SORT_NAME;
|
||||
break;
|
||||
case SORT_PROGRESS_TAG:
|
||||
sortType = SORT_PROGRESS;
|
||||
break;
|
||||
case SORT_STATE_TAG:
|
||||
sortType = SORT_STATE;
|
||||
break;
|
||||
case SORT_TRACKER_TAG:
|
||||
sortType = SORT_TRACKER;
|
||||
break;
|
||||
default:
|
||||
sortType = @"";
|
||||
}
|
||||
|
||||
[menuItem setState: [sortType isEqualToString: [fDefaults stringForKey: @"Sort"]] ? NSOnState : NSOffState];
|
||||
return [fWindow isVisible];
|
||||
}
|
||||
|
||||
if (action == @selector(toggleSmallView:))
|
||||
{
|
||||
|
|
34
macosx/English.lproj/MainMenu.nib/classes.nib
generated
34
macosx/English.lproj/MainMenu.nib/classes.nib
generated
|
@ -145,10 +145,6 @@
|
|||
<dict>
|
||||
<key>fActionButton</key>
|
||||
<string>NSButton</string>
|
||||
<key>fDateSortActionItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fDateSortItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fDockMenu</key>
|
||||
<string>NSMenu</string>
|
||||
<key>fDownloadFilterButton</key>
|
||||
|
@ -161,10 +157,6 @@
|
|||
<string>NSMenuItem</string>
|
||||
<key>fFilterBar</key>
|
||||
<string>StatusBarView</string>
|
||||
<key>fNameSortActionItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fNameSortItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fNextFilterItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fNextInfoTabItem</key>
|
||||
|
@ -173,20 +165,12 @@
|
|||
<string>NSButton</string>
|
||||
<key>fOpenIgnoreDownloadFolder</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fOrderSortActionItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fOrderSortItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fPauseFilterButton</key>
|
||||
<string>NSButton</string>
|
||||
<key>fPrevFilterItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fPrevInfoTabItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fProgressSortActionItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fProgressSortItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fScrollView</key>
|
||||
<string>NSScrollView</string>
|
||||
<key>fSearchFilterField</key>
|
||||
|
@ -195,10 +179,6 @@
|
|||
<string>NSButton</string>
|
||||
<key>fSpeedLimitButton</key>
|
||||
<string>NSButton</string>
|
||||
<key>fStateSortActionItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fStateSortItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fStatusBar</key>
|
||||
<string>StatusBarView</string>
|
||||
<key>fTableView</key>
|
||||
|
@ -209,10 +189,6 @@
|
|||
<string>NSTextField</string>
|
||||
<key>fTotalULField</key>
|
||||
<string>NSTextField</string>
|
||||
<key>fTrackerSortActionItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fTrackerSortItem</key>
|
||||
<string>NSMenuItem</string>
|
||||
<key>fURLSheetTextField</key>
|
||||
<string>NSTextField</string>
|
||||
<key>fURLSheetWindow</key>
|
||||
|
@ -290,21 +266,13 @@
|
|||
<key>SUPERCLASS</key>
|
||||
<string>NSPopUpButton</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>ImageBackgroundView</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>NSView</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CLASS</key>
|
||||
<string>StatusBarView</string>
|
||||
<key>LANGUAGE</key>
|
||||
<string>ObjC</string>
|
||||
<key>SUPERCLASS</key>
|
||||
<string>ImageBackgroundView</string>
|
||||
<string>NSView</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>IBVersion</key>
|
||||
|
|
3
macosx/English.lproj/MainMenu.nib/info.nib
generated
3
macosx/English.lproj/MainMenu.nib/info.nib
generated
|
@ -10,7 +10,8 @@
|
|||
<integer>5</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>2</integer>
|
||||
<integer>1639</integer>
|
||||
<integer>1895</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>9A581</string>
|
||||
|
|
BIN
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -29,13 +29,13 @@
|
|||
|
||||
- (id) initWithFrame: (NSRect) rect
|
||||
{
|
||||
if ((self = [super initWithFrame: rect]))
|
||||
if ((self = [super initWithFrame: rect]))
|
||||
{
|
||||
NSColor * beginningColor = [NSColor colorWithCalibratedRed: 208.0/255.0 green: 208.0/255.0 blue: 208.0/255.0 alpha: 1.0];
|
||||
NSColor * endingColor = [NSColor colorWithCalibratedRed: 233.0/255.0 green: 233.0/255.0 blue: 233.0/255.0 alpha: 1.0];
|
||||
fGradient = [[CTGradient gradientWithBeginningColor: beginningColor endingColor: endingColor] retain];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
|
Loading…
Add table
Reference in a new issue