70 lines
1.7 KiB
C++
70 lines
1.7 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 set_title(string new_title)
|
|
{
|
|
string markup = "<span size='xx-large'>" + new_title + "</span>";
|
|
gtk_label_set_markup(GTK_LABEL(title), markup.c_str());
|
|
}
|
|
|
|
static void set_artist(string new_artist)
|
|
{
|
|
string markup = "<span size='x-large'>" + new_artist + "</span>";
|
|
gtk_label_set_markup(GTK_LABEL(artist), markup.c_str());
|
|
}
|
|
|
|
static void set_album(string new_album)
|
|
{
|
|
string markup = "<span size='x-large'>" + new_album + "</span>";
|
|
gtk_label_set_markup(GTK_LABEL(album), markup.c_str());
|
|
}
|
|
|
|
static GtkWidget *align(GtkWidget *label)
|
|
{
|
|
GtkWidget *alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0);
|
|
gtk_container_add(GTK_CONTAINER(alignment), label);
|
|
return alignment;
|
|
}
|
|
|
|
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("");
|
|
|
|
set_title(" ");
|
|
set_artist(" ");
|
|
set_album(" ");
|
|
|
|
box_pack_start(tag_box, align(title), FALSE, FALSE, 0);
|
|
box_pack_start(tag_box, align(artist), FALSE, FALSE, 0);
|
|
box_pack_start(tag_box, align(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;
|
|
}
|
|
|
|
void set_now_playing(Track &track)
|
|
{
|
|
set_title(track.get_title());
|
|
set_artist("by " + track.get_artist());
|
|
set_album("from " + track.get_album());
|
|
}
|