gui/gst: Completely define the positon and duration labels in glade
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
15da6b4249
commit
71c4e6a1aa
24
gui/gst.cpp
24
gui/gst.cpp
|
@ -18,9 +18,6 @@ static GtkScale *o_seek;
|
||||||
|
|
||||||
static GtkSpinButton *o_count;
|
static GtkSpinButton *o_count;
|
||||||
static GtkToggleButton *o_enabled;
|
static GtkToggleButton *o_enabled;
|
||||||
|
|
||||||
static GtkLabel *o_duration;
|
|
||||||
static GtkLabel *o_position;
|
|
||||||
static GtkAdjustment *o_progress;
|
static GtkAdjustment *o_progress;
|
||||||
|
|
||||||
const gchar *TITLE_FMT = "<span size='xx-large'>%s</span>";
|
const gchar *TITLE_FMT = "<span size='xx-large'>%s</span>";
|
||||||
|
@ -35,18 +32,23 @@ static inline void __audio_set_label(const gchar *label, const gchar *fmt,
|
||||||
g_free(markup);
|
g_free(markup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void __audio_set_time_label(const gchar *label, unsigned int time)
|
||||||
|
{
|
||||||
|
gchar *str = string_sec2str(time);
|
||||||
|
__audio_set_label(label, "%s", str);
|
||||||
|
g_free(str);
|
||||||
|
}
|
||||||
|
|
||||||
static void on_load(struct track *track)
|
static void on_load(struct track *track)
|
||||||
{
|
{
|
||||||
Gtk::ToggleButton *toggle;
|
Gtk::ToggleButton *toggle;
|
||||||
gchar *str;
|
|
||||||
|
|
||||||
__audio_set_label("o_title", TITLE_FMT, 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_artist", ARTIST_FMT, track->tr_artist->ar_name);
|
||||||
__audio_set_label("o_album", ALBUM_FMT, track->tr_album->al_name);
|
__audio_set_label("o_album", ALBUM_FMT, track->tr_album->al_name);
|
||||||
|
|
||||||
str = string_sec2str(track->tr_length);
|
__audio_set_time_label("o_position", 0);
|
||||||
gtk_label_set_text(o_duration, str);
|
__audio_set_time_label("o_duration", track->tr_length);
|
||||||
g_free(str);
|
|
||||||
|
|
||||||
toggle = Glib :: wrap(GTK_TOGGLE_BUTTON(gui_builder_widget("o_ban")), false);
|
toggle = Glib :: wrap(GTK_TOGGLE_BUTTON(gui_builder_widget("o_ban")), false);
|
||||||
toggle->set_active(playlist_has(PL_HIDDEN, track));
|
toggle->set_active(playlist_has(PL_HIDDEN, track));
|
||||||
|
@ -106,12 +108,9 @@ static void on_pause_enabled()
|
||||||
|
|
||||||
static bool on_timeout()
|
static bool on_timeout()
|
||||||
{
|
{
|
||||||
gchar *pos = string_sec2str(audio_position() / GST_SECOND);
|
|
||||||
|
|
||||||
gtk_adjustment_set_upper(o_progress, audio_duration());
|
gtk_adjustment_set_upper(o_progress, audio_duration());
|
||||||
gtk_adjustment_set_value(o_progress, audio_position());
|
gtk_adjustment_set_value(o_progress, audio_position());
|
||||||
gtk_label_set_text(o_position, pos);
|
__audio_set_time_label("o_position", audio_position() / GST_SECOND);
|
||||||
g_free(pos);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,9 +128,6 @@ void gst :: init_pre()
|
||||||
|
|
||||||
o_count = GTK_SPIN_BUTTON(gui_builder_widget("o_pause_count"));
|
o_count = GTK_SPIN_BUTTON(gui_builder_widget("o_pause_count"));
|
||||||
o_enabled = GTK_TOGGLE_BUTTON(gui_builder_widget("o_pause_enabled"));
|
o_enabled = GTK_TOGGLE_BUTTON(gui_builder_widget("o_pause_enabled"));
|
||||||
|
|
||||||
o_duration = GTK_LABEL(gui_builder_widget("o_duration"));
|
|
||||||
o_position = GTK_LABEL(gui_builder_widget("o_position"));
|
|
||||||
o_progress = GTK_ADJUSTMENT(gui_builder_object("o_progress"));
|
o_progress = GTK_ADJUSTMENT(gui_builder_object("o_progress"));
|
||||||
|
|
||||||
g_signal_connect(o_seek, "change-value", G_CALLBACK(on_seek), NULL);
|
g_signal_connect(o_seek, "change-value", G_CALLBACK(on_seek), NULL);
|
||||||
|
|
Loading…
Reference in New Issue