Skip to content

Commit bc45180

Browse files
cocoaui: Fix missing implementations of cursorFollowsPlaybackAction and scrollFollowsPlaybackAction
1 parent f53d038 commit bc45180

File tree

3 files changed

+127
-114
lines changed

3 files changed

+127
-114
lines changed

plugins/cocoaui/AppDelegate.h

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -38,83 +38,4 @@
3838

3939
@property (nonatomic,readonly) MediaLibraryManager *mediaLibraryManager;
4040

41-
@property (unsafe_unretained) IBOutlet NSMenuItem *mainWindowToggleMenuItem;
42-
@property (unsafe_unretained) IBOutlet NSMenuItem *logWindowToggleMenuItem;
43-
@property (weak) IBOutlet NSMenuItem *equalizerWindowToggleMenuItem;
44-
45-
46-
@property (unsafe_unretained) IBOutlet NSMenu *mainMenu;
47-
@property (unsafe_unretained) IBOutlet NSMenu *dockMenu;
48-
49-
50-
@property (unsafe_unretained) IBOutlet NSWindow *addFilesWindow;
51-
@property (unsafe_unretained) IBOutlet NSTextField *addFilesLabel;
52-
- (IBAction)addFilesCancel:(id)sender;
53-
54-
@property (unsafe_unretained) IBOutlet NSPanel *customSortPanel;
55-
@property (unsafe_unretained) IBOutlet NSTextField *customSortEntry;
56-
@property (unsafe_unretained) IBOutlet NSButton *customSortDescending;
57-
58-
59-
- (IBAction)customSortCancelAction:(id)sender;
60-
- (IBAction)customSortOKAction:(id)sender;
61-
62-
- (IBAction)toggleDescendingSortOrderAction:(id)sender;
63-
@property (unsafe_unretained) IBOutlet NSMenuItem *descendingSortMode;
64-
65-
- (IBAction)openPrefWindow:(id)sender;
66-
67-
// file menu
68-
- (IBAction)openFilesAction:(id)sender;
69-
- (IBAction)addFilesAction:(id)sender;
70-
- (IBAction)addFoldersAction:(id)sender;
71-
- (IBAction)addLocationAction:(id)sender;
72-
@property (unsafe_unretained) IBOutlet NSPanel *addLocationPanel;
73-
- (IBAction)addLocationOKAction:(id)sender;
74-
- (IBAction)addLocationCancelAction:(id)sender;
75-
@property (unsafe_unretained) IBOutlet NSTextField *addLocationTextField;
76-
77-
- (IBAction)newPlaylistAction:(id)sender;
78-
- (IBAction)loadPlaylistAction:(id)sender;
79-
- (IBAction)savePlaylistAction:(id)sender;
80-
81-
82-
// edit menu
83-
- (IBAction)clearAction:(id)sender;
84-
85-
- (IBAction)sortPlaylistByTitle:(id)sender;
86-
- (IBAction)sortPlaylistByTrackNumber:(id)sender;
87-
- (IBAction)sortPlaylistByAlbum:(id)sender;
88-
- (IBAction)sortPlaylistByArtist:(id)sender;
89-
- (IBAction)sortPlaylistByDate:(id)sender;
90-
- (IBAction)sortPlaylistRandom:(id)sender;
91-
- (IBAction)sortPlaylistCustom:(id)sender;
92-
93-
// playback menu
94-
- (IBAction)previousAction:(id)sender;
95-
- (IBAction)playAction:(id)sender;
96-
- (IBAction)pauseAction:(id)sender;
97-
- (IBAction)stopAction:(id)sender;
98-
- (IBAction)nextAction:(id)sender;
99-
100-
@property (unsafe_unretained) IBOutlet NSMenuItem *orderLinear;
101-
@property (unsafe_unretained) IBOutlet NSMenuItem *orderRandom;
102-
@property (unsafe_unretained) IBOutlet NSMenuItem *orderShuffle;
103-
@property (unsafe_unretained) IBOutlet NSMenuItem *orderShuffleAlbums;
104-
- (IBAction)orderLinearAction:(id)sender;
105-
- (IBAction)orderRandomAction:(id)sender;
106-
- (IBAction)orderShuffleAction:(id)sender;
107-
- (IBAction)orderShuffleAlbumsAction:(id)sender;
108-
109-
@property (unsafe_unretained) IBOutlet NSMenuItem *loopNone;
110-
@property (unsafe_unretained) IBOutlet NSMenuItem *loopAll;
111-
@property (unsafe_unretained) IBOutlet NSMenuItem *loopSingle;
112-
- (IBAction)loopNoneAction:(id)sender;
113-
- (IBAction)loopAllAction:(id)sender;
114-
- (IBAction)loopSingleAction:(id)sender;
115-
116-
// window menu
117-
- (IBAction)showMainWinAction:(id)sender;
118-
- (IBAction)showLogWindowAction:(id)sender;
119-
12041
@end

plugins/cocoaui/AppDelegate.m

Lines changed: 124 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,92 @@
4949

5050
extern DB_functions_t *deadbeef;
5151

52-
@interface AppDelegate () {
52+
@interface AppDelegate () <NSMenuDelegate> {
5353
char *_titleScript;
5454
char *_artistAlbumScript;
5555
int _listenerFileAddBeginAddIdentifier;
5656
int _listenerFileAddedIdentifier;
5757
}
5858

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+
59138
@property (unsafe_unretained) IBOutlet NSMenuItem *cursorFollowsPlayback;
60139
@property (unsafe_unretained) IBOutlet NSMenuItem *scrollFollowsPlayback;
61140
@property (unsafe_unretained) IBOutlet NSMenuItem *stopAfterCurrentTrack;
@@ -114,40 +193,6 @@ - (void)outputDeviceChanged {
114193
}
115194

116195
- (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-
151196
[self volumeChanged];
152197

153198
[_mainWindow updateTitleBarConfig];
@@ -751,9 +796,15 @@ - (IBAction)playRandomAction:(id)sender {
751796
}
752797

753798
- (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);
754802
}
755803

756804
- (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);
757808
}
758809

759810
- (IBAction)stopAfterCurrentTrackAction:(id)sender {
@@ -1094,4 +1145,42 @@ - (IBAction)editKeybooardShortcutsAction:(id)sender {
10941145
[self.keyboardShortcutEditorWindowController showWindow:nil];
10951146
}
10961147

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+
10971186
@end

plugins/cocoaui/XIB/MainMenu.xib

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,9 @@ CA
611611
</connections>
612612
</menuItem>
613613
</items>
614+
<connections>
615+
<outlet property="delegate" destination="494" id="6gj-rU-Rf0"/>
616+
</connections>
614617
</menu>
615618
</menuItem>
616619
<menuItem title="Window" id="FtX-jB-U5D">

0 commit comments

Comments
 (0)