|
49 | 49 |
|
50 | 50 | extern DB_functions_t *deadbeef; |
51 | 51 |
|
52 | | -@interface AppDelegate () { |
| 52 | +@interface AppDelegate () <NSMenuDelegate> { |
53 | 53 | char *_titleScript; |
54 | 54 | char *_artistAlbumScript; |
55 | 55 | int _listenerFileAddBeginAddIdentifier; |
56 | 56 | int _listenerFileAddedIdentifier; |
57 | 57 | } |
58 | 58 |
|
| 59 | +@property (unsafe_unretained) IBOutlet NSMenuItem *mainWindowToggleMenuItem; |
| 60 | +@property (unsafe_unretained) IBOutlet NSMenuItem *logWindowToggleMenuItem; |
| 61 | +@property (weak) IBOutlet NSMenuItem *equalizerWindowToggleMenuItem; |
| 62 | + |
| 63 | + |
| 64 | +@property (unsafe_unretained) IBOutlet NSMenu *mainMenu; |
| 65 | +@property (unsafe_unretained) IBOutlet NSMenu *dockMenu; |
| 66 | + |
| 67 | + |
| 68 | +@property (unsafe_unretained) IBOutlet NSWindow *addFilesWindow; |
| 69 | +@property (unsafe_unretained) IBOutlet NSTextField *addFilesLabel; |
| 70 | +- (IBAction)addFilesCancel:(id)sender; |
| 71 | + |
| 72 | +@property (unsafe_unretained) IBOutlet NSPanel *customSortPanel; |
| 73 | +@property (unsafe_unretained) IBOutlet NSTextField *customSortEntry; |
| 74 | +@property (unsafe_unretained) IBOutlet NSButton *customSortDescending; |
| 75 | + |
| 76 | + |
| 77 | +- (IBAction)customSortCancelAction:(id)sender; |
| 78 | +- (IBAction)customSortOKAction:(id)sender; |
| 79 | + |
| 80 | +- (IBAction)toggleDescendingSortOrderAction:(id)sender; |
| 81 | +@property (unsafe_unretained) IBOutlet NSMenuItem *descendingSortMode; |
| 82 | + |
| 83 | +- (IBAction)openPrefWindow:(id)sender; |
| 84 | + |
| 85 | +// file menu |
| 86 | +- (IBAction)openFilesAction:(id)sender; |
| 87 | +- (IBAction)addFilesAction:(id)sender; |
| 88 | +- (IBAction)addFoldersAction:(id)sender; |
| 89 | +- (IBAction)addLocationAction:(id)sender; |
| 90 | +@property (unsafe_unretained) IBOutlet NSPanel *addLocationPanel; |
| 91 | +- (IBAction)addLocationOKAction:(id)sender; |
| 92 | +- (IBAction)addLocationCancelAction:(id)sender; |
| 93 | +@property (unsafe_unretained) IBOutlet NSTextField *addLocationTextField; |
| 94 | + |
| 95 | +- (IBAction)newPlaylistAction:(id)sender; |
| 96 | +- (IBAction)loadPlaylistAction:(id)sender; |
| 97 | +- (IBAction)savePlaylistAction:(id)sender; |
| 98 | + |
| 99 | + |
| 100 | +// edit menu |
| 101 | +- (IBAction)clearAction:(id)sender; |
| 102 | + |
| 103 | +- (IBAction)sortPlaylistByTitle:(id)sender; |
| 104 | +- (IBAction)sortPlaylistByTrackNumber:(id)sender; |
| 105 | +- (IBAction)sortPlaylistByAlbum:(id)sender; |
| 106 | +- (IBAction)sortPlaylistByArtist:(id)sender; |
| 107 | +- (IBAction)sortPlaylistByDate:(id)sender; |
| 108 | +- (IBAction)sortPlaylistRandom:(id)sender; |
| 109 | +- (IBAction)sortPlaylistCustom:(id)sender; |
| 110 | + |
| 111 | +// playback menu |
| 112 | +- (IBAction)previousAction:(id)sender; |
| 113 | +- (IBAction)playAction:(id)sender; |
| 114 | +- (IBAction)pauseAction:(id)sender; |
| 115 | +- (IBAction)stopAction:(id)sender; |
| 116 | +- (IBAction)nextAction:(id)sender; |
| 117 | + |
| 118 | +@property (unsafe_unretained) IBOutlet NSMenuItem *orderLinear; |
| 119 | +@property (unsafe_unretained) IBOutlet NSMenuItem *orderRandom; |
| 120 | +@property (unsafe_unretained) IBOutlet NSMenuItem *orderShuffle; |
| 121 | +@property (unsafe_unretained) IBOutlet NSMenuItem *orderShuffleAlbums; |
| 122 | +- (IBAction)orderLinearAction:(id)sender; |
| 123 | +- (IBAction)orderRandomAction:(id)sender; |
| 124 | +- (IBAction)orderShuffleAction:(id)sender; |
| 125 | +- (IBAction)orderShuffleAlbumsAction:(id)sender; |
| 126 | + |
| 127 | +@property (unsafe_unretained) IBOutlet NSMenuItem *loopNone; |
| 128 | +@property (unsafe_unretained) IBOutlet NSMenuItem *loopAll; |
| 129 | +@property (unsafe_unretained) IBOutlet NSMenuItem *loopSingle; |
| 130 | +- (IBAction)loopNoneAction:(id)sender; |
| 131 | +- (IBAction)loopAllAction:(id)sender; |
| 132 | +- (IBAction)loopSingleAction:(id)sender; |
| 133 | + |
| 134 | +// window menu |
| 135 | +- (IBAction)showMainWinAction:(id)sender; |
| 136 | +- (IBAction)showLogWindowAction:(id)sender; |
| 137 | + |
59 | 138 | @property (unsafe_unretained) IBOutlet NSMenuItem *cursorFollowsPlayback; |
60 | 139 | @property (unsafe_unretained) IBOutlet NSMenuItem *scrollFollowsPlayback; |
61 | 140 | @property (unsafe_unretained) IBOutlet NSMenuItem *stopAfterCurrentTrack; |
@@ -114,40 +193,6 @@ - (void)outputDeviceChanged { |
114 | 193 | } |
115 | 194 |
|
116 | 195 | - (void)configChanged { |
117 | | - NSMenuItem *shuffle_items[] = { |
118 | | - _orderLinear, |
119 | | - _orderShuffle, |
120 | | - _orderRandom, |
121 | | - _orderShuffleAlbums, |
122 | | - nil |
123 | | - }; |
124 | | - |
125 | | - ddb_shuffle_t shuffle = deadbeef->streamer_get_shuffle (); |
126 | | - for (ddb_shuffle_t i = 0; shuffle_items[i]; i++) { |
127 | | - shuffle_items[i].state = i==shuffle?NSControlStateValueOn:NSControlStateValueOff; |
128 | | - } |
129 | | - |
130 | | - NSMenuItem *repeat_items[] = { |
131 | | - _loopAll, |
132 | | - _loopNone, |
133 | | - _loopSingle, |
134 | | - nil |
135 | | - }; |
136 | | - |
137 | | - ddb_repeat_t repeat = deadbeef->streamer_get_repeat (); |
138 | | - for (ddb_repeat_t i = 0; repeat_items[i]; i++) { |
139 | | - repeat_items[i].state = i==repeat?NSControlStateValueOn:NSControlStateValueOff; |
140 | | - } |
141 | | - |
142 | | - _scrollFollowsPlayback.state = deadbeef->conf_get_int ("playlist.scroll.followplayback", 1)?NSControlStateValueOn:NSControlStateValueOff; |
143 | | - _cursorFollowsPlayback.state = deadbeef->conf_get_int ("playlist.scroll.cursorfollowplayback", 1)?NSControlStateValueOn:NSControlStateValueOff; |
144 | | - |
145 | | - _stopAfterCurrentTrack.state = deadbeef->conf_get_int ("playlist.stop_after_current", 0)?NSControlStateValueOn:NSControlStateValueOff; |
146 | | - _stopAfterCurrentAlbum.state = deadbeef->conf_get_int ("playlist.stop_after_album", 0)?NSControlStateValueOn:NSControlStateValueOff; |
147 | | - _stopAfterPlaybackQueue.state = deadbeef->conf_get_int ("playlist.stop_after_queue", 0)?NSControlStateValueOn:NSControlStateValueOff; |
148 | | - |
149 | | - _descendingSortMode.state = deadbeef->conf_get_int ("cocoaui.sort_desc", 0) ? NSControlStateValueOn : NSControlStateValueOff; |
150 | | - |
151 | 196 | [self volumeChanged]; |
152 | 197 |
|
153 | 198 | [_mainWindow updateTitleBarConfig]; |
@@ -751,9 +796,15 @@ - (IBAction)playRandomAction:(id)sender { |
751 | 796 | } |
752 | 797 |
|
753 | 798 | - (IBAction)cursorFollowsPlaybackAction:(id)sender { |
| 799 | + int state = self.cursorFollowsPlayback.state == NSControlStateValueOn; |
| 800 | + deadbeef->conf_set_int ("playlist.scroll.cursorfollowplayback", !state); |
| 801 | + deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0); |
754 | 802 | } |
755 | 803 |
|
756 | 804 | - (IBAction)scrollFollowsPlaybackAction:(id)sender { |
| 805 | + int state = self.scrollFollowsPlayback.state == NSControlStateValueOn; |
| 806 | + deadbeef->conf_set_int ("playlist.scroll.followplayback", !state); |
| 807 | + deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0); |
757 | 808 | } |
758 | 809 |
|
759 | 810 | - (IBAction)stopAfterCurrentTrackAction:(id)sender { |
@@ -1094,4 +1145,42 @@ - (IBAction)editKeybooardShortcutsAction:(id)sender { |
1094 | 1145 | [self.keyboardShortcutEditorWindowController showWindow:nil]; |
1095 | 1146 | } |
1096 | 1147 |
|
| 1148 | +#pragma mark - NSMenuDelegate |
| 1149 | + |
| 1150 | +- (void)menuNeedsUpdate:(NSMenu *)menu { |
| 1151 | + self.scrollFollowsPlayback.state = deadbeef->conf_get_int ("playlist.scroll.followplayback", 1) ? NSControlStateValueOn : NSControlStateValueOff; |
| 1152 | + self.cursorFollowsPlayback.state = deadbeef->conf_get_int ("playlist.scroll.cursorfollowplayback", 1) ? NSControlStateValueOn : NSControlStateValueOff; |
| 1153 | + |
| 1154 | + self.stopAfterCurrentTrack.state = deadbeef->conf_get_int ("playlist.stop_after_current", 0) ? NSControlStateValueOn : NSControlStateValueOff; |
| 1155 | + self.stopAfterCurrentAlbum.state = deadbeef->conf_get_int ("playlist.stop_after_album", 0) ? NSControlStateValueOn : NSControlStateValueOff; |
| 1156 | + self.stopAfterPlaybackQueue.state = deadbeef->conf_get_int ("playlist.stop_after_queue", 0) ? NSControlStateValueOn : NSControlStateValueOff; |
| 1157 | + |
| 1158 | + self.descendingSortMode.state = deadbeef->conf_get_int ("cocoaui.sort_desc", 0) ? NSControlStateValueOn : NSControlStateValueOff; |
| 1159 | + |
| 1160 | + NSMenuItem *shuffle_items[] = { |
| 1161 | + _orderLinear, |
| 1162 | + _orderShuffle, |
| 1163 | + _orderRandom, |
| 1164 | + _orderShuffleAlbums, |
| 1165 | + nil |
| 1166 | + }; |
| 1167 | + |
| 1168 | + ddb_shuffle_t shuffle = deadbeef->streamer_get_shuffle (); |
| 1169 | + for (ddb_shuffle_t i = 0; shuffle_items[i]; i++) { |
| 1170 | + shuffle_items[i].state = i==shuffle?NSControlStateValueOn:NSControlStateValueOff; |
| 1171 | + } |
| 1172 | + |
| 1173 | + NSMenuItem *repeat_items[] = { |
| 1174 | + _loopAll, |
| 1175 | + _loopNone, |
| 1176 | + _loopSingle, |
| 1177 | + nil |
| 1178 | + }; |
| 1179 | + |
| 1180 | + ddb_repeat_t repeat = deadbeef->streamer_get_repeat (); |
| 1181 | + for (ddb_repeat_t i = 0; repeat_items[i]; i++) { |
| 1182 | + repeat_items[i].state = i==repeat?NSControlStateValueOn:NSControlStateValueOff; |
| 1183 | + } |
| 1184 | +} |
| 1185 | + |
1097 | 1186 | @end |
0 commit comments