ocarina: Improved label setting function
I created a single function to escape the text and set it in the label. I don't know why I didn't do this from the beginning!
This commit is contained in:
parent
5ae5174536
commit
30246df924
|
@ -8,28 +8,32 @@ static GtkWidget *title = NULL;
|
||||||
static GtkWidget *artist = NULL;
|
static GtkWidget *artist = NULL;
|
||||||
static GtkWidget *album = NULL;
|
static GtkWidget *album = NULL;
|
||||||
|
|
||||||
|
static void set_label(GtkWidget *label, string text, string size)
|
||||||
|
{
|
||||||
|
string escaped = g_markup_escape_text(text.c_str(), -1);
|
||||||
|
string markup = "<span size='" + size + "'>" + escaped + "</span>";
|
||||||
|
gtk_label_set_markup(GTK_LABEL(label), markup.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
static void set_title(string new_title)
|
static void set_title(string new_title)
|
||||||
{
|
{
|
||||||
string markup = "<span size='xx-large'>" + new_title + "</span>";
|
set_label(title, new_title, "xx-large");
|
||||||
gtk_label_set_markup(GTK_LABEL(title), markup.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_artist(string new_artist)
|
static void set_artist(string new_artist)
|
||||||
{
|
{
|
||||||
string markup = "<span size='x-large'>" + new_artist + "</span>";
|
set_label(artist, new_artist, "x-large");
|
||||||
gtk_label_set_markup(GTK_LABEL(artist), markup.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_album(string new_album)
|
static void set_album(string new_album)
|
||||||
{
|
{
|
||||||
string markup = "<span size='x-large'>" + new_album + "</span>";
|
set_label(album, new_album, "x-large");
|
||||||
gtk_label_set_markup(GTK_LABEL(album), markup.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *align(GtkWidget *label)
|
static GtkWidget *align(GtkWidget *label)
|
||||||
{
|
{
|
||||||
GtkWidget *alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0);
|
GtkWidget *alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0);
|
||||||
gtk_container_add(GTK_CONTAINER(alignment), label);
|
container_add(alignment, label);
|
||||||
return alignment;
|
return alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue