From 34c05a7903e87a2b5d83d36b8af783499d3ce682 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 18 Jul 2011 17:08:50 +0000 Subject: when renaming, remove old session and add new session name from/to recent sessions list git-svn-id: svn://localhost/ardour2/branches/3.0@9894 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/recent_sessions.h | 1 + libs/ardour/recent_sessions.cc | 25 +++++++++++++++++++++++++ libs/ardour/session_state.cc | 10 ++++++++++ 3 files changed, 36 insertions(+) diff --git a/libs/ardour/ardour/recent_sessions.h b/libs/ardour/ardour/recent_sessions.h index e6d2f83bcc..2951496849 100644 --- a/libs/ardour/ardour/recent_sessions.h +++ b/libs/ardour/ardour/recent_sessions.h @@ -30,6 +30,7 @@ namespace ARDOUR { int read_recent_sessions (RecentSessions& rs); int store_recent_sessions (std::string name, std::string path); int write_recent_sessions (RecentSessions& rs); + int remove_recent_sessions (const std::string& path); }; // namespace ARDOUR #endif // __ardour_recent_sessions_h__ diff --git a/libs/ardour/recent_sessions.cc b/libs/ardour/recent_sessions.cc index dfe85190b3..adc25294fb 100644 --- a/libs/ardour/recent_sessions.cc +++ b/libs/ardour/recent_sessions.cc @@ -137,3 +137,28 @@ ARDOUR::store_recent_sessions (string name, string path) return ARDOUR::write_recent_sessions (rs); } +int +ARDOUR::remove_recent_sessions (const string& path) +{ + RecentSessions rs; + bool write = false; + + if (ARDOUR::read_recent_sessions (rs) < 0) { + return -1; + } + + for (RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) { + if (i->second == path) { + rs.erase (i); + write = true; + break; + } + } + + if (write) { + return ARDOUR::write_recent_sessions (rs); + } else { + return 1; + } +} + diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 0973e294c5..1b8c7c0ba0 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -100,6 +100,7 @@ #include "ardour/processor.h" #include "ardour/port.h" #include "ardour/proxy_controllable.h" +#include "ardour/recent_sessions.h" #include "ardour/region_factory.h" #include "ardour/route_group.h" #include "ardour/send.h" @@ -3787,6 +3788,10 @@ Session::rename (const std::string& new_name) } } + /* remove old name from recent sessions */ + + remove_recent_sessions (_path); + _path = newpath; _current_snapshot_name = new_name; _name = new_name; @@ -3797,6 +3802,11 @@ Session::rename (const std::string& new_name) save_state (_current_snapshot_name); + + /* add to recent sessions */ + + store_recent_sessions (new_name, _path); + return 0; #undef RENAME -- cgit v1.2.3