From a9d70383d1544b49b2d48986c6cfbd8646cd793c Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Tue, 4 Sep 2007 05:26:28 +0000 Subject: [PATCH] Use functions from ardour/session_state_utils.h instead of ardour/session.h in ARDOUR_UI::redisplay_recent_sessions git-svn-id: svn://localhost/ardour2/trunk@2388 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 69 +++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 37 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 57804deb8c..d6fc549371 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -805,73 +806,67 @@ ARDOUR_UI::session_menu (GdkEventButton *ev) void ARDOUR_UI::redisplay_recent_sessions () { - vector *sessions; - vector::iterator i; + std::vector session_directories; RecentSessionsSorter cmp; recent_session_display.set_model (Glib::RefPtr(0)); recent_session_model->clear (); - RecentSessions rs; + ARDOUR::RecentSessions rs; ARDOUR::read_recent_sessions (rs); if (rs.empty()) { recent_session_display.set_model (recent_session_model); return; } - - /* sort them alphabetically */ + // + // sort them alphabetically sort (rs.begin(), rs.end(), cmp); - sessions = new vector; - - for (RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) { - sessions->push_back (new string ((*i).second)); + + for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) { + session_directories.push_back ((*i).second); } + + for (vector::const_iterator i = session_directories.begin(); + i != session_directories.end(); ++i) + { + std::vector state_file_paths; + + // now get available states for this session - for (i = sessions->begin(); i != sessions->end(); ++i) { + get_state_files_in_directory (*i, state_file_paths); - vector* states; - vector item; - string fullpath = *(*i); - - /* remove any trailing / */ - - if (fullpath[fullpath.length()-1] == '/') { - fullpath = fullpath.substr (0, fullpath.length()-1); - } - - /* now get available states for this session */ - - if ((states = Session::possible_states (fullpath)) == 0) { - /* no state file? */ + if (state_file_paths.empty()) { + // no state file? continue; } + + std::vector state_file_names(get_file_names_no_extension (state_file_paths)); - TreeModel::Row row = *(recent_session_model->append()); + Gtk::TreeModel::Row row = *(recent_session_model->append()); + const string fullpath = (*i).to_string(); + row[recent_session_columns.visible_name] = Glib::path_get_basename (fullpath); row[recent_session_columns.fullpath] = fullpath; + + if (state_file_names.size() > 1) { - if (states->size() > 1) { + // add the children - /* add the children */ - - for (vector::iterator i2 = states->begin(); i2 != states->end(); ++i2) { - - TreeModel::Row child_row = *(recent_session_model->append (row.children())); + for (std::vector::iterator i2 = state_file_names.begin(); + i2 != state_file_names.end(); ++i2) + { - child_row[recent_session_columns.visible_name] = **i2; + Gtk::TreeModel::Row child_row = *(recent_session_model->append (row.children())); + + child_row[recent_session_columns.visible_name] = *i2; child_row[recent_session_columns.fullpath] = fullpath; - - delete *i2; } } - - delete states; } recent_session_display.set_model (recent_session_model); - delete sessions; } void