From 5793dc20704e312e4ace137f94d60428210706c8 Mon Sep 17 00:00:00 2001
From: Colin Fletcher <colin.m.fletcher@googlemail.com>
Date: Sun, 14 Jun 2026 17:42:56 +0100
Subject: [PATCH 08/10] start "open session" chooser in parent directory of
 current session

Copied'n'pasted from the code for the new session dialogue page: perhaps
the check for existing session should be factored out, but this at least
works for now.

Fix for #10233
---
 gtk2_ardour/session_dialog.cc | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/gtk2_ardour/session_dialog.cc b/gtk2_ardour/session_dialog.cc
index 564352dea2..28ec4029dc 100644
--- a/gtk2_ardour/session_dialog.cc
+++ b/gtk2_ardour/session_dialog.cc
@@ -576,7 +576,22 @@ SessionDialog::setup_existing_box ()
 	/* Browse button */
 
 	existing_session_chooser.set_size_request (450, 300);
-	existing_session_chooser.set_current_folder(poor_mans_glob (Config->get_default_session_parent_dir()));
+
+	if (ARDOUR_UI::instance()->the_session ()) {
+		// point the existing session file chooser at the parent directory of the current session
+		string session_parent_dir = Glib::path_get_dirname(ARDOUR_UI::instance()->the_session()->path());
+		existing_session_chooser.set_current_folder (session_parent_dir);
+		string default_session_folder = poor_mans_glob (Config->get_default_session_parent_dir());
+		try {
+			/* add_shortcut_folder throws an exception if the folder being added already has a shortcut */
+			existing_session_chooser.add_shortcut_folder (default_session_folder);
+		}
+		catch (Glib::Error & e) {
+			std::cerr << "existing_session_chooser.add_shortcut_folder (" << default_session_folder << ") threw Glib::Error " << e.what() << std::endl;
+		}
+	} else {
+		existing_session_chooser.set_current_folder(poor_mans_glob (Config->get_default_session_parent_dir()));
+	}
 
 	FileFilter session_filter;
 	session_filter.add_pattern (string_compose(X_("*%1"), ARDOUR::statefile_suffix));
-- 
2.47.3

