49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
|
|
#include <libsaria/track.h>
|
|
#include <ocarina/gtk.h>
|
|
#include "footer.h"
|
|
|
|
static GtkWidget *now_playing = NULL;
|
|
static GtkWidget *title = NULL;
|
|
static GtkWidget *artist = NULL;
|
|
static GtkWidget *album = NULL;
|
|
|
|
static void make_nowplaying()
|
|
{
|
|
GtkWidget *tag_box = gtk_vbox_new(FALSE, 0);
|
|
now_playing = gtk_hbox_new(FALSE, 0);
|
|
|
|
title = gtk_label_new("");
|
|
artist = gtk_label_new("");
|
|
album = gtk_label_new("");
|
|
|
|
box_pack_start(tag_box, title, FALSE, FALSE, 0);
|
|
box_pack_start(tag_box, artist, FALSE, FALSE, 0);
|
|
box_pack_start(tag_box, album, FALSE, FALSE, 0);
|
|
|
|
box_pack_start(now_playing, tag_box, FALSE, FALSE, 0);
|
|
gtk_widget_show_all(now_playing);
|
|
}
|
|
|
|
GtkWidget *get_nowplaying()
|
|
{
|
|
if (now_playing == NULL)
|
|
make_nowplaying();
|
|
return now_playing;
|
|
}
|
|
|
|
static void change_label(GtkWidget *label, string prefix, string text)
|
|
{
|
|
if (text != "")
|
|
gtk_label_set_text(GTK_LABEL(label), (prefix + text).c_str());
|
|
else
|
|
gtk_label_set_text(GTK_LABEL(label), "");
|
|
}
|
|
|
|
void set_footer_track(Track &track)
|
|
{
|
|
change_label(title , "", track.get_title());
|
|
change_label(artist, "by ", track.get_artist());
|
|
change_label(album, "from ", track.get_album());
|
|
}
|