#include <glibmm/datetime.h>
#include <gtkmm/filechooser.h>
+#include <gtkmm/stock.h>
#include "pbd/basename.h"
#include "pbd/failed_constructor.h"
#include "gtkmm2ext/utils.h"
#include "gtkmm2ext/keyboard.h"
+#include "widgets/tooltips.h"
+
#include "ardour/audioengine.h"
#include "ardour/filesystem_paths.h"
+#include "ardour/luascripting.h"
#include "ardour/recent_sessions.h"
#include "ardour/session.h"
#include "ardour/session_state_utils.h"
#include "opts.h"
#include "engine_dialog.h"
#include "pbd/i18n.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "utils.h"
using namespace Glib;
using namespace PBD;
using namespace ARDOUR;
+using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
SessionDialog::SessionDialog (bool require_new, const std::string& session_name, const std::string& session_path, const std::string& template_name, bool cancel_not_quit)
}
if (!template_name.empty()) {
- use_template_button.set_active (false);
load_template_override = template_name;
}
populate_session_templates ();
- if (!template_model->children().empty()) {
- use_template_button.show();
- template_chooser.show ();
- } else {
- use_template_button.hide();
- template_chooser.hide ();
- }
-
if (recent_session_model) {
int cnt = redisplay_recent_sessions ();
if (cnt > 0) {
return true;
}
- if (use_template_button.get_active()) {
+ if (template_chooser.get_selection()->count_selected_rows() > 0) {
return true;
}
return Glib::build_filename (the_path, load_template_override + ARDOUR::template_suffix);
}
- if (use_template_button.get_active()) {
- TreeModel::iterator iter = template_chooser.get_active ();
- TreeModel::Row row = (*iter);
- string s = row[session_template_columns.path];
- return s;
+ if (template_chooser.get_selection()->count_selected_rows() > 0) {
+ TreeIter iter = template_chooser.get_selection()->get_selected();
+
+ if (iter) {
+ string s = (*iter)[session_template_columns.path];
+ return s;
+ }
}
return string();
{
vector<TemplateInfo> templates;
- find_session_templates (templates);
+ find_session_templates (templates, true);
template_model->clear ();
+ //Add any Lua scripts (factory templates) found in the scripts folder
+ LuaScriptList& ms (LuaScripting::instance ().scripts (LuaScriptInfo::SessionSetup));
+ for (LuaScriptList::const_iterator s = ms.begin(); s != ms.end(); ++s) {
+ TreeModel::Row row;
+ row = *(template_model->append ());
+ row[session_template_columns.name] = "Meta: " + (*s)->name;
+ row[session_template_columns.path] = "urn:ardour:" + (*s)->path;
+ row[session_template_columns.description] = (*s)->description;
+ row[session_template_columns.created_with] = _("{Factory Template}");
+ }
+
+
+ //Add any "template sessions" found in the user's preferences folder
for (vector<TemplateInfo>::iterator x = templates.begin(); x != templates.end(); ++x) {
TreeModel::Row row;
row[session_template_columns.name] = (*x).name;
row[session_template_columns.path] = (*x).path;
+ row[session_template_columns.description] = (*x).description;
+ row[session_template_columns.created_with] = (*x).created_with;
}
-
- if (!templates.empty()) {
- /* select first row */
- template_chooser.set_active (0);
- }
+
+ //Add an explicit 'Empty Template' item
+ TreeModel::Row row = *template_model->prepend ();
+ row[session_template_columns.name] = (_("Empty Template"));
+ row[session_template_columns.path] = string();
+ row[session_template_columns.description] = _("An empty session with factory default settings.");
+ row[session_template_columns.created_with] = _("{Factory Template}");
+
+ //auto-select the first item in the list
+ Gtk::TreeModel::Row first = template_model->children()[0];
+ if(first) {
+ template_chooser.get_selection()->select(first);
+ }
}
void
SessionDialog::setup_new_session_page ()
{
- session_new_vbox.set_border_width (12);
- session_new_vbox.set_spacing (18);
-
- VBox *vbox1 = manage (new VBox);
- HBox* hbox1 = manage (new HBox);
- Label* label1 = manage (new Label);
+ session_new_vbox.set_border_width (8);
+ session_new_vbox.set_spacing (8);
- vbox1->set_spacing (6);
+ Label* name_label = manage (new Label);
+ name_label->set_text (_("Session name:"));
- hbox1->set_spacing (6);
- hbox1->pack_start (*label1, false, false);
- hbox1->pack_start (new_name_entry, true, true);
+ HBox* name_hbox = manage (new HBox);
+ name_hbox->set_spacing (6);
- label1->set_text (_("Session name:"));
+ name_hbox->pack_start (*name_label, false, false);
+ name_hbox->pack_start (new_name_entry, true, true);
if (!ARDOUR_COMMAND_LINE::session_name.empty()) {
new_name_entry.set_text (Glib::path_get_basename (ARDOUR_COMMAND_LINE::session_name));
new_name_entry.signal_changed().connect (sigc::mem_fun (*this, &SessionDialog::new_name_changed));
new_name_entry.signal_activate().connect (sigc::mem_fun (*this, &SessionDialog::new_name_activated));
- vbox1->pack_start (*hbox1, true, true);
-
/* --- */
- HBox* hbox2 = manage (new HBox);
+ HBox* folder_box = manage (new HBox);
Label* label2 = manage (new Label);
- hbox2->set_spacing (6);
- hbox2->pack_start (*label2, false, false);
- hbox2->pack_start (new_folder_chooser, true, true);
+ folder_box->set_spacing (6);
+ folder_box->pack_start (*label2, false, false);
+ folder_box->pack_start (new_folder_chooser, true, true);
label2->set_text (_("Create session folder in:"));
Gtkmm2ext::add_volume_shortcuts (new_folder_chooser);
- vbox1->pack_start (*hbox2, false, false);
-
- session_new_vbox.pack_start (*vbox1, false, false);
-
/* --- */
- VBox *vbox2 = manage (new VBox);
- HBox* hbox3 = manage (new HBox);
- template_model = ListStore::create (session_template_columns);
+ template_model = TreeStore::create (session_template_columns);
- vbox2->set_spacing (6);
+ HBox* template_hbox = manage (new HBox);
- VBox *vbox3 = manage (new VBox);
-
- vbox3->set_spacing (6);
-
- /* we may want to hide this and show it at various
- times depending on the existence of templates.
- */
- template_chooser.set_no_show_all (true);
- use_template_button.set_no_show_all (true);
-
- HBox* hbox4a = manage (new HBox);
- use_template_button.set_label (_("Use this template"));
-
- TreeModel::Row row = *template_model->prepend ();
- row[session_template_columns.name] = (_("no template"));
- row[session_template_columns.path] = string();
-
- hbox4a->set_spacing (6);
- hbox4a->pack_start (use_template_button, false, false);
- hbox4a->pack_start (template_chooser, true, true);
+ //if the "template override" is provided, don't give the user any template selections (?)
+ if ( load_template_override.empty() ) {
+ template_hbox->set_spacing (6);
+ template_hbox->pack_start (template_chooser, false, false);
+ template_hbox->pack_start (template_desc, true, true);
+ }
+
+ template_desc.set_editable (false);
+ template_desc.set_wrap_mode (Gtk::WRAP_WORD);
+ template_desc.set_size_request(300,400);
+ template_desc.set_left_margin(6);
+ template_desc.set_right_margin(6);
template_chooser.set_model (template_model);
-
- Gtk::CellRendererText* text_renderer = Gtk::manage (new Gtk::CellRendererText);
- text_renderer->property_editable() = false;
-
- template_chooser.pack_start (*text_renderer);
- template_chooser.add_attribute (text_renderer->property_text(), session_template_columns.name);
- template_chooser.set_active (0);
-
- vbox3->pack_start (*hbox4a, false, false);
+ template_chooser.set_size_request(300,400);
+ template_chooser.append_column (_("Template"), session_template_columns.name);
+ template_chooser.append_column (_("Created With"), session_template_columns.created_with);
+ template_chooser.set_headers_visible (true);
+ template_chooser.get_selection()->set_mode (SELECTION_SINGLE);
+ template_chooser.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &SessionDialog::template_row_selected));
+ template_chooser.set_sensitive (true);
/* --- */
- HBox* hbox5 = manage (new HBox);
-
- hbox5->set_spacing (6);
- hbox5->pack_start (more_new_session_options_button, false, false);
-
setup_more_options_box ();
more_new_session_options_button.add (more_options_vbox);
- vbox3->pack_start (*hbox5, false, false);
- hbox3->pack_start (*vbox3, true, true, 8);
- vbox2->pack_start (*hbox3, false, false);
-
/* --- */
- session_new_vbox.pack_start (*vbox2, false, false);
+ session_new_vbox.pack_start (*name_hbox, true, true);
+ session_new_vbox.pack_start (*folder_box, true, true);
+ session_new_vbox.pack_start (*template_hbox, false, false);
+ session_new_vbox.pack_start (more_new_session_options_button, false, false);
session_new_vbox.show_all ();
}
}
}
+void
+SessionDialog::template_row_selected ()
+{
+ if (template_chooser.get_selection()->count_selected_rows() > 0) {
+ TreeIter iter = template_chooser.get_selection()->get_selected();
+
+ if (iter) {
+ string s = (*iter)[session_template_columns.description];
+ template_desc.get_buffer()->set_text (s);
+ }
+ }
+}
+
void
SessionDialog::setup_more_options_box ()
{
return;
}
+ Gtk::TreeModel::Path tpath = recent_session_model->get_path(iter);
+ const bool is_child = tpath.up () && tpath.up ();
+
Gtk::Menu* m = manage (new Menu);
MenuList& items = m->items ();
- items.push_back (MenuElem (s));
- items.push_back (SeparatorElem());
- items.push_back (MenuElem (_("Remove from recent"), sigc::mem_fun (*this, &SessionDialog::recent_remove_selected)));
+ items.push_back (MenuElem (s, sigc::bind (sigc::hide_return (sigc::ptr_fun (&PBD::open_folder)), s)));
+ if (!is_child) {
+ items.push_back (SeparatorElem());
+ items.push_back (MenuElem (_("Remove session from recent list"), sigc::mem_fun (*this, &SessionDialog::recent_remove_selected)));
+ }
m->popup (ev->button, ev->time);
}