lib: Create a schedule() function
This lets me clean up some of the code in controls.cpp Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
1c437c4957
commit
df0d1496de
|
@ -43,17 +43,12 @@ static bool on_timeout()
|
|||
return audio_playing();
|
||||
}
|
||||
|
||||
static void enable_timeout()
|
||||
{
|
||||
Glib::signal_timeout().connect(sigc::ptr_fun(on_timeout), 500);
|
||||
}
|
||||
|
||||
|
||||
static void o_play()
|
||||
{
|
||||
audio :: play();
|
||||
o_fix_buttons();
|
||||
enable_timeout();
|
||||
lib :: schedule(on_timeout, 500);
|
||||
}
|
||||
|
||||
static void o_pause()
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace lib
|
|||
const std::string share_file(const std::string &);
|
||||
Glib::RefPtr<Gtk::Builder> &get_builder();
|
||||
const std::string key_name(GdkEventKey *);
|
||||
void schedule(bool (*)(), unsigned int);
|
||||
|
||||
template <class T>
|
||||
static inline T *get_widget(const std::string &name)
|
||||
|
|
|
@ -42,3 +42,8 @@ const std::string lib :: key_name(GdkEventKey *event)
|
|||
std::string key = gdk_keyval_name(event->keyval);
|
||||
return key;
|
||||
}
|
||||
|
||||
void lib :: schedule(bool (*func)(), unsigned int milliseconds)
|
||||
{
|
||||
Glib :: signal_timeout().connect(sigc::ptr_fun(func), milliseconds);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue