Added rating checkbox outlet in Prefs nib and controller. Rating shows up
authorKent Sutherland <ksuther@ithinksw.com>
Thu, 18 Sep 2003 01:59:31 +0000 (01:59 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Thu, 18 Sep 2003 01:59:31 +0000 (01:59 +0000)
in menu. Quit menu item shows up in prefs tables now.

English.lproj/Preferences.nib/classes.nib
English.lproj/Preferences.nib/info.nib
English.lproj/Preferences.nib/keyedobjects.nib
MenuController.m
PreferencesController.h
PreferencesController.m

index f2bcacf..2c165fa 100755 (executable)
@@ -27,6 +27,7 @@
                 nextTrackButton = NSButton; 
                 playPauseButton = NSButton; 
                 previousTrackButton = NSButton; 
+                ratingCheckbox = NSButton; 
                 ratingDecrementButton = NSButton; 
                 ratingIncrementButton = NSButton; 
                 showPlayerButton = NSButton; 
index 7718757..d9513a1 100755 (executable)
@@ -3,9 +3,9 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>1 3 356 240 0 0 1056 770 </string>
+       <string>6 66 356 240 0 0 1152 746 </string>
        <key>IBFramework Version</key>
-       <string>286.0</string>
+       <string>291.0</string>
        <key>IBGroupedObjects</key>
        <dict>
                <key>0</key>
index f99cf5d..59710a3 100755 (executable)
Binary files a/English.lproj/Preferences.nib/keyedobjects.nib and b/English.lproj/Preferences.nib/keyedobjects.nib differ
index b862318..cfd2909 100755 (executable)
                             action:nil
                             keyEquivalent:@""];
                 }
+                
+                if ([defaults boolForKey:@"showTrackRating"]) {
+                    NSString *string;
+                    switch ((int)([currentRemote currentSongRating] * 5)) {
+                        case 0:
+                            string = [NSString stringWithUTF8String:"☆☆☆☆☆"];
+                        break;
+                        case 1:
+                            string = [NSString stringWithUTF8String:"★☆☆☆☆"];
+                        break;
+                        case 2:
+                            string = [NSString stringWithUTF8String:"★★☆☆☆"];
+                        break;
+                        case 3:
+                            string = [NSString stringWithUTF8String:"★★★☆☆"];
+                        break;
+                        case 4:
+                            string = [NSString stringWithUTF8String:"★★★★☆"];
+                        break;
+                        case 5:
+                            string = [NSString stringWithUTF8String:"★★★★★"];
+                        break;
+                    }
+                    [menu addItemWithTitle:
+                        [@"    " stringByAppendingString:string]
+                          action:nil
+                          keyEquivalent:@""];
+                }
             } else {
                 [menu addItemWithTitle:NSLocalizedString(@"noSong", @"No Song") action:NULL keyEquivalent:@""];
             }
index 761a518..1f0094d 100755 (executable)
@@ -30,6 +30,7 @@
     IBOutlet NSButton *nextTrackButton;
     IBOutlet NSButton *playPauseButton;
     IBOutlet NSButton *previousTrackButton;
+    IBOutlet NSButton *ratingCheckbox;
     IBOutlet NSButton *ratingDecrementButton;
     IBOutlet NSButton *ratingIncrementButton;
     IBOutlet NSTextField *songsInAdvance;
index 1cc9355..2f1eb9c 100755 (executable)
@@ -509,6 +509,7 @@ static PreferencesController *prefs = nil;
         @"rewind",
         @"showPlayer",
         @"separator",
+        @"quit",
         nil];
     
     // Get our preferred menu
@@ -657,6 +658,7 @@ static PreferencesController *prefs = nil;
     [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];
@@ -679,57 +681,31 @@ static PreferencesController *prefs = nil;
 
 - (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];
 }
 
 
@@ -857,7 +833,7 @@ static PreferencesController *prefs = nil;
         
         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;
             }
         }