blob: 35e3881f0a0b8b0cdfcedc6dd24b81a972d4ad26 [file] [log] [blame]
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * @copyright See LICENCE for copyright and license information.
4 *
5 * @author Alexander Afanasyev <alexander.afanasyev@ucla.edu>
6 * @author Ilya Moiseenko <iliamo@ucla.edu>
7 */
8
9#import "menu-delegate.h"
10
11@implementation MenuDelegate
12
13- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
14{
15 // Insert code here to initialize your application
16}
17
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070018-(void)awakeFromNib
19{
20 statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070021 [statusItem setMenu:statusMenu];
Ilya Moiseenko350b9b52013-09-25 16:38:41 -070022 [statusItem setToolTip:@"NDN Control Center"];
23 [statusItem setEnabled:YES];
24 //[statusItem setTitle:@"Status"];
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070025 [statusItem setHighlightMode:YES];
Ilya Moiseenko350b9b52013-09-25 16:38:41 -070026 //[statusItem setTarget:self];
27
28 NSBundle *bundle = [NSBundle bundleForClass:[self class]];
Ilya Moiseenkoa10ef8d2013-09-25 17:23:05 -070029 NSString *path = [bundle pathForResource:@"FlatDisconnected" ofType:@"png"];
Ilya Moiseenko350b9b52013-09-25 16:38:41 -070030 menuIcon = [[NSImage alloc] initWithContentsOfFile:path];
31 [statusItem setTitle:@""];
32 [statusItem setImage:menuIcon];
Ilya Moiseenkoa10ef8d2013-09-25 17:23:05 -070033
34 daemonStarted = false;
35}
36
37-(IBAction)switchDaemon:(id)sender
38{
39 if (daemonStarted)
40 {
41 daemonStarted = false;
42 [sender setTitle:@"Start"];
43 [connectionStatus setTitle:@"NDN disconnected"];
44
45 NSBundle *bundle = [NSBundle bundleForClass:[self class]];
46 NSString *path = [bundle pathForResource:@"FlatDisconnected" ofType:@"png"];
47 menuIcon = [[NSImage alloc] initWithContentsOfFile:path];
48 [statusItem setImage:menuIcon];
49 }
50 else
51 {
52 daemonStarted = true;
53 [sender setTitle:@"Stop"];
54 [connectionStatus setTitle:@"NDN connected"];
55
56 NSBundle *bundle = [NSBundle bundleForClass:[self class]];
57 NSString *path = [bundle pathForResource:@"FlatConnected" ofType:@"png"];
58 menuIcon = [[NSImage alloc] initWithContentsOfFile:path];
59 [statusItem setImage:menuIcon];
60 }
Ilya Moiseenko350b9b52013-09-25 16:38:41 -070061}
62
63-(IBAction)openDaemonStatus:(id)sender
64{
65 [statusPopover showRelativeToRect:[[daemonStatus view] bounds]
66 ofView:[daemonStatus view]
67 preferredEdge:NSMinXEdge];
68
69 //[statusPopover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge];
70}
71
72-(IBAction)openRoutingStatusPage:(id)sender
73{
74 NSURL *pageURL = [NSURL URLWithString:@"http://netlab.cs.memphis.edu/script/htm/status.htm"];
75
76 [[NSWorkspace sharedWorkspace] openURL: pageURL];
77}
78
79-(IBAction)openTrafficMapPage:(id)sender
80{
81
82 NSURL *pageURL = [NSURL URLWithString:@"http://ndnmap.arl.wustl.edu"];
83
84 [[NSWorkspace sharedWorkspace] openURL: pageURL];
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070085}
86
87@end