-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathSPMenuItem.m
51 lines (36 loc) · 997 Bytes
/
SPMenuItem.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
//
// SPMenuItem.m
// tetherKit
//
// Created by Kevin Bradley on 1/19/11.
// Copyright 2011 FireCore, LLC. All rights reserved.
//
#import "SPMenuItem.h"
#import "tetherKitAppDelegate.h"
@implementation SPMenuItem
- (IBAction)add:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:[sender title] forKey:@"lastUsedBundle"];
[[NSApp delegate] itunesRestore:nil];
}
- (BOOL)hasSubmenu
{
return YES;
}
- (NSMenu *)submenu
{
NSMenu *theMenu = [[NSMenu alloc] init];
[theMenu setAutoenablesItems:YES];
NSArray *appBundles = [tetherKitAppDelegate appSupportBundles];
//NSLog(@"appBundles: %@", appBundles);
NSEnumerator *bundleEnum = [appBundles objectEnumerator];
id currentObject = nil;
while (currentObject = [bundleEnum nextObject])
{
NSMenuItem *theItem = [[NSMenuItem alloc] initWithTitle:currentObject action:@selector(add:) keyEquivalent:@""];
[theItem setTarget:self];
[theMenu addItem:[theItem autorelease]];
}
return theMenu;
}
@end