#include <ardour/recent_sessions.h>
#include <ardour/session.h>
+#include <ardour/template_utils.h>
#include <gtkmm/entry.h>
#include <gtkmm/filechooserbutton.h>
#include <gtkmm2ext/window_title.h>
using namespace Gtkmm2ext;
+using namespace ARDOUR;
+using namespace PBD;
#include "opts.h"
m_treeview->set_headers_visible (false);
m_treeview->get_selection()->set_mode (Gtk::SELECTION_SINGLE);
- std::string path = ARDOUR::get_user_ardour_path();
-
- if (path.empty()) {
- path = ARDOUR::get_system_data_path();
+ if (is_directory (user_template_directory ()))
+ {
+ m_template->set_current_folder (user_template_directory().to_string());
}
-
- const char * const template_dir_name = X_("templates");
-
- if (!path.empty()) {
- string user_template_path = path + template_dir_name;
-
- if (Glib::file_test(user_template_path, Glib::FILE_TEST_IS_DIR))
- {
- m_template->set_current_folder (user_template_path);
- }
+ else if (is_directory (system_template_directory ()))
+ {
+ m_template->set_current_folder (system_template_directory().to_string());
}
- const std::string sys_templates_dir = ARDOUR::get_system_data_path() + template_dir_name;
-
- if (Glib::file_test(sys_templates_dir, Glib::FILE_TEST_IS_DIR))
+ if (is_directory (system_template_directory ()))
{
- m_template->add_shortcut_folder(sys_templates_dir);
+ m_template->add_shortcut_folder (system_template_directory().to_string());
}
m_template->set_title(_("select template"));
m_folder->set_current_folder(getenv ("HOME"));
m_folder->set_title(_("select directory"));
- on_new_session_page = true;
m_notebook->set_current_page(0);
m_notebook->show();
m_notebook->show_all_children();
}
*/
- if (m_notebook->get_current_page() == 0) {
+ if (on_new_session_page ()) {
return Glib::filename_from_utf8(m_name->get_text());
} else {
if (m_treeview->get_selection()->count_selected_rows() == 0) {
std::string
NewSessionDialog::session_folder() const
{
- if (m_notebook->get_current_page() == 0) {
+ if (on_new_session_page ()) {
return Glib::filename_from_utf8(m_folder->get_current_folder());
} else {
return m_connect_outputs_to_physical->get_active();
}
-int
-NewSessionDialog::get_current_page()
+bool
+NewSessionDialog::on_new_session_page() const
{
- return m_notebook->get_current_page();
+ return (m_notebook->get_current_page() == 0);
}
void
void
NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum)
{
- if (pagenum == 1) {
- on_new_session_page = false;
+ if (!on_new_session_page ()) {
m_okbutton->set_label(_("Open"));
set_response_sensitive (Gtk::RESPONSE_NONE, false);
m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON)));
set_response_sensitive (Gtk::RESPONSE_OK, true);
}
} else {
- on_new_session_page = true;
if (m_name->get_text() != "") {
set_response_sensitive (Gtk::RESPONSE_NONE, true);
}
void
NewSessionDialog::file_chosen ()
{
- if (on_new_session_page) return;
+ if (on_new_session_page ()) return;
m_treeview->get_selection()->unselect_all();