#import "PreferencesController.h"
#import "MainController.h"
#import "StatusWindow.h"
+#import "CustomMenuTableView.h"
#import <ITKit/ITHotKeyCenter.h>
#import <ITKit/ITKeyCombo.h>
[launchPlayerAtLaunchCheckbox setTitle:[NSString stringWithFormat:@"Launch %@ when MenuTunes launches", [[controller currentRemote] playerSimpleName]]]; //This isn't localized...
}
-// [window setLevel:NSStatusWindowLevel];
+ [window setLevel:NSStatusWindowLevel];
[window center];
- [NSApp activateIgnoringOtherApps:YES];
[window makeKeyAndOrderFront:self];
}
[self cancelHotKey:sender];
}
+- (void)deletePressedInTableView:(NSTableView *)tableView
+{
+ if (tableView == menuTableView) {
+ int selRow = [tableView selectedRow];
+ if (selRow != - 1) {
+ NSString *object = [myItems objectAtIndex:selRow];
+
+ if ([object isEqualToString:@"preferences"]) {
+ NSBeep();
+ return;
+ }
+
+ if (![object isEqualToString:@"separator"])
+ [availableItems addObject:object];
+ [myItems removeObjectAtIndex:selRow];
+ [menuTableView reloadData];
+ [allTableView reloadData];
+ }
+ [self changeMenus:self];
+ }
+}
/*************************************************************************/
id anItem;
// Set the list of items you can have.
availableItems = [[NSMutableArray alloc] initWithObjects:
+ @"separator",
@"trackInfo",
@"upcomingSongs",
@"playlists",
@"fastForward",
@"rewind",
@"showPlayer",
- @"separator",
+ @"quit",
nil];
// Get our preferred menu
[artistCheckbox setState:[df boolForKey:@"showArtist"] ? NSOnState : NSOffState];
[trackTimeCheckbox setState:[df boolForKey:@"showTime"] ? NSOnState : NSOffState];
[trackNumberCheckbox setState:[df boolForKey:@"showTrackNumber"] ? NSOnState : NSOffState];
+ [ratingCheckbox setState:[df boolForKey:@"showTrackRating"] ? NSOnState : NSOffState];
// Set the launch at login checkbox state
[df synchronize];
- (void)setLaunchesAtLogin:(BOOL)flag
{
- if ( flag ) {
- NSMutableDictionary *loginwindow;
- NSMutableArray *loginarray;
- ComponentInstance temp = OpenDefaultComponent(kOSAComponentType, kAppleScriptSubtype);
- int i;
- BOOL skip = NO;
-
- [df synchronize];
- loginwindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy];
- loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"];
-
- for (i = 0; i < [loginarray count]; i++) {
- NSDictionary *tempDict = [loginarray objectAtIndex:i];
- if ([[[tempDict objectForKey:@"Path"] lastPathComponent] isEqualToString:[[[NSBundle mainBundle] bundlePath] lastPathComponent]]) {
- skip = YES;
- }
- }
-
- if (!skip) {
- AEDesc scriptDesc, resultDesc;
- NSString *script = [NSString stringWithFormat:@"tell application \"System Events\"\nmake new login item at end of login items with properties {path:\"%@\", kind:\"APPLICATION\"}\nend tell", [[NSBundle mainBundle] bundlePath]];
-
- AECreateDesc(typeChar, [script cString], [script cStringLength],
- &scriptDesc);
-
- OSADoScript(temp, &scriptDesc, kOSANullScript, typeChar, kOSAModeCanInteract, &resultDesc);
-
- AEDisposeDesc(&scriptDesc);
- AEDisposeDesc(&resultDesc);
- CloseComponent(temp);
- }
-
+ NSMutableDictionary *loginwindow;
+ NSMutableArray *loginarray;
+
+ [df synchronize];
+ loginwindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy];
+ loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"];
+
+ if (flag) {
+ NSDictionary *itemDict = [NSDictionary dictionaryWithObjectsAndKeys:
+ [[NSBundle mainBundle] bundlePath], @"Path",
+ [NSNumber numberWithInt:0], @"Hide", nil];
+ [loginarray addObject:itemDict];
} else {
- NSMutableDictionary *loginwindow;
- NSMutableArray *loginarray;
int i;
-
- [df synchronize];
- loginwindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy];
- loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"];
-
for (i = 0; i < [loginarray count]; i++) {
NSDictionary *tempDict = [loginarray objectAtIndex:i];
if ([[[tempDict objectForKey:@"Path"] lastPathComponent] isEqualToString:[[[NSBundle mainBundle] bundlePath] lastPathComponent]]) {
[loginarray removeObjectAtIndex:i];
- [df setPersistentDomain:loginwindow forName:@"loginwindow"];
- [df synchronize];
break;
}
}
}
+ [df setPersistentDomain:loginwindow forName:@"loginwindow"];
+ [df synchronize];
+ [loginwindow release];
}
if ([[[info draggingPasteboard] types] containsObject:@"MenuTableViewPboardType"]) {
NSString *item = [myItems objectAtIndex:[[[info draggingPasteboard] stringForType:@"MenuTableViewPboardType"] intValue]];
- if ([item isEqualToString:@"Preferences"] || [item isEqualToString:@"Quit"]) {
+ if ([item isEqualToString:@"preferences"]) {
return NSDragOperationNone;
}
}