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

in the groups popup in the add window, have an option to show the groups window

This commit is contained in:
Mitchell Livingston 2008-01-05 22:32:34 +00:00
parent 57bc23edc5
commit fac74ffd7b
4 changed files with 576 additions and 459 deletions

View file

@ -43,6 +43,7 @@
NSString * fDestination; NSString * fDestination;
BOOL fDeleteTorrent, fDeleteEnable; BOOL fDeleteTorrent, fDeleteEnable;
int fGroupValue;
} }
- (id) initWithTorrent: (Torrent *) torrent destination: (NSString *) path controller: (Controller *) controller - (id) initWithTorrent: (Torrent *) torrent destination: (NSString *) path controller: (Controller *) controller
@ -56,5 +57,6 @@
- (void) cancelAdd: (id) sender; - (void) cancelAdd: (id) sender;
- (void) updateGroupMenu: (NSNotification *) notification; - (void) updateGroupMenu: (NSNotification *) notification;
- (void) showGroupsWindow: (id) sender;
@end @end

View file

@ -26,11 +26,14 @@
#import "Controller.h" #import "Controller.h"
#import "GroupsWindowController.h" #import "GroupsWindowController.h"
#import "NSStringAdditions.h" #import "NSStringAdditions.h"
#import "NSMenuAdditions.h"
#import "ExpandedPathToIconTransformer.h" #import "ExpandedPathToIconTransformer.h"
@interface AddWindowController (Private) @interface AddWindowController (Private)
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) contextInfo; - (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) contextInfo;
- (void) setGroupsMenu;
- (void) changeGroupValue: (id) sender;
@end @end
@ -50,6 +53,8 @@
fDeleteTorrent = deleteTorrent == TORRENT_FILE_DELETE || (deleteTorrent == TORRENT_FILE_DEFAULT fDeleteTorrent = deleteTorrent == TORRENT_FILE_DELETE || (deleteTorrent == TORRENT_FILE_DEFAULT
&& [[NSUserDefaults standardUserDefaults] boolForKey: @"DeleteOriginalTorrent"]); && [[NSUserDefaults standardUserDefaults] boolForKey: @"DeleteOriginalTorrent"]);
fDeleteEnable = deleteTorrent == TORRENT_FILE_DEFAULT; fDeleteEnable = deleteTorrent == TORRENT_FILE_DEFAULT;
fGroupValue = -1;
} }
return self; return self;
} }
@ -85,7 +90,8 @@
} }
[fStatusField setStringValue: statusString]; [fStatusField setStringValue: statusString];
[fGroupPopUp setMenu: [[GroupsWindowController groups] groupMenuWithTarget: nil action: NULL isSmall: NO]]; [self setGroupsMenu];
[fGroupPopUp selectItemWithTag: -1];
[fStartCheck setState: [[NSUserDefaults standardUserDefaults] boolForKey: @"AutoStartDownload"] ? NSOnState : NSOffState]; [fStartCheck setState: [[NSUserDefaults standardUserDefaults] boolForKey: @"AutoStartDownload"] ? NSOnState : NSOffState];
@ -164,11 +170,18 @@
- (void) updateGroupMenu: (NSNotification *) notification - (void) updateGroupMenu: (NSNotification *) notification
{ {
#warning add option to go to group window [self setGroupsMenu];
if (![fGroupPopUp selectItemWithTag: fGroupValue])
{
fGroupValue = -1;
[fGroupPopUp selectItemWithTag: fGroupValue];
}
}
int groupValue = [[fGroupPopUp selectedItem] tag]; - (void) showGroupsWindow: (id) sender
[fGroupPopUp setMenu: [[GroupsWindowController groups] groupMenuWithTarget: nil action: NULL isSmall: NO]]; {
[fGroupPopUp selectItemWithTag: groupValue]; [fGroupPopUp selectItemWithTag: fGroupValue];
[fController showGroups: sender];
} }
- (void) mouseMoved: (NSEvent *) event - (void) mouseMoved: (NSEvent *) event
@ -205,4 +218,22 @@
} }
} }
- (void) setGroupsMenu
{
NSMenu * menu = [fGroupPopUp menu];
int i;
for (i = [menu numberOfItems]-1 - 2; i >= 0; i--)
[menu removeItemAtIndex: i];
NSMenu * groupMenu = [[GroupsWindowController groups] groupMenuWithTarget: self action: @selector(changeGroupValue:) isSmall: NO];
[menu appendItemsFromMenu: groupMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange:
NSMakeRange(0, [groupMenu numberOfItems])] atBottom: NO];
}
- (void) changeGroupValue: (id) sender
{
fGroupValue = [sender tag];
}
@end @end

View file

@ -798,8 +798,6 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
- (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add - (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add
{ {
[addController close];
Torrent * torrent = [addController torrent]; Torrent * torrent = [addController torrent];
if (add) if (add)
{ {
@ -2055,8 +2053,8 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
{ {
if (menu == fGroupsSetMenu || menu == fGroupsSetContextMenu) if (menu == fGroupsSetMenu || menu == fGroupsSetContextMenu)
{ {
int i, keep = (menu == fGroupsSetMenu || menu == fGroupsSetContextMenu) ? 2 : 0; int i;
for (i = [menu numberOfItems]-1 - keep; i >= 0; i--) for (i = [menu numberOfItems]-1 - 2; i >= 0; i--)
[menu removeItemAtIndex: i]; [menu removeItemAtIndex: i];
NSMenu * groupMenu = [[GroupsWindowController groups] groupMenuWithTarget: self action: @selector(setGroup:) isSmall: NO]; NSMenu * groupMenu = [[GroupsWindowController groups] groupMenuWithTarget: self action: @selector(setGroup:) isSmall: NO];

File diff suppressed because it is too large Load diff