gui/gst: Completely define title, artist, and album widgets in glade

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-12-24 12:40:01 -05:00
parent aacc1f876a
commit 15da6b4249
1 changed files with 11 additions and 20 deletions

View File

@ -19,36 +19,30 @@ static GtkScale *o_seek;
static GtkSpinButton *o_count;
static GtkToggleButton *o_enabled;
static GtkLabel *o_album;
static GtkLabel *o_artist;
static GtkLabel *o_duration;
static GtkLabel *o_position;
static GtkLabel *o_title;
static GtkAdjustment *o_progress;
const gchar *TITLE_FMT = "<span size='xx-large'>%s</span>";
const gchar *ARTIST_FMT = "<span size='x-large'>By: %s</span>";
const gchar *ALBUM_FMT = "<span size='x-large'>From: %s</span>";
static void set_markup(GtkLabel *label, const std::string &size,
const std::string &text)
static inline void __audio_set_label(const gchar *label, const gchar *fmt,
const gchar *text)
{
gchar *markup = g_markup_printf_escaped("<span size='%s'>%s</span>",
size.c_str(), text.c_str());
gtk_label_set_markup(label, markup);
gchar *markup = g_markup_printf_escaped(fmt, text);
gtk_label_set_markup(GTK_LABEL(gui_builder_widget(label)), markup);
g_free(markup);
}
static void on_load(struct track *track)
{
Gtk::ToggleButton *toggle;
gchar *str;
gchar *str = g_strdup_printf("From: %s", track->tr_album->al_name);
set_markup(o_album, "x-large", str);
g_free(str);
str = g_strdup_printf("By: %s", track->tr_artist->ar_name);
set_markup(o_artist, "x-large", str);
g_free(str);
set_markup(o_title, "xx-large", track->tr_title);
__audio_set_label("o_title", TITLE_FMT, track->tr_title);
__audio_set_label("o_artist", ARTIST_FMT, track->tr_artist->ar_name);
__audio_set_label("o_album", ALBUM_FMT, track->tr_album->al_name);
str = string_sec2str(track->tr_length);
gtk_label_set_text(o_duration, str);
@ -136,11 +130,8 @@ void gst :: init_pre()
o_count = GTK_SPIN_BUTTON(gui_builder_widget("o_pause_count"));
o_enabled = GTK_TOGGLE_BUTTON(gui_builder_widget("o_pause_enabled"));
o_album = GTK_LABEL(gui_builder_widget("o_album"));
o_artist = GTK_LABEL(gui_builder_widget("o_artist"));
o_duration = GTK_LABEL(gui_builder_widget("o_duration"));
o_position = GTK_LABEL(gui_builder_widget("o_position"));
o_title = GTK_LABEL(gui_builder_widget("o_title"));
o_progress = GTK_ADJUSTMENT(gui_builder_object("o_progress"));
g_signal_connect(o_seek, "change-value", G_CALLBACK(on_seek), NULL);