From 071ada7487cc503754f8998077af333e4786ec69 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 26 Aug 2010 18:38:44 +0000 Subject: [PATCH] Add listener for the autosave timer Originally committed to SVN as r4765. --- aegisub/src/frame_main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index f50603f0c..525b485c6 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -92,6 +92,8 @@ #define StartupLog(a) #endif +static void autosave_timer_changed(wxTimer &timer, const agi::OptionValue &opt); + FrameMain::FrameMain (wxArrayString args) : wxFrame ((wxFrame*)NULL,-1,_T(""),wxDefaultPosition,wxSize(920,700),wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN) { @@ -179,6 +181,7 @@ FrameMain::FrameMain (wxArrayString args) if (time > 0) { AutoSave.Start(time*1000); } + OPT_GET("App/Auto/Save Every Seconds")->Subscribe(this, std::tr1::bind(autosave_timer_changed, std::tr1::ref(AutoSave), std::tr1::placeholders::_1)); // Set accelerator keys StartupLog(_T("Install hotkeys")); @@ -1346,3 +1349,13 @@ bool FrameMain::HasASSDraw() { return false; #endif } + +static void autosave_timer_changed(wxTimer &timer, const agi::OptionValue &opt) { + int freq = opt.GetInt(); + if (freq <= 0) { + timer.Stop(); + } + else { + timer.Start(freq * 1000); + } +}