-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclaytracks.clay
601 lines (480 loc) · 20.2 KB
/
claytracks.clay
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
import data.algorithms.(
join,
split);
import data.algorithms.strings.(trim);
import data.sequences.(map);
import data.strings.(String);
import data.vectors.(Vector);
import http.(
GetRequest,
parseResponse,
parseUrl,
sendRequest);
import io.files.(
File,
READ,
stderr);
import io.streams.(readLine);
import printer.(printlnTo, println);
import gstreamer.*;
import glib.*;
import gio.*;
import gobject.*;
import gtk.*;
import gtk.keysyms.*;
import gdkpixbuf.*;
import api;
import parallel.*;
import io.filesystem.utils.*;
private var nothingPlayingText = cstring("Nothing playing currently");
private var playButtonText = cstring("Play");
private var pauseButtonText = cstring("Pause");
private var apiKeyFile = "api-key.txt";
private var iconFile = "8tracks-icon.jpg";
private alias LIST_PAGE = 0;
private alias PLAY_PAGE = 1;
// The size of the mix images in the mixes list
private alias LIST_IMAGE_SIZE = 133;
record ListUI (
// The `Player` pointer is used in some callbacks
currentMixList: Vector[Tuple[Pointer[Player], api.Mix]],
mixListBox: Pointer[GtkBox],
scrolledWindow: Pointer[GtkScrolledWindow],
nextButton: Pointer[GtkButton],
prevButton: Pointer[GtkButton],
);
record PlayUI (
currentTrackLabel: Pointer[GtkLabel],
playPauseButton: Pointer[GtkButton],
skipButton: Pointer[GtkButton],
imageWidget: Pointer[GtkImage],
);
record Player (
apiKey: String,
playtoken: String,
currentTrack: Maybe[api.Track],
currentMix: Maybe[api.Mix],
currentlyPlaying?: Bool,
mixSearchParameters: api.MixSearchParameters,
currentClockId: Maybe[GstClockID],
songReporterRegistered?: Bool,
songReported?: Bool,
playbin: Pointer[GstElement],
notebook: Pointer[GtkNotebook],
listUI: ListUI,
playUI: PlayUI,
);
overload destroy(this: Player) {
maybe(this.currentClockId, id -> {
gst_clock_id_unschedule(id);
this.currentClockId = nothing(GstClockID);
});
gst_element_set_state(this.playbin, GST_STATE_NULL);
gst_object_unref(gpointer(this.playbin));
this.playbin = null(GstElement);
}
private initPlayer(ref player) {
player.playbin = gst_element_factory_make(cstring("playbin2"), cstring("play"));
var bus = gst_element_get_bus(player.playbin);
gst_bus_add_watch(bus, GstBusFunc(watchBus), gpointer(@player));
gst_object_unref(gpointer(bus));
player.apiKey = readApiKey(apiKeyFile);
player.playtoken = api.getPlaytoken(player.apiKey);
}
private readApiKey(file) {
var f = File(file, READ);
var s = readLine(f);
return move(trim(s));
}
private nextTrack(player: Player) {
var mix = require(player.currentMix);
var maybeTrack = api.getNextTrack(player.apiKey, player.playtoken, mix);
changeTrack(player, maybeTrack);
}
private playMix(player: Player, mix: api.Mix) {
player.currentMix = Maybe(mix);
var maybeTrack = api.getTrack(player.apiKey, player.playtoken, mix);
changeTrack(player, maybeTrack);
gtk_notebook_set_current_page(player.notebook, PLAY_PAGE);
var image = getImageFromUrlString(mix.sq250CoverUrl);
if (null?(image)) {
gtk_image_set_from_stock(player.playUI.imageWidget,
cstring("gtk-missing-image"), GTK_ICON_SIZE_DIALOG);
} else {
gtk_image_set_from_pixbuf(player.playUI.imageWidget, image);
g_object_unref(image);
}
}
private skipTrack(player: Player) {
var mix = require(player.currentMix);
// TODO is skipping allowed?
var maybeTrack = api.skipTrack(player.apiKey, player.playtoken, mix);
// TODO show indication if skipping fails
changeTrack(player, maybeTrack);
}
[S when String?(S)]
private parseTags(s: S) {
var tagFragments = split(s, ',');
return move(map(trim, tagFragments));
}
private external watchBus(bus: Pointer[GstBus], message: Pointer[GstMessage], data: gpointer) : gboolean {
ref player = Pointer[Player](data)^;
var msgType = message^.type;
switch (msgType)
case (GST_MESSAGE_STATE_CHANGED) {
var oldState = GstState(0);
var newState = GstState(0);
var pendingState = GstState(0);
gst_message_parse_state_changed(message, @oldState, @newState, @pendingState);
//var newStateName = gst_element_state_get_name(newState);
//println("Changed state to ", CStringRef(newStateName));
if (newState == GST_STATE_PLAYING and not player.songReporterRegistered?) {
registerSongReporter(player);
}
}
case (GST_MESSAGE_ERROR) {
var err = null(GError);
var debugInfo = null(gchar);
gst_message_parse_error(message, @err, @debugInfo);
println("Error: ", String(err^.message));
println("debug info: ", String(debugInfo));
g_error_free(err);
g_free(gpointer(debugInfo));
player.currentlyPlaying? = false;
}
case (GST_MESSAGE_EOS) {
nextTrack(player);
}
else {
//println(String(gst_message_type_get_name(msgType)));
}
return TRUE;
}
private external destroying(widget: Pointer[GtkWidget], data: gpointer) {
gtk_main_quit();
}
private external clickedPlay(button: Pointer[GtkButton], data: gpointer) {
ref mixTuple = Pointer[Tuple[Pointer[Player], api.Mix]](data)^;
playMix(mixTuple.0^, mixTuple.1);
}
private external clickedPlayPause(button: Pointer[GtkButton], data: gpointer) {
ref player = Pointer[Player](data)^;
togglePlaying(player);
}
private external clickedSkip(button: Pointer[GtkButton], data: gpointer) {
ref player = Pointer[Player](data)^;
if (player.currentlyPlaying?) {
// Pause current track
gst_element_set_state(player.playbin, GST_STATE_PAUSED);
player.currentlyPlaying? = false;
}
skipTrack(player);
}
private external destroyWidget(widget: Pointer[GtkWidget], data: gpointer) {
gtk_widget_destroy(widget);
}
private external tagEntryKeyPressed(entry: Pointer[GtkEntry], event: Pointer[GdkEvent],
data: gpointer): gboolean {
ref player = Pointer[Player](data)^;
var type = event^.0;
assert(type == GDK_KEY_PRESS);
ref keyEvent: GdkEventKey = event^.8;
if (keyEvent.keyval == GDK_KEY_Return) {
var textPtr = gtk_entry_get_text(entry);
var tags = parseTags(CStringRef(textPtr));
player.mixSearchParameters.tagList = move(tags);
player.mixSearchParameters.page = 1;
updateCurrentMixes(player);
return TRUE;
}
return FALSE;
}
private external sortOrderBoxChanged(widget: Pointer[GtkComboBox], data: gpointer) {
ref player = Pointer[Player](data)^;
var active = gtk_combo_box_get_active(widget);
if (active < 0 or active >= EnumMemberCount(api.SortMethod))
return;
var method = intToEnum(api.SortMethod, active);
if (method != player.mixSearchParameters.sortMethod) {
player.mixSearchParameters.sortMethod = method;
player.mixSearchParameters.page = 1;
updateCurrentMixes(player);
}
}
private external clickedReload(button: Pointer[GtkButton], data: gpointer) {
ref player = Pointer[Player](data)^;
updateCurrentMixes(player);
}
private external clickedPreviousPage(button: Pointer[GtkButton], data: gpointer) {
ref player = Pointer[Player](data)^;
if (player.mixSearchParameters.page > 1) {
player.mixSearchParameters.page -: 1;
updateCurrentMixes(player);
}
}
private external clickedNextPage(button: Pointer[GtkButton], data: gpointer) {
ref player = Pointer[Player](data)^;
player.mixSearchParameters.page +: 1;
updateCurrentMixes(player);
}
private external registerPlayingSong(clock: Pointer[GstClock], time: GstClockTime,
id: GstClockID, data: gpointer) : gboolean {
ref player = Pointer[Player](data)^;
println("Reporting track");
api.reportTrack(player.apiKey, require(player.currentMix), require(player.currentTrack));
player.songReported? = true;
gst_clock_id_unref(id);
player.currentClockId = nothing(GstClockID);
// return value is ignored, according to docs
return TRUE;
}
private registerSongReporter(ref player: Player) {
var clock = gst_element_get_clock(player.playbin);
if (null?(clock)) {
printlnTo(stderr, "clock is null");
return;
}
println("Registering Song Reporter");
var baseTime = gst_element_get_base_time(player.playbin);
var clockId = gst_clock_new_single_shot_id(clock, baseTime + GST_SECOND * 30);
gst_clock_id_wait_async(clockId, GstClockCallback(registerPlayingSong), gpointer(@player));
player.currentClockId = Maybe(clockId);
g_object_unref(gpointer(clock));
player.songReporterRegistered? = true;
player.songReported? = false;
}
private changeTrack(player, maybeTrack) {
player.currentTrack = maybeTrack;
maybe(maybeTrack, track -> {
// Stop left-over song reporter
if (player.songReporterRegistered? and not player.songReported?) {
gst_clock_id_unschedule(require(player.currentClockId));
player.currentClockId = nothing(GstClockID);
}
println("Current track: ", track);
gtk_label_set_text(player.playUI.currentTrackLabel,
cstring("'" ++ track.name ++ "' by " ++ track.performer));
gst_element_set_state(player.playbin, GST_STATE_NULL);
g_object_set(gpointer(player.playbin), cstring("uri"), cstring(track.url), 0);
gst_element_set_state(player.playbin, GST_STATE_PLAYING);
player.currentlyPlaying? = true;
player.songReporterRegistered? = false;
player.songReported? = false;
setControlButtonsSensitive(player, true);
}, -> {
println("No current track (end of playlist?)");
gtk_label_set_text(player.playUI.currentTrackLabel, nothingPlayingText);
player.currentlyPlaying? = false;
setControlButtonsSensitive(player, false);
});
}
private togglePlaying(player) {
player.currentlyPlaying? = not player.currentlyPlaying?;
gst_element_set_state(player.playbin,
if (player.currentlyPlaying?) GST_STATE_PLAYING else GST_STATE_PAUSED);
gtk_button_set_label(player.playUI.playPauseButton,
if (player.currentlyPlaying?) pauseButtonText else playButtonText);
}
private getMixImage(mix) {
return move(getImageFromUrlString(mix.sq133CoverUrl));
}
private getImageFromUrlString(urlString) {
var url = require(parseUrl(urlString));
var req = GetRequest();
var sock = sendRequest(req, url);
var resp = parseResponse(sock, req);
var memoryStream = g_memory_input_stream_new_from_data(
gpointer(cstring(resp.body)),
Int64(size(resp.body)), GDestroyNotify(0));
var error = Pointer[GError](0);
var image = gdk_pixbuf_new_from_stream(memoryStream, null(GCancellable), @error);
g_object_unref(memoryStream);
if (not null?(error)) {
println("error creating pixbuf ", String(error^.message));
g_error_free(error);
return null(GdkPixbuf);
} else {
return image;
}
}
private getMixImages(mixes) {
var images = Vector[Pointer[GdkPixbuf]]();
resize(images, size(mixes));
parallelMap(mixes, images, mix -> getMixImage(mix));
return move(images);
}
private addMixToContainer(ref mixTuple, image, container) {
ref mix = mixTuple.1;
var hbox = gtk_hbox_new(FALSE, 5);
gtk_container_add(Pointer[GtkContainer](container), Pointer[GtkWidget](hbox));
/*
var alignment = gtk_alignment_new(0.5f, 0.5f, 0f, 0f);
gtk_box_pack_start(Pointer[GtkBox](hbox), alignment, TRUE, TRUE, 0u);
*/
var labelsBox = gtk_vbox_new(FALSE, 1);
gtk_box_pack_start(Pointer[GtkBox](hbox), labelsBox, TRUE, FALSE, 0u);
var nameLabel = gtk_label_new(cstring(mix.name));
gtk_box_pack_start(Pointer[GtkBox](labelsBox), nameLabel, TRUE, FALSE, 0u);
var tagsString = "Tags: " ++ join(String(", "), mix.tagListCache);
var tagsLabel = gtk_label_new(cstring(tagsString));
gtk_box_pack_end(Pointer[GtkBox](labelsBox), tagsLabel, TRUE, FALSE, 0u);
..for (label in nameLabel, tagsLabel) {
//gtk_container_add(Pointer[GtkContainer](alignment), label);
gtk_widget_set_size_request(label, 300, -1);
gtk_label_set_justify(Pointer[GtkLabel](label), GTK_JUSTIFY_CENTER);
gtk_misc_set_alignment(Pointer[GtkMisc](label), 0.5f, 0.5f);
gtk_label_set_line_wrap(Pointer[GtkLabel](label), TRUE);
}
var imageWidget =
if (null?(image)) gtk_image_new_from_stock(cstring("gtk-missing-image"), GTK_ICON_SIZE_DIALOG)
else gtk_image_new_from_pixbuf(image);
// Set a minimum size. Mixes that don't set an image stand out otherwise
gtk_widget_set_size_request(imageWidget, LIST_IMAGE_SIZE, LIST_IMAGE_SIZE);
gtk_box_pack_end(Pointer[GtkBox](hbox), Pointer[GtkWidget](imageWidget),
FALSE, FALSE, UInt32(0));
var button = gtk_button_new_with_label(playButtonText);
gtk_box_pack_end(Pointer[GtkBox](hbox), Pointer[GtkWidget](button),
FALSE, FALSE, UInt32(0));
gSignalConnect(button, cstring("clicked"),
GCallback(clickedPlay), gpointer(@mixTuple));
}
private updateCurrentMixes(ref player) {
setCurrentMixes(player, api.getMixes(player.apiKey, player.mixSearchParameters));
gtk_widget_set_sensitive(Pointer[GtkWidget](player.listUI.prevButton),
if (player.mixSearchParameters.page == 1) FALSE else TRUE);
scrollUp(player.listUI.scrolledWindow);
}
private setCurrentMixes(ref player, mixes) {
// Remove old mixes
gtk_container_foreach(Pointer[GtkContainer](player.listUI.mixListBox),
GtkCallback(destroyWidget), gpointer(0));
ref mixList = player.listUI.currentMixList;
clear(mixList);
var images = getMixImages(mixes);
for (i in range(size(mixes))) {
push(mixList, [@player, mixes[i]]);
addMixToContainer(mixList[i], images[i], player.listUI.mixListBox);
if (not null?(images[i])) {
g_object_unref(images[i]);
}
}
gtk_widget_show_all(Pointer[GtkWidget](player.listUI.mixListBox));
}
private setControlButtonsSensitive(player, sensitive?) {
..for (button in player.playUI.playPauseButton, player.playUI.skipButton) {
gtk_widget_set_sensitive(Pointer[GtkWidget](button), if (sensitive?) TRUE else FALSE);
}
}
private scrollUp(scrolledWindow) {
var adjustment = gtk_scrolled_window_get_vadjustment(scrolledWindow);
gtk_adjustment_set_value(adjustment, gtk_adjustment_get_lower(adjustment));
gtk_scrolled_window_set_vadjustment(scrolledWindow, adjustment);
}
private runApplication() {
// Has to be destroyed before GST is uninitialized
var player = Player();
initPlayer(player);
var window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(Pointer[GtkWindow](window), cstring("Cl8tracks"));
gtk_window_set_default_size(Pointer[GtkWindow](window), 500, 600);
gSignalConnect(window, cstring("destroy"),
GCallback(destroying), gpointer(0));
var errorPtr = null(GError);
gtk_window_set_default_icon_from_file(cstring(iconFile), @errorPtr);
if (not null?(errorPtr)) {
println("Error loading icon from file '", iconFile ,"', error was: ",
errorPtr^.message);
}
player.notebook = Pointer[GtkNotebook](gtk_notebook_new());
gtk_container_add(Pointer[GtkContainer](window), Pointer[GtkWidget](player.notebook));
// List page
var listBox = gtk_vbox_new(FALSE, 5);
var listLabel = gtk_label_new(cstring("List"));
gtk_notebook_append_page(player.notebook, Pointer[GtkWidget](listBox), listLabel);
player.listUI.scrolledWindow = Pointer[GtkScrolledWindow](
gtk_scrolled_window_new(null(GtkAdjustment), null(GtkAdjustment)));
gtk_scrolled_window_set_policy(player.listUI.scrolledWindow, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start_defaults(Pointer[GtkBox](listBox), Pointer[GtkWidget](player.listUI.scrolledWindow));
player.listUI.mixListBox = Pointer[GtkBox](gtk_vbox_new(FALSE, 5));
gtk_scrolled_window_add_with_viewport(
Pointer[GtkScrolledWindow](player.listUI.scrolledWindow),
Pointer[GtkWidget](player.listUI.mixListBox));
var searchBox = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(Pointer[GtkBox](listBox), Pointer[GtkWidget](searchBox),
FALSE, FALSE, 0u);
var tagsLabel = gtk_label_new(cstring("Tags"));
gtk_box_pack_start(Pointer[GtkBox](searchBox), Pointer[GtkWidget](tagsLabel),
FALSE, FALSE, 0u);
var tagEntry = Pointer[GtkEntry](gtk_entry_new());
gSignalConnect(tagEntry, cstring("key-press-event"),
GCallback(tagEntryKeyPressed), gpointer(@player));
gtk_box_pack_start(Pointer[GtkBox](searchBox), Pointer[GtkWidget](tagEntry),
TRUE, TRUE, 0u);
var sortOrderBox = Pointer[GtkComboBoxText](gtk_combo_box_text_new());
..for (i in staticIntegers(#EnumMemberCount(api.SortMethod))) {
var name = EnumMemberName(api.SortMethod, i);
gtk_combo_box_text_append_text(sortOrderBox, cstring(name));
}
gtk_combo_box_set_active(Pointer[GtkComboBox](sortOrderBox), 0);
gSignalConnect(sortOrderBox, cstring("changed"),
GCallback(sortOrderBoxChanged), gpointer(@player));
gtk_box_pack_start(Pointer[GtkBox](searchBox), Pointer[GtkWidget](sortOrderBox),
FALSE, FALSE, 0u);
var pageBox = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(Pointer[GtkBox](listBox), Pointer[GtkWidget](pageBox),
FALSE, FALSE, 0u);
var previousPageButton = Pointer[GtkButton](gtk_button_new_with_label(cstring("Previous Page")));
gtk_box_pack_start(Pointer[GtkBox](pageBox), Pointer[GtkWidget](previousPageButton),
FALSE, FALSE, 0u);
gSignalConnect(previousPageButton, cstring("clicked"),
GCallback(clickedPreviousPage), gpointer(@player));
player.listUI.prevButton = previousPageButton;
var reloadButton = gtk_button_new_with_label(cstring("Reload List"));
gtk_box_pack_start(Pointer[GtkBox](pageBox), Pointer[GtkWidget](reloadButton),
TRUE, FALSE, 0u);
gSignalConnect(reloadButton, cstring("clicked"),
GCallback(clickedReload), gpointer(@player));
var nextPageButton = Pointer[GtkButton](gtk_button_new_with_label(cstring("Next Page")));
gtk_box_pack_end(Pointer[GtkBox](pageBox), Pointer[GtkWidget](nextPageButton),
FALSE, FALSE, 0u);
gSignalConnect(nextPageButton, cstring("clicked"),
GCallback(clickedNextPage), gpointer(@player));
player.listUI.nextButton = nextPageButton;
// Player control page
var playBox = gtk_vbox_new(FALSE, 5);
var playLabel = gtk_label_new(cstring("Playing"));
gtk_notebook_append_page(player.notebook, Pointer[GtkWidget](playBox), playLabel);
player.playUI.imageWidget = Pointer[GtkImage](gtk_image_new_from_stock(
cstring("gtk-missing-image"), GTK_ICON_SIZE_DIALOG));
gtk_box_pack_start(Pointer[GtkBox](playBox), Pointer[GtkWidget](player.playUI.imageWidget),
FALSE, FALSE, 0u);
var controlButtonBox = gtk_hbutton_box_new();
gtk_button_box_set_layout(Pointer[GtkButtonBox](controlButtonBox), GTK_BUTTONBOX_CENTER);
gtk_box_pack_start(Pointer[GtkBox](playBox), Pointer[GtkWidget](controlButtonBox),
FALSE, FALSE, 0u);
player.playUI.playPauseButton = Pointer[GtkButton](gtk_button_new_with_label(pauseButtonText));
gtk_container_add(Pointer[GtkContainer](controlButtonBox),
Pointer[GtkWidget](player.playUI.playPauseButton));
gSignalConnect(player.playUI.playPauseButton, cstring("clicked"),
GCallback(clickedPlayPause), gpointer(@player));
player.playUI.skipButton = Pointer[GtkButton](gtk_button_new_with_label(cstring("Skip")));
gtk_container_add(Pointer[GtkContainer](controlButtonBox),
Pointer[GtkWidget](player.playUI.skipButton));
gSignalConnect(player.playUI.skipButton, cstring("clicked"),
GCallback(clickedSkip), gpointer(@player));
setControlButtonsSensitive(player, false);
player.playUI.currentTrackLabel = Pointer[GtkLabel](gtk_label_new(nothingPlayingText));
gtk_box_pack_start(Pointer[GtkBox](playBox), Pointer[GtkWidget](player.playUI.currentTrackLabel),
FALSE, FALSE, 0u);
gtk_widget_show_all(Pointer[GtkWidget](window));
updateCurrentMixes(player);
gtk_main();
}
main(argc, argv) {
// Fire up the toolkits!
gst_init(@argc, @argv);
gtk_init(@argc, @argv);
runApplication();
// cleanup
gst_deinit();
}