Scoop API

scoop:scoop.desktop:0.1.0

src/tasks.scoop

Selected production source · src/tasks.scoop

1package scoop.desktop
3import scoop.window.RequestStatus
5internal fun publishJumpList(owner: DesktopOwner, tasks: Array<JumpListTask>): RequestStatus {
6 @Unsafe
7 {
8 val native = desktopCreated(nativeTasksCreate(owner.pointer!!), "Jump List")
9 try {
10 for (task in tasks) {
11 val icon =
12 when (task.icon) {
13 case Some(val value) -> value.path.toOsString().toUtf16()
14 case None -> []
15 }
16 task.title.withUtf8Bytes {
17 title,
18 titleLength -> @Unsafe
19 {
20 (task.description ?: "").withUtf8Bytes {
21 description,
22 descriptionLength -> @Unsafe
23 {
24 icon.withDataPointer {
25 path,
26 count -> @Unsafe
27 {
28 desktopStatus(
29 nativeTasksAdd(
30 native,
31 title,
32 titleLength,
33 description,
34 descriptionLength,
35 path,
36 count,
37 task.icon?.index ?: 0
38 ),
39 "Jump List task"
40 )
41 }
42 }
43 }
44 }
45 }
46 }
47 for (argument in task.arguments)
48 argument.withUtf8Bytes {
49 text,
50 length -> @Unsafe
51 {
52 desktopStatus(
53 nativeTasksArgument(native, text, length),
54 "Jump List argument"
55 )
56 }
57 }
58 }
59 return desktopStatus(nativeTasksCommit(native), "publish Jump List")
60 } finally {
61 nativeTasksDestroy(native)
62 }
63 }