Skip to content

Commit 4f98964

Browse files
committed
Introduce <playlist> record, plus some plumbing.
1 parent a49ebc1 commit 4f98964

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

Spotiqueue/Classes/RBGuileBridge.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public func track_to_scm_record(track: RBSpotifyItem) -> SCM {
4646
scm_from_int32(Int32(track.durationSeconds))) // duration in seconds
4747
}
4848

49+
@_cdecl("playlist_to_scm_record")
50+
public func playlist_to_scm_record(track: RBSpotifyItem) -> SCM {
51+
// Same caveats apply as with `track_to_scm_record`.
52+
scm_call_2(scm_c_public_ref("spotiqueue records", "make-playlist"),
53+
scm_from_utf8_string(track.spotify_uri), // uri
54+
scm_from_utf8_string(track.title)) // title
55+
}
56+
4957
@objc class RBGuileBridge: NSObject {
5058
private static func call_hook(hook_name: String, args_list: SCM) {
5159
assert(Thread.isMainThread)

Spotiqueue/GuileHelpers.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ SCM get_tracks_from(NSArray* realTracks) {
9090
SCM_UNDEFINED);
9191
int32_t pos = 0;
9292
for (RBSpotifyItem* t in realTracks) {
93-
scm_list_set_x(tracks, scm_from_int32(pos), track_to_scm_record(t));
93+
if ([t itemType] == ItemTypePlaylist) {
94+
scm_list_set_x(tracks, scm_from_int32(pos), playlist_to_scm_record(t));
95+
} else {
96+
scm_list_set_x(tracks, scm_from_int32(pos), track_to_scm_record(t));
97+
}
9498
pos++;
9599
}
96100

guile/spotiqueue/base.scm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373

7474
(define (just-the-uri-please item)
7575
(cond ((track? item) (track-uri item))
76+
((playlist? item) (playlist-uri item))
7677
((string? item) item)
7778
(else #nil)))
7879

guile/spotiqueue/records.scm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,19 @@
3232
(define (track-album track) (_track-album track))
3333
(define (track-duration track) (_track-duration track))
3434

35+
;; A fledgling record type for playlists, so that we can support retrieving the contents of the
36+
;; search pane, too.
37+
(define-record-type <playlist>
38+
(_make-playlist uri title)
39+
_playlist?
40+
(uri _playlist-uri)
41+
(title _playlist-title))
42+
43+
(define (make-playlist uri title)
44+
(_make-playlist uri title))
45+
46+
(define (playlist? playlist) (_playlist? playlist))
47+
(define (playlist-uri playlist) (_playlist-uri playlist))
48+
(define (playlist-title playlist) (_playlist-title playlist))
49+
3550
;;; END records.scm

0 commit comments

Comments
 (0)