gui: Set artist, album, title, and duration from gst code

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-01-14 20:16:01 -05:00
parent 6fec8876a9
commit 300acde068
2 changed files with 21 additions and 17 deletions

View File

@ -20,7 +20,11 @@ static Gtk::Button *o_prev;
static Gtk::Scale *o_seek;
static Gtk::Button *o_stop;
static Gtk::Label *o_position;
static Gtk::Label *o_album;
static Gtk::Label *o_artist;
static Gtk::Label *o_duration;
static Gtk::Label *o_position;
static Gtk::Label *o_title;
static Glib::RefPtr<Gtk::Adjustment> o_progress;
@ -36,6 +40,13 @@ static bool gst_change_state(GstState state)
}
}
static void set_markup(Gtk::Label *label, const std::string &size,
const std::string &text)
{
label->set_markup("<span size='" + size + "'>" +
Glib::Markup::escape_text(text) + "</span>");
}
class GSTDriver : public AudioDriver
{
@ -48,6 +59,11 @@ public:
g_object_set(G_OBJECT(gst_player), "uri", uri, NULL);
g_free(uri);
set_markup(o_album, "x-large", "From: " + track->album()->name());
set_markup(o_artist, "x-large", "By: " + track->artist()->name());
set_markup(o_title, "xx-large", track->name());
o_duration->set_text(track->length_str());
on_track_loaded(track);
}
@ -185,7 +201,11 @@ void init_gst(int *argc, char ***argv)
o_seek = lib :: get_widget<Gtk::Scale>("o_seek");
o_stop = lib :: get_widget<Gtk::Button>("o_stop");
o_album = lib :: get_widget<Gtk::Label>("o_album");
o_artist = lib :: get_widget<Gtk::Label>("o_artist");
o_duration = lib :: get_widget<Gtk::Label>("o_duration");
o_position = lib :: get_widget<Gtk::Label>("o_position");
o_title = lib :: get_widget<Gtk::Label>("o_title");
o_progress = lib :: get_object<Gtk::Adjustment>("o_progress");
o_next->signal_clicked().connect(sigc::ptr_fun(on_next));

View File

@ -31,26 +31,10 @@ static void on_config_pause_count()
enabled->set_active(true);
}
static void set_label_text(Gtk::Label *label, const std::string &size,
const std::string &text)
{
label->set_markup("<span size='" + size + "'>" +
Glib::Markup::escape_text(text) + "</span>");
}
void on_track_loaded(Track *track)
{
Gtk::ToggleButton *ban = lib :: get_widget<Gtk::ToggleButton>("o_ban");
Gtk::ToggleButton *fav = lib :: get_widget<Gtk::ToggleButton>("o_favorite");
Gtk::Label *title = lib :: get_widget<Gtk::Label>("o_title");
Gtk::Label *artist = lib :: get_widget<Gtk::Label>("o_artist");
Gtk::Label *album = lib :: get_widget<Gtk::Label>("o_album");
Gtk::Label *duration = lib :: get_widget<Gtk::Label>("o_duration");
set_label_text(title, "xx-large", track->name());
set_label_text(artist, "x-large", "By: " + track->artist()->name());
set_label_text(album, "x-large", "From: " + track->album()->name());
duration->set_text(track->length_str());
bool banned = playlist :: has(track, "Banned");
bool favorite = playlist :: has(track, "Favorites");