summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorJesse Chappell <jesse@essej.net>2007-04-20 02:46:21 +0000
committerJesse Chappell <jesse@essej.net>2007-04-20 02:46:21 +0000
commitc46cb59f8d4b25b7199c52f0613ddc5b4186b93f (patch)
treeccecb8e405b6312271c4b059a52ce4b5a771fc2a /gtk2_ardour
parenta77dd0ad59c4668301cef5097ebf22f4353b4f79 (diff)
resurrected the periodic safety backup. defaults to 120 second interval between saves. never lose your work again.
git-svn-id: svn://localhost/ardour2/trunk@1732 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/ardour.menus1
-rw-r--r--gtk2_ardour/ardour_ui.cc33
-rw-r--r--gtk2_ardour/ardour_ui.h6
-rw-r--r--gtk2_ardour/ardour_ui_dialogs.cc4
-rw-r--r--gtk2_ardour/ardour_ui_ed.cc1
-rw-r--r--gtk2_ardour/ardour_ui_options.cc10
6 files changed, 53 insertions, 2 deletions
diff --git a/gtk2_ardour/ardour.menus b/gtk2_ardour/ardour.menus
index 9b857b5a52..5529b4de0c 100644
--- a/gtk2_ardour/ardour.menus
+++ b/gtk2_ardour/ardour.menus
@@ -348,6 +348,7 @@
<menuitem action='LatchedRecordEnable'/>
<menuitem action='RegionEquivalentsOverlap'/>
<separator/>
+ <menuitem action='PeriodicSafetyBackups'/>
<menuitem action='VerifyRemoveLastCapture'/>
<menuitem action='StopRecordingOnXrun'/>
<menuitem action='StopTransportAtEndOfSession'/>
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 8fa4f283f8..850f29fe0a 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -428,6 +428,39 @@ ARDOUR_UI::save_ardour_state ()
save_keybindings ();
}
+gint
+ARDOUR_UI::autosave_session ()
+{
+ if (!Config->get_periodic_safety_backups())
+ return 1;
+
+ if (session) {
+ session->maybe_write_autosave();
+ }
+
+ return 1;
+}
+
+void
+ARDOUR_UI::update_autosave ()
+{
+ ENSURE_GUI_THREAD (mem_fun (*this, &ARDOUR_UI::update_autosave));
+
+ if (session->dirty()) {
+ if (_autosave_connection.connected()) {
+ _autosave_connection.disconnect();
+ }
+
+ _autosave_connection = Glib::signal_timeout().connect (mem_fun (*this, &ARDOUR_UI::autosave_session),
+ Config->get_periodic_safety_backup_interval() * 1000);
+
+ } else {
+ if (_autosave_connection.connected()) {
+ _autosave_connection.disconnect();
+ }
+ }
+}
+
void
ARDOUR_UI::startup ()
{
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h
index 3cee38372b..1ebb7407af 100644
--- a/gtk2_ardour/ardour_ui.h
+++ b/gtk2_ardour/ardour_ui.h
@@ -291,6 +291,11 @@ class ARDOUR_UI : public Gtkmm2ext::UI
int ask_about_saving_session (const string & why);
int save_the_session;
+ /* periodic safety backup, to be precise */
+ gint autosave_session();
+ void update_autosave();
+ sigc::connection _autosave_connection;
+
void queue_transport_change ();
void map_transport_state ();
int32_t do_engine_start ();
@@ -668,6 +673,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
void toggle_StopPluginsWithTransport();
void toggle_DoNotRunPluginsWhileRecording();
void toggle_VerifyRemoveLastCapture();
+ void toggle_PeriodicSafetyBackups();
void toggle_StopRecordingOnXrun();
void toggle_StopTransportAtEndOfSession();
void toggle_GainReduceFastTransport();
diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc
index c3b82c74a8..8a50697e85 100644
--- a/gtk2_ardour/ardour_ui_dialogs.cc
+++ b/gtk2_ardour/ardour_ui_dialogs.cc
@@ -126,6 +126,10 @@ ARDOUR_UI::connect_to_session (Session *s)
solo_alert_button.set_active (session->soloing());
+ /* update autochange callback on dirty state changing */
+
+ session->DirtyChanged.connect (mem_fun(*this, &ARDOUR_UI::update_autosave));
+
/* can't be auditioning here */
primary_clock.set_session (s);
diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc
index 7ecbb0d01b..1add49af69 100644
--- a/gtk2_ardour/ardour_ui_ed.cc
+++ b/gtk2_ardour/ardour_ui_ed.cc
@@ -402,6 +402,7 @@ ARDOUR_UI::install_actions ()
ActionManager::register_toggle_action (option_actions, X_("StopPluginsWithTransport"), _("Stop plugins with transport"), mem_fun (*this, &ARDOUR_UI::toggle_StopPluginsWithTransport));
ActionManager::register_toggle_action (option_actions, X_("VerifyRemoveLastCapture"), _("Verify remove last capture"), mem_fun (*this, &ARDOUR_UI::toggle_VerifyRemoveLastCapture));
+ ActionManager::register_toggle_action (option_actions, X_("PeriodicSafetyBackups"), _("Make periodic safety backups"), mem_fun (*this, &ARDOUR_UI::toggle_PeriodicSafetyBackups));
ActionManager::register_toggle_action (option_actions, X_("StopRecordingOnXrun"), _("Stop recording on xrun"), mem_fun (*this, &ARDOUR_UI::toggle_StopRecordingOnXrun));
ActionManager::register_toggle_action (option_actions, X_("StopTransportAtEndOfSession"), _("Stop transport at session end"), mem_fun (*this, &ARDOUR_UI::toggle_StopTransportAtEndOfSession));
ActionManager::register_toggle_action (option_actions, X_("GainReduceFastTransport"), _("-12dB gain reduce ffwd/rewind"), mem_fun (*this, &ARDOUR_UI::toggle_GainReduceFastTransport));
diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc
index 9565c46e40..34431aeafb 100644
--- a/gtk2_ardour/ardour_ui_options.cc
+++ b/gtk2_ardour/ardour_ui_options.cc
@@ -399,6 +399,12 @@ ARDOUR_UI::toggle_VerifyRemoveLastCapture()
}
void
+ARDOUR_UI::toggle_PeriodicSafetyBackups()
+{
+ ActionManager::toggle_config_state ("options", "PeriodicSafetyBackups", &Configuration::set_periodic_safety_backups, &Configuration::get_periodic_safety_backups);
+}
+
+void
ARDOUR_UI::toggle_StopRecordingOnXrun()
{
ActionManager::toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun, &Configuration::get_stop_recording_on_xrun);
@@ -891,6 +897,8 @@ ARDOUR_UI::parameter_changed (const char* parameter_name)
ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
} else if (PARAM_IS ("verify-remove-last-capture")) {
ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
+ } else if (PARAM_IS ("periodic-safety-backups")) {
+ ActionManager::map_some_state ("options", "PeriodicSafetyBackups", &Configuration::get_periodic_safety_backups);
} else if (PARAM_IS ("stop-recording-on-xrun")) {
ActionManager::map_some_state ("options", "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
} else if (PARAM_IS ("stop-at-session-end")) {
@@ -944,8 +952,6 @@ ARDOUR_UI::parameter_changed (const char* parameter_name)
map_meter_hold ();
} else if (PARAM_IS ("meter-falloff")) {
map_meter_falloff ();
- } else if (PARAM_IS ("verify-remove-last-capture")) {
- ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
} else if (PARAM_IS ("video-pullup") || PARAM_IS ("smpte-format")) {
if (session) {
primary_clock.set (session->audible_frame(), true);