basic -T <load_template> option

git-svn-id: svn://localhost/ardour2/branches/3.0@7208 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Torben Hohn
2010-06-02 14:36:10 +00:00
parent 816232cd97
commit ef505452a2
7 changed files with 39 additions and 8 deletions

View File

@@ -294,7 +294,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
/** @return true if a session was chosen and `apply' clicked, otherwise false if `cancel' was clicked */
bool
ARDOUR_UI::run_startup (bool should_be_new)
ARDOUR_UI::run_startup (bool should_be_new, string load_template)
{
if (_startup == 0) {
_startup = new ArdourStartup ();
@@ -307,6 +307,9 @@ ARDOUR_UI::run_startup (bool should_be_new)
}
_startup->set_new_only (should_be_new);
if (!load_template.empty()) {
_startup->set_load_template( load_template );
}
_startup->present ();
main().run();
@@ -642,7 +645,7 @@ Please consider the possibilities, and perhaps (re)start JACK."));
void
ARDOUR_UI::startup ()
{
if (get_session_parameters (true, ARDOUR_COMMAND_LINE::new_session)) {
if (get_session_parameters (true, ARDOUR_COMMAND_LINE::new_session, ARDOUR_COMMAND_LINE::load_template)) {
exit (1);
}
@@ -2388,7 +2391,7 @@ ARDOUR_UI::loading_message (const std::string& /*msg*/)
/** @param quit_on_cancel true if exit() should be called if the user clicks `cancel' in the new session dialog */
int
ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new)
ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, string load_template)
{
Glib::ustring session_name;
Glib::ustring session_path;
@@ -2396,6 +2399,11 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new)
int ret = -1;
bool likely_new = false;
if (! load_template.empty()) {
should_be_new = true;
template_name = load_template;
}
while (ret != 0) {
if (!should_be_new && !ARDOUR_COMMAND_LINE::session_name.empty()) {
@@ -2415,7 +2423,7 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new)
} else {
bool const apply = run_startup (should_be_new);
bool const apply = run_startup (should_be_new, load_template);
if (!apply) {
if (quit_on_cancel) {
exit (1);

View File

@@ -107,7 +107,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
ARDOUR_UI (int *argcp, char **argvp[]);
~ARDOUR_UI();
bool run_startup (bool should_be_new);
bool run_startup (bool should_be_new, std::string load_template);
void show ();
bool shown() { return shown_flag; }
@@ -137,7 +137,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
_will_create_new_session_automatically = yn;
}
int get_session_parameters (bool quit_on_cancel, bool should_be_new = false);
int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
void parse_cmdline_path (const Glib::ustring& cmdline_path, Glib::ustring& session_name, Glib::ustring& session_path, bool& existing_session);
int load_cmdline_session (const Glib::ustring& session_name, const Glib::ustring& session_path, bool& existing_session);
int build_session_from_nsd (const Glib::ustring& session_name, const Glib::ustring& session_path);

View File

@@ -113,7 +113,7 @@ ARDOUR_UI::install_actions ()
/* the real actions */
act = ActionManager::register_action (main_actions, X_("New"), _("New..."), hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::get_session_parameters), false, true)));
act = ActionManager::register_action (main_actions, X_("New"), _("New..."), hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::get_session_parameters), false, true, "")));
ActionManager::register_action (main_actions, X_("Open"), _("Open..."), sigc::mem_fun(*this, &ARDOUR_UI::open_session));
ActionManager::register_action (main_actions, X_("Recent"), _("Recent..."), sigc::mem_fun(*this, &ARDOUR_UI::open_recent_session));

View File

@@ -45,6 +45,7 @@ Glib::ustring ARDOUR_COMMAND_LINE::menus_file = "ardour.menus";
bool ARDOUR_COMMAND_LINE::finder_invoked_ardour = false;
string ARDOUR_COMMAND_LINE::immediate_save;
string ARDOUR_COMMAND_LINE::jack_session_uuid;
string ARDOUR_COMMAND_LINE::load_template;
using namespace ARDOUR_COMMAND_LINE;
@@ -78,7 +79,7 @@ print_help (const char *execname)
int
ARDOUR_COMMAND_LINE::parse_opts (int argc, char *argv[])
{
const char *optstring = "bc:C:dD:hk:E:m:N:nOp:SU:vV";
const char *optstring = "bc:C:dD:hk:E:m:N:nOp:ST:U:vV";
const char *execname = strrchr (argv[0], '/');
if (getenv ("ARDOUR_SAE")) {
@@ -107,6 +108,7 @@ ARDOUR_COMMAND_LINE::parse_opts (int argc, char *argv[])
{ "curvetest", 1, 0, 'C' },
{ "save", 1, 0, 'E' },
{ "uuid", 1, 0, 'U' },
{ "template", 1, 0, 'T' },
{ 0, 0, 0, 0 }
};
@@ -162,6 +164,9 @@ ARDOUR_COMMAND_LINE::parse_opts (int argc, char *argv[])
case 'S':
// ; just pass this through to gtk it will figure it out
break;
case 'T':
load_template = optarg;
break;
case 'N':
new_session = true;

View File

@@ -40,6 +40,7 @@ extern Glib::ustring menus_file;
extern bool finder_invoked_ardour;
extern std::string immediate_save;
extern std::string jack_session_uuid;
extern std::string load_template;
extern int32_t parse_opts (int argc, char *argv[]);

View File

@@ -142,9 +142,19 @@ ArdourStartup::set_new_only (bool yn)
}
}
void
ArdourStartup::set_load_template( string load_template )
{
use_template_button.set_active( false );
load_template_override = load_template;
}
bool
ArdourStartup::use_session_template ()
{
if (!load_template_override.empty())
return true;
if (use_template_button.get_active()) {
return template_chooser.get_active_row_number() > 0;
} else {
@@ -155,6 +165,11 @@ ArdourStartup::use_session_template ()
Glib::ustring
ArdourStartup::session_template_name ()
{
if (!load_template_override.empty()) {
string the_path = (ARDOUR::user_template_directory()/ (load_template_override + ".template")).to_string();
return the_path;
}
if (ic_existing_session_button.get_active()) {
return ustring();
}

View File

@@ -30,6 +30,7 @@ class ArdourStartup : public Gtk::Assistant {
~ArdourStartup ();
void set_new_only (bool);
void set_load_template( std::string load_template );
Glib::ustring session_name (bool& should_be_new);
Glib::ustring session_folder ();
@@ -177,6 +178,7 @@ class ArdourStartup : public Gtk::Assistant {
Gtk::RadioButtonGroup session_template_group;
Gtk::RadioButton use_session_as_template_button;
Gtk::RadioButton use_template_button;
std::string load_template_override;
void more_new_session_options_button_clicked();
void new_name_changed ();