gui: Implement seeking

You can either click + drag the slider or use the keyboard to change the
current position.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-01-24 16:27:00 -05:00 committed by Anna Schumaker
parent 00d5258902
commit 60c35219c2
2 changed files with 12 additions and 3 deletions

View File

@ -20,9 +20,9 @@
</columns>
</object>
<object class="GtkAdjustment" id="o_progress">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
<property name="upper">100000000000</property>
<property name="step_increment">1000000000</property>
<property name="page_increment">10000000000</property>
</object>
<object class="GtkWindow" id="o_window">
<property name="visible">True</property>

View File

@ -54,6 +54,12 @@ static void on_next()
audio :: play();
}
static bool on_seek(Gtk::ScrollType type, double value)
{
audio :: seek_to(value);
return true;
}
static void on_track_loaded(library :: Song &song)
{
Gtk::Label *title, *artist, *album, *duration;
@ -290,6 +296,7 @@ Gtk::Window *connect_wires()
Gtk::TreeView *treeview;
Gtk::SpinButton *count;
Gtk::CheckButton *enabled;
Gtk::Scale *position;
builder = Gtk::Builder::create();
builder->add_from_file("gui/ocarina6.glade");
@ -304,8 +311,10 @@ Gtk::Window *connect_wires()
builder->get_widget("o_pause_count", count);
builder->get_widget("o_pause_enabled", enabled);
builder->get_widget("o_position_scale", position);
count->signal_changed().connect(sigc::ptr_fun(on_config_pause));
enabled->signal_toggled().connect(sigc::ptr_fun(on_config_pause));
position->signal_change_value().connect(sigc::ptr_fun(on_seek));
connect_button("o_play", audio::play);
connect_button("o_pause", audio::pause);