Skip to content

Commit 67f7c58

Browse files
committed
GuileHelpers.m(player:alert): Procedure to show NSAlert from Guile.
1 parent ea15ad0 commit 67f7c58

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Spotiqueue/Classes/RBGuileBridge.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import Foundation
10+
import AppKit
1011

1112
func block_on_main<A>(closure: () -> A) -> A {
1213
if Thread.isMainThread {
@@ -169,6 +170,14 @@ public func track_to_scm_record(track: RBSpotifyItem) -> SCM {
169170
}
170171
}
171172

173+
@objc static func alert_popup(title: String, message: String) {
174+
let alert = NSAlert()
175+
alert.messageText = title
176+
alert.informativeText = message
177+
alert.addButton(withTitle: "OK")
178+
alert.runModal()
179+
}
180+
172181
enum KeyMap: String {
173182
case queue = "queue-panel-map"
174183
case search = "search-panel-map"

Spotiqueue/GuileHelpers.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,15 @@ SCM queue_set_tracks(SCM track_list) {
130130
return _scm_true();
131131
}
132132

133+
SCM alert_popup(SCM title, SCM message) {
134+
NSString* objc_title = [[NSString alloc] initWithUTF8String: scm_to_utf8_string(title)];
135+
NSString* objc_message = [[NSString alloc] initWithUTF8String: scm_to_utf8_string(message)];
136+
[RBGuileBridge alert_popupWithTitle:objc_title message:objc_message];
137+
return _scm_true();
138+
}
139+
133140
void register_funcs_objc(void) {
141+
scm_c_define_gsubr("player:alert", 2, 0, 0, &alert_popup);
134142
scm_c_define_gsubr("player:auto-advance", 0, 0, 0, &auto_advance);
135143
scm_c_define_gsubr("player:current-track", 0, 0, 0, &current_track);
136144
scm_c_define_gsubr("player:homedir", 0, 0, 0, &get_homedir);
@@ -143,6 +151,7 @@ void register_funcs_objc(void) {
143151
scm_c_define_gsubr("queue:_set-tracks", 1, 0, 0, &queue_set_tracks);
144152
scm_c_define_gsubr("window:focus-search-box", 0, 0, 0, &focus_search_box);
145153
scm_c_export(
154+
"player:alert",
146155
"player:auto-advance",
147156
"player:current-track",
148157
"player:homedir",

0 commit comments

Comments
 (0)