ocarina: Individual functions for setting tag labels
I switched over to using pango <span> tags to set font properties to make the text larger. I decided that the title will be bigger than artist and album, so I can't have one generic function for setting the label properties. Instead, I divided it up into one function for each label.
This commit is contained in:
parent
0db7c0cf6b
commit
90bc64131d
|
@ -8,6 +8,24 @@ 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 void make_nowplaying()
|
||||
{
|
||||
GtkWidget *tag_box = gtk_vbox_new(FALSE, 0);
|
||||
|
@ -17,6 +35,10 @@ static void make_nowplaying()
|
|||
artist = gtk_label_new("");
|
||||
album = gtk_label_new("");
|
||||
|
||||
set_title(" ");
|
||||
set_artist(" ");
|
||||
set_album(" ");
|
||||
|
||||
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);
|
||||
|
@ -32,17 +54,9 @@ GtkWidget *get_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());
|
||||
set_title(track.get_title());
|
||||
set_artist("by " + track.get_artist());
|
||||
set_album("from " + track.get_album());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue