Implemented the status window for song shufflability.
authorKent Sutherland <ksuther@ithinksw.com>
Wed, 14 Sep 2005 05:08:42 +0000 (05:08 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Wed, 14 Sep 2005 05:08:42 +0000 (05:08 +0000)
English.lproj/Localizable.strings
MainController.m
StatusWindowController.h
StatusWindowController.m
iTunesRemote.m

index 67011b8..4badbe6 100755 (executable)
@@ -28,6 +28,8 @@ open = "Open";
 playCount = "Play Count";
 shuffleOn = "Shuffle On";
 shuffleOff = "Shuffle Off";
+shufflableOn = "Current Song Skipped When Shuffling";
+shufflableOff = "Current Song Not Skipped When Shuffling";
 repeatOff = "Repeat Off";
 repeatPlaylist = "Repeat Playlist";
 repeatOneTrack = "Repeat One Track";
index 9a8b493..b9f856a 100755 (executable)
@@ -1349,15 +1349,17 @@ static MainController *sharedController;
 
 - (void)toggleSongShufflable
 {
-       NS_DURING
-        BOOL flag = ![[self currentRemote] currentSongShufflable];
-        ITDebugLog(@"Toggling shufflability.");
-        [[self currentRemote] setCurrentSongShufflable:flag];
-        //Show song shufflability status window
-        //[statusWindowController showSongShuffabilityWindow:flag];
-    NS_HANDLER
-        [self networkError:localException];
-    NS_ENDHANDLER
+       if ([self songIsPlaying]) {
+               NS_DURING
+                       BOOL flag = ![[self currentRemote] currentSongShufflable];
+                       ITDebugLog(@"Toggling shufflability.");
+                       [[self currentRemote] setCurrentSongShufflable:flag];
+                       //Show song shufflability status window
+                       [statusWindowController showSongShufflabilityWindow:flag];
+               NS_HANDLER
+                       [self networkError:localException];
+               NS_ENDHANDLER
+       }
 }
 
 - (void)registerNowOK
index b192d36..307975d 100755 (executable)
@@ -38,6 +38,7 @@ typedef enum {
 - (void)showRatingWindowWithRating:(float)rating;
 - (void)showShuffleWindow:(BOOL)shuffle;
 - (void)showRepeatWindowWithMode:(StatusWindowRepeatMode)mode;
+- (void)showSongShufflabilityWindow:(BOOL)shufflable;
 - (void)showSetupQueryWindow;
 - (void)showRegistrationQueryWindow;
 - (void)showReconnectQueryWindow;
index 269681d..a3336a6 100755 (executable)
@@ -254,6 +254,14 @@ static StatusWindowController *sharedController;
     [_window appear:self];
 }
 
+- (void)showSongShufflabilityWindow:(BOOL)shufflable
+{
+    [_window setImage:[NSImage imageNamed:@"Shuffle"]];
+    [_window setSizing:(ITTransientStatusWindowSizing)[df integerForKey:@"statusWindowSizing"]];
+    [_window buildTextWindowWithString:( !shufflable ? NSLocalizedString(@"shufflableOn", @"Current Song Skipped When Shuffling") : NSLocalizedString(@"shufflableOff", @"Current Song Not Skipped When Shuffling"))];
+    [_window appear:self];
+}
+
 - (void)showSetupQueryWindow
 {
     NSString *message = NSLocalizedString(@"autolaunch_msg", @"Would you like MenuTunes to launch\nautomatically at startup?");
index 3dc2504..c537975 100755 (executable)
                ITDebugLog(@"Not a valid track to set status to, returning.");
                return NO;
        }
-       ITSendAEWithString([NSString stringWithFormat:@"data:long(%lu), '----':obj { form:'prop', want:type('prop'), seld:type('pSfa'), from:obj { form:'indx', want:type('cTrk'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }", !shufflable, [self currentSongIndex]], 'core', 'setd', &savedPSN);
+       ITSendAEWithString([NSString stringWithFormat:@"data:long(%lu), '----':obj { form:'prop', want:type('prop'), seld:type('pSfa'), from:obj { form:'indx', want:type('cTrk'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }", shufflable, [self currentSongIndex]], 'core', 'setd', &savedPSN);
     ITDebugLog(@"Setting current song shufflable status to %i done.", shufflable);
     return YES;
 }