+/* Playing widget for mini-mode */
+
+static void queue_set_playing_widget(const char attribute((unused)) *event,
+ void attribute((unused)) *eventdata,
+ void *callbackdata) {
+ GtkLabel *w = callbackdata;
+
+ if(playing_track) {
+ const char *artist = namepart(playing_track->track, "display", "artist");
+ const char *album = namepart(playing_track->track, "display", "album");
+ const char *title = namepart(playing_track->track, "display", "title");
+ const char *ldata = column_length(playing_track, NULL);
+ if(!ldata)
+ ldata = "";
+ char *text;
+ byte_xasprintf(&text, "%s/%s/%s %s", artist, album, title, ldata);
+ gtk_label_set_text(w, text);
+ } else
+ gtk_label_set_text(w, "");
+}
+
+GtkWidget *playing_widget(void) {
+ GtkWidget *w = gtk_label_new("");
+ gtk_misc_set_alignment(GTK_MISC(w), 1.0, 0);
+ /* Spot changes to the playing track */
+ event_register("playing-track-changed",
+ queue_set_playing_widget,
+ w);
+ /* Use the best-known name for it */
+ event_register("lookups-complete",
+ queue_set_playing_widget,
+ w);
+ /* Keep the amount played so far up to date */
+ event_register("periodic-fast",
+ queue_set_playing_widget,
+ w);
+ return frame_widget(w, NULL);
+}
+