#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();
m_limit_output_ports->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::limit_outputs_clicked));
m_create_master_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::master_bus_button_clicked));
m_create_control_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::monitor_bus_button_clicked));
- m_name->signal_key_release_event().connect(mem_fun (*this, &NewSessionDialog::entry_key_release));
+ m_name->signal_changed().connect(mem_fun (*this, &NewSessionDialog::on_new_session_name_entry_changed));
m_notebook->signal_switch_page().connect (mem_fun (*this, &NewSessionDialog::notebook_page_changed));
m_treeview->get_selection()->signal_changed().connect (mem_fun (*this, &NewSessionDialog::treeview_selection_changed));
m_treeview->signal_row_activated().connect (mem_fun (*this, &NewSessionDialog::recent_row_activated));
std::string
NewSessionDialog::session_name() const
{
- std::string str = Glib::filename_from_utf8(m_open_filechooser->get_filename());
+ std::string str = Glib::filename_from_utf8(m_open_filechooser->get_filename());
std::string::size_type position = str.find_last_of ('/');
str = str.substr (position+1);
position = str.find_last_of ('.');
}
*/
- 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) {
- return Glib::filename_from_utf8(m_folder->get_current_folder());
+ if (on_new_session_page ()) {
+ return Glib::filename_from_utf8(m_folder->get_current_folder());
} else {
if (m_treeview->get_selection()->count_selected_rows() == 0) {
- return Glib::filename_from_utf8(m_open_filechooser->get_current_folder());
+ return Glib::filename_from_utf8(m_open_filechooser->get_current_folder());
}
Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
return (*i)[recent_columns.fullpath];
bool
NewSessionDialog::use_session_template() const
{
- if(m_template->get_filename().empty() && (m_notebook->get_current_page() == 0)) return false;
+ if(m_template->get_filename().empty() && (m_notebook->get_current_page() == 0)) return false;
return true;
}
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
{
m_name->set_text("");
set_response_sensitive (Gtk::RESPONSE_OK, false);
-
}
-bool
-NewSessionDialog::entry_key_release (GdkEventKey* ev)
+void
+NewSessionDialog::on_new_session_name_entry_changed ()
{
if (m_name->get_text() != "") {
set_response_sensitive (Gtk::RESPONSE_OK, true);
} else {
set_response_sensitive (Gtk::RESPONSE_OK, false);
}
- return true;
}
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();
void
NewSessionDialog::recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col)
{
- response (Gtk::RESPONSE_YES);
+ response (Gtk::RESPONSE_YES);
}
void
NewSessionDialog::connect_inputs_clicked ()
{
- m_limit_input_ports->set_sensitive(m_connect_inputs->get_active());
+ m_limit_input_ports->set_sensitive(m_connect_inputs->get_active());
- if (m_connect_inputs->get_active() && m_limit_input_ports->get_active()) {
- m_input_limit_count->set_sensitive(true);
- } else {
- m_input_limit_count->set_sensitive(false);
- }
+ if (m_connect_inputs->get_active() && m_limit_input_ports->get_active()) {
+ m_input_limit_count->set_sensitive(true);
+ } else {
+ m_input_limit_count->set_sensitive(false);
+ }
}
void
NewSessionDialog::connect_outputs_clicked ()
{
- m_limit_output_ports->set_sensitive(m_connect_outputs->get_active());
+ m_limit_output_ports->set_sensitive(m_connect_outputs->get_active());
- if (m_connect_outputs->get_active() && m_limit_output_ports->get_active()) {
- m_output_limit_count->set_sensitive(true);
- } else {
- m_output_limit_count->set_sensitive(false);
- }
+ if (m_connect_outputs->get_active() && m_limit_output_ports->get_active()) {
+ m_output_limit_count->set_sensitive(true);
+ } else {
+ m_output_limit_count->set_sensitive(false);
+ }
}
void
NewSessionDialog::limit_inputs_clicked ()
{
- m_input_limit_count->set_sensitive(m_limit_input_ports->get_active());
+ m_input_limit_count->set_sensitive(m_limit_input_ports->get_active());
}
void
NewSessionDialog::limit_outputs_clicked ()
{
- m_output_limit_count->set_sensitive(m_limit_output_ports->get_active());
+ m_output_limit_count->set_sensitive(m_limit_output_ports->get_active());
}
void
NewSessionDialog::master_bus_button_clicked ()
{
- m_master_bus_channel_count->set_sensitive(m_create_master_bus->get_active());
+ m_master_bus_channel_count->set_sensitive(m_create_master_bus->get_active());
}
void
NewSessionDialog::monitor_bus_button_clicked ()
{
- m_control_bus_channel_count->set_sensitive(m_create_control_bus->get_active());
+ m_control_bus_channel_count->set_sensitive(m_create_control_bus->get_active());
}
void
NewSessionDialog::reset_template()
{
- m_template->set_filename("");
+ m_template->set_filename("");
}
void
/* remove any trailing / */
if (fullpath[fullpath.length()-1] == '/') {
- fullpath = fullpath.substr (0, fullpath.length()-1);
+ fullpath = fullpath.substr (0, fullpath.length()-1);
}
/* now get available states for this session */
if ((states = ARDOUR::Session::possible_states (fullpath)) == 0) {
- /* no state file? */
- continue;
+ /* no state file? */
+ continue;
}
Gtk::TreeModel::Row row = *(recent_model->append());
row[recent_columns.fullpath] = fullpath;
if (states->size()) {
-
- /* add the children */
-
- for (std::vector<std::string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
- Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
-
+ /* add the children */
+
+ for (std::vector<std::string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
+
+ Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
+
child_row[recent_columns.visible_name] = **i2;
child_row[recent_columns.fullpath] = fullpath;
-
+
delete *i2;
}
}