-
Notifications
You must be signed in to change notification settings - Fork 2
/
MenuHandler.m
61 lines (49 loc) · 1.27 KB
/
MenuHandler.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// MenuHandler.m
// TransmissionRemote
//
// Created by Tobias Rundström on 2010-03-13.
// Copyright 2010 Purple Scout. All rights reserved.
//
#import "MenuHandler.h"
#import "TransmissionClient.h"
#import "PreferencesWindow.h"
#import "AboutController.h"
@implementation MenuHandler
-(IBAction)addTorrent:(id)sender
{
NSOpenPanel *panel = [[NSOpenPanel openPanel] retain];
panel.delegate = self;
[panel setCanChooseDirectories:NO];
[panel setCanCreateDirectories:NO];
[panel setAllowsMultipleSelection:YES];
[panel setPrompt:NSLocalizedString(@"Add torrent", nil)];
[panel setMessage:NSLocalizedString(@"Select torrent to add", nil)];
[panel beginWithCompletionHandler:^void (NSInteger result) {
if (result == NSFileHandlingPanelCancelButton) {
return;
}
for (NSURL *Url in [panel URLs]) {
[[TransmissionClient client] addTorrentUrl:Url];
}
[panel release];
}];
}
-(BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
{
if ([filename hasSuffix:@".torrent"]) {
return YES;
}
return NO;
}
-(IBAction)showPreferences:(id)sender
{
PreferencesWindow *win = [PreferencesWindow new];
[win showWindow:nil];
}
-(IBAction)showAboutDialog:(id)sender
{
AboutController *aboutCtrl = [AboutController new];
[aboutCtrl showWindow:nil];
}
@end