diff --git a/gui/controls.cpp b/gui/controls.cpp index 9c12c463..266a98a1 100644 --- a/gui/controls.cpp +++ b/gui/controls.cpp @@ -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() diff --git a/include/lib/lib.h b/include/lib/lib.h index e9a3e244..64e6321f 100644 --- a/include/lib/lib.h +++ b/include/lib/lib.h @@ -14,6 +14,7 @@ namespace lib const std::string share_file(const std::string &); Glib::RefPtr &get_builder(); const std::string key_name(GdkEventKey *); + void schedule(bool (*)(), unsigned int); template static inline T *get_widget(const std::string &name) diff --git a/lib/lib.cpp b/lib/lib.cpp index 2631acfa..c0a0e06f 100644 --- a/lib/lib.cpp +++ b/lib/lib.cpp @@ -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); +}