13
0

changes to integrate new/recent/browse in new session dialog.

Probably some errors/mistakes in here and no doubt some improvements to be done.
This commit is contained in:
Paul Davis 2013-09-20 14:17:59 -04:00
parent 960a47330a
commit bab9184f7c
2 changed files with 183 additions and 218 deletions

View File

@ -70,8 +70,6 @@ ArdourStartup::ArdourStartup (bool require_new, const std::string& session_name,
, config_modified (false)
, new_only (require_new)
, default_dir_chooser (0)
, ic_new_session_button (_("Create a new session"))
, ic_existing_session_button (_("Open an existing session"))
, monitor_via_hardware_button (string_compose (_("Use an external mixer or the hardware mixer of your audio interface.\n"
"%1 will play NO role in monitoring"), PROGRAM_NAME))
, monitor_via_ardour_button (string_compose (_("Ask %1 to play back material as it is being recorded"), PROGRAM_NAME))
@ -84,7 +82,7 @@ ArdourStartup::ArdourStartup (bool require_new, const std::string& session_name,
, new_user_page_index (-1)
, default_folder_page_index (-1)
, monitoring_page_index (-1)
, session_page_index (-1)
, new_session_page_index (-1)
, initial_choice_index (-1)
, final_page_index (-1)
, session_options_page_index (-1)
@ -137,27 +135,19 @@ ArdourStartup::ArdourStartup (bool require_new, const std::string& session_name,
setup_first_time_config_page ();
setup_monitoring_choice_page ();
setup_monitor_section_choice_page ();
ic_new_session_button.set_active (true); // always create new session on first run
setup_final_page ();
setup_new_session_page ();
} else {
if (!new_only) {
setup_initial_choice_page ();
}
setup_new_session_page ();
}
setup_session_page ();
setup_more_options_page ();
if (new_user) {
setup_final_page ();
}
if (new_only) {
ic_vbox.hide ();
} else {
ic_vbox.show ();
}
if (!template_name.empty()) {
use_template_button.set_active (false);
load_template_override = template_name;
@ -232,10 +222,6 @@ ArdourStartup::session_template_name ()
return Glib::build_filename (the_path, load_template_override + ARDOUR::template_suffix);
}
if (ic_existing_session_button.get_active()) {
return string();
}
if (use_template_button.get_active()) {
TreeModel::iterator iter = template_chooser.get_active ();
TreeModel::Row row = (*iter);
@ -254,26 +240,24 @@ ArdourStartup::session_name (bool& should_be_new)
return _provided_session_name;
}
if (ic_new_session_button.get_active()) {
should_be_new = true;
string val = new_name_entry.get_text ();
strip_whitespace_edges (val);
return val;
} else if (_existing_session_chooser_used) {
/* existing session chosen from file chooser */
should_be_new = false;
return existing_session_chooser.get_filename ();
} else {
/* existing session chosen from recent list */
should_be_new = false;
/* Try recent session selection */
TreeIter iter = recent_session_display.get_selection()->get_selected();
if (iter) {
should_be_new = false;
return (*iter)[recent_session_columns.visible_name];
}
return "";
if (_existing_session_chooser_used) {
/* existing session chosen from file chooser */
should_be_new = false;
return existing_session_chooser.get_filename ();
} else {
should_be_new = true;
string val = new_name_entry.get_text ();
strip_whitespace_edges (val);
return val;
}
}
@ -284,20 +268,20 @@ ArdourStartup::session_folder ()
return _provided_session_path;
}
if (ic_new_session_button.get_active()) {
std::string legal_session_folder_name = legalize_for_path (new_name_entry.get_text());
return Glib::build_filename (new_folder_chooser.get_current_folder(), legal_session_folder_name);
} else if (_existing_session_chooser_used) {
/* existing session chosen from file chooser */
return existing_session_chooser.get_current_folder ();
} else {
/* existing session chosen from recent list */
/* Try recent session selection */
TreeIter iter = recent_session_display.get_selection()->get_selected();
if (iter) {
return (*iter)[recent_session_columns.fullpath];
}
return "";
if (_existing_session_chooser_used) {
/* existing session chosen from file chooser */
return existing_session_chooser.get_current_folder ();
} else {
std::string legal_session_folder_name = legalize_for_path (new_name_entry.get_text());
return Glib::build_filename (new_folder_chooser.get_current_folder(), legal_session_folder_name);
}
}
@ -511,16 +495,31 @@ ArdourStartup::setup_initial_choice_page ()
ic_vbox.set_spacing (6);
ic_vbox.set_border_width (24);
RadioButton::Group g (ic_new_session_button.get_group());
ic_existing_session_button.set_group (g);
/* append the page early because the recent session display will cause
calls to set_page_complete() on this page.
*/
initial_choice_index = append_page (ic_vbox);
set_page_title (ic_vbox, string_compose("%1 %2", PROGRAM_NAME, VERSIONSTRING));
set_page_header_image (ic_vbox, icon_pixbuf);
HBox* centering_hbox = manage (new HBox);
VBox* centering_vbox = manage (new VBox);
centering_vbox->set_spacing (6);
Label* new_label = manage (new Label);
new_label->set_markup (string_compose ("<span weight=\"bold\" size=\"large\">%1</span>", _("Create a new session")));
new_label->set_alignment (0, 0.5);
ic_new_session_button.set_label (_("Configure the new session ..."));
ic_new_session_button.signal_clicked().connect (sigc::mem_fun (*this, &ArdourStartup::new_session_button_clicked));
centering_vbox->pack_start (*new_label, false, false, 12);
centering_vbox->pack_start (ic_new_session_button, false, true);
centering_vbox->pack_start (ic_existing_session_button, false, true);
/* Possible update message */
if (ARDOUR_UI::instance()->announce_string() != "" ) {
@ -549,22 +548,75 @@ ArdourStartup::setup_initial_choice_page ()
info_box->pack_start (*updates_button, false, false);
}
ic_new_session_button.signal_button_press_event().connect(sigc::mem_fun(*this, &ArdourStartup::initial_button_clicked), false);
ic_new_session_button.signal_activate().connect(sigc::mem_fun(*this, &ArdourStartup::initial_button_activated), false);
ARDOUR::RecentSessions rs;
ARDOUR::read_recent_sessions (rs);
ic_existing_session_button.signal_button_press_event().connect(sigc::mem_fun(*this, &ArdourStartup::initial_button_clicked), false);
ic_existing_session_button.signal_activate().connect(sigc::mem_fun(*this, &ArdourStartup::initial_button_activated), false);
if (!rs.empty()) {
/* recent session scroller */
Label* load_label = manage (new Label);
load_label->set_markup (string_compose ("<span weight=\"bold\" size=\"large\">%1</span>", _("Load a recent session")));
load_label->set_alignment (0, 0.5);
centering_vbox->pack_start (*load_label, false, false, 12);
recent_session_model = TreeStore::create (recent_session_columns);
redisplay_recent_sessions ();
recent_session_display.set_model (recent_session_model);
recent_session_display.append_column (_("Recent Sessions"), recent_session_columns.visible_name);
recent_session_display.set_headers_visible (false);
recent_session_display.get_selection()->set_mode (SELECTION_SINGLE);
recent_session_display.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &ArdourStartup::recent_session_row_selected));
recent_scroller.add (recent_session_display);
recent_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
recent_scroller.set_shadow_type (Gtk::SHADOW_IN);
recent_session_display.show();
recent_scroller.show();
recent_session_display.signal_row_activated().connect (sigc::mem_fun (*this, &ArdourStartup::recent_row_activated));
int cnt = redisplay_recent_sessions ();
if (cnt > 4) {
recent_scroller.set_size_request (-1, 300);
}
centering_vbox->pack_start (recent_scroller, false, true);
}
/* Browse button */
existing_session_chooser.set_title (_("Select session file"));
existing_session_chooser.signal_file_set().connect (sigc::mem_fun (*this, &ArdourStartup::existing_session_selected));
existing_session_chooser.set_current_folder(poor_mans_glob (Config->get_default_session_parent_dir()));
FileFilter session_filter;
session_filter.add_pattern ("*.ardour");
session_filter.set_name (string_compose (_("%1 sessions"), PROGRAM_NAME));
existing_session_chooser.add_filter (session_filter);
existing_session_chooser.set_filter (session_filter);
#ifdef GTKOSX
existing_session_chooser.add_shortcut_folder ("/Volumes");
#endif
Label* browse_label = manage (new Label);
browse_label->set_markup (string_compose ("<span weight=\"bold\" size=\"large\">%1</span>", _("Browse for other sessions")));
browse_label->set_alignment (0, 0.5);
centering_vbox->pack_start (*browse_label, false, false, 12);
centering_vbox->pack_start (existing_session_chooser, false, false);
/* pack it all up */
centering_hbox->pack_start (*centering_vbox, true, true);
ic_vbox.pack_start (*centering_hbox, true, true);
ic_vbox.show_all ();
initial_choice_index = append_page (ic_vbox);
set_page_title (ic_vbox, string_compose("%1 %2", PROGRAM_NAME, VERSIONSTRING));
set_page_header_image (ic_vbox, icon_pixbuf);
/* user could just click on "Forward" if default
* choice is correct.
*/
@ -572,35 +624,33 @@ ArdourStartup::setup_initial_choice_page ()
set_page_complete (ic_vbox, true);
}
bool
ArdourStartup::initial_button_clicked (GdkEventButton* ev)
{
if (ev->type == GDK_2BUTTON_PRESS && session_page_index != -1) {
set_current_page(session_page_index);
}
return false;
}
void
ArdourStartup::initial_button_activated ()
ArdourStartup::session_selected ()
{
if (session_page_index != -1) {
set_current_page(session_page_index);
/* HACK HACK HACK ... change the "Apply" button label
to say "Open"
*/
Gtk::Widget* tl = ic_vbox.get_toplevel();
Gtk::Window* win;
if ((win = dynamic_cast<Gtk::Window*>(tl)) != 0) {
/* ::get_default_widget() is not wrapped in gtkmm */
Gtk::Widget* def = wrap (gtk_window_get_default_widget (win->gobj()));
Gtk::Button* button;
if ((button = dynamic_cast<Gtk::Button*>(def)) != 0) {
if (more_new_session_options_button.get_active()) {
button->set_label (_("Next"));
} else {
button->set_label (_("Open"));
}
}
}
}
void
ArdourStartup::setup_session_page ()
ArdourStartup::new_session_button_clicked ()
{
session_vbox.set_border_width (24);
session_vbox.pack_start (session_hbox, true, true);
session_vbox.show_all ();
session_page_index = append_page (session_vbox);
/* initial setting */
set_page_type (session_vbox, ASSISTANT_PAGE_CONFIRM);
set_current_page (new_session_page_index);
}
void
@ -621,6 +671,24 @@ ArdourStartup::on_cancel ()
gtk_main_quit ();
}
void
ArdourStartup::on_prepare (Gtk::Widget* page)
{
if (page == &session_new_vbox) {
/* if the user already defined a name by using the recent
* session list or browsing to an existing session
* then we are done.
*/
bool expect_new_ignored;
if (!session_name (expect_new_ignored).empty()) {
on_apply ();
}
}
}
bool
ArdourStartup::on_delete_event (GdkEventAny*)
{
@ -662,41 +730,6 @@ ArdourStartup::on_apply ()
gtk_main_quit ();
}
void
ArdourStartup::on_prepare (Gtk::Widget* page)
{
if (page == &session_vbox) {
if (ic_new_session_button.get_active()) {
/* new session requested */
setup_new_session_page ();
} else {
/* existing session requested */
setup_existing_session_page ();
}
/* HACK HACK HACK ... change the "Apply" button label
to say "Open"
*/
Gtk::Widget* tl = session_vbox.get_toplevel();
Gtk::Window* win;
if ((win = dynamic_cast<Gtk::Window*>(tl)) != 0) {
/* ::get_default_widget() is not wrapped in gtkmm */
Gtk::Widget* def = wrap (gtk_window_get_default_widget (win->gobj()));
Gtk::Button* button;
if ((button = dynamic_cast<Gtk::Button*>(def)) != 0) {
if (more_new_session_options_button.get_active()) {
button->set_label (_("Forward"));
}else{
button->set_label (_("Open"));
}
}
}
}
}
void
ArdourStartup::populate_session_templates ()
{
@ -719,10 +752,7 @@ ArdourStartup::populate_session_templates ()
void
ArdourStartup::setup_new_session_page ()
{
if (!session_hbox.get_children().empty()) {
session_hbox.remove (**session_hbox.get_children().begin());
}
session_new_vbox.set_border_width (12);
session_new_vbox.set_spacing (18);
if (session_new_vbox.get_children().empty()) {
@ -742,7 +772,7 @@ ArdourStartup::setup_new_session_page ()
if (!ARDOUR_COMMAND_LINE::session_name.empty()) {
new_name_entry.set_text (Glib::path_get_basename (ARDOUR_COMMAND_LINE::session_name));
/* name provided - they can move right along */
set_page_complete (session_vbox, true);
set_page_complete (session_new_vbox, true);
}
new_name_entry.signal_changed().connect (sigc::mem_fun (*this, &ArdourStartup::new_name_changed));
@ -882,23 +912,26 @@ ArdourStartup::setup_new_session_page ()
}
session_new_vbox.show_all ();
session_hbox.pack_start (session_new_vbox, true, true);
set_page_title (session_vbox, _("New Session"));
set_page_type (session_vbox, ASSISTANT_PAGE_CONFIRM);
new_session_page_index = append_page (session_new_vbox);
set_page_type (session_new_vbox, ASSISTANT_PAGE_CONTENT);
set_page_title (session_new_vbox, _("New Session"));
if (more_new_session_options_button.get_active()) {
set_page_type (session_vbox, ASSISTANT_PAGE_CONTENT);
set_page_type (session_new_vbox, ASSISTANT_PAGE_CONTENT);
} else {
set_page_type (session_new_vbox, ASSISTANT_PAGE_CONFIRM);
}
session_hbox.show_all();
}
void
ArdourStartup::new_name_changed ()
{
if (!new_name_entry.get_text().empty()) {
set_page_complete (session_vbox, true);
session_selected ();
set_page_complete (session_new_vbox, true);
} else {
set_page_complete (session_vbox, false);
set_page_complete (session_new_vbox, false);
}
}
@ -996,87 +1029,22 @@ void
ArdourStartup::recent_session_row_selected ()
{
if (recent_session_display.get_selection()->count_selected_rows() > 0) {
set_page_complete (session_vbox, true);
set_page_complete (ic_vbox, true);
session_selected ();
} else {
set_page_complete (session_vbox, false);
set_page_complete (ic_vbox, false);
}
}
void
ArdourStartup::setup_existing_session_page ()
{
recent_session_model = TreeStore::create (recent_session_columns);
redisplay_recent_sessions ();
if (!session_hbox.get_children().empty()) {
session_hbox.remove (**session_hbox.get_children().begin());
}
if (session_existing_vbox.get_children().empty()) {
recent_session_display.set_model (recent_session_model);
recent_session_display.append_column (_("Recent Sessions"), recent_session_columns.visible_name);
recent_session_display.set_headers_visible (false);
recent_session_display.get_selection()->set_mode (SELECTION_BROWSE);
recent_session_display.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &ArdourStartup::recent_session_row_selected));
recent_scroller.add (recent_session_display);
recent_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
recent_scroller.set_shadow_type (Gtk::SHADOW_IN);
recent_session_display.show();
recent_scroller.show();
int cnt = redisplay_recent_sessions ();
recent_session_display.signal_row_activated().connect (sigc::mem_fun (*this, &ArdourStartup::recent_row_activated));
if (cnt > 4) {
recent_scroller.set_size_request (-1, 300);
}
session_existing_vbox.set_spacing (8);
session_existing_vbox.pack_start (recent_scroller, true, true);
existing_session_chooser.set_title (_("Select session file"));
existing_session_chooser.signal_file_set().connect (sigc::mem_fun (*this, &ArdourStartup::existing_session_selected));
existing_session_chooser.set_current_folder(poor_mans_glob (Config->get_default_session_parent_dir()));
FileFilter session_filter;
session_filter.add_pattern ("*.ardour");
session_filter.set_name (string_compose (_("%1 sessions"), PROGRAM_NAME));
existing_session_chooser.add_filter (session_filter);
existing_session_chooser.set_filter (session_filter);
#ifdef GTKOSX
existing_session_chooser.add_shortcut_folder ("/Volumes");
#endif
HBox* hbox = manage (new HBox);
hbox->set_spacing (4);
hbox->pack_start (*manage (new Label (_("Browse:"))), PACK_SHRINK);
hbox->pack_start (existing_session_chooser);
session_existing_vbox.pack_start (*hbox, false, false);
hbox->show_all ();
}
session_existing_vbox.show_all ();
session_hbox.pack_start (session_existing_vbox, true, true);
set_page_title (session_vbox, _("Select a session"));
set_page_type (session_vbox, ASSISTANT_PAGE_CONFIRM);
session_hbox.show_all();
}
void
ArdourStartup::more_new_session_options_button_clicked ()
{
if (more_new_session_options_button.get_active()) {
more_options_vbox.show_all ();
set_page_type (more_options_vbox, ASSISTANT_PAGE_CONFIRM);
set_page_type (session_vbox, ASSISTANT_PAGE_CONTENT);
set_page_type (session_new_vbox, ASSISTANT_PAGE_CONTENT);
} else {
set_page_type (session_vbox, ASSISTANT_PAGE_CONFIRM);
set_page_type (session_new_vbox, ASSISTANT_PAGE_CONFIRM);
more_options_vbox.hide ();
}
}
@ -1385,19 +1353,21 @@ ArdourStartup::move_along_now ()
{
gint cur = get_current_page ();
if (cur == session_page_index) {
if (cur == new_session_page_index) {
if (more_new_session_options_button.get_active()) {
set_current_page (session_options_page_index);
} else {
on_apply ();
}
} else {
on_apply ();
}
}
void
ArdourStartup::recent_row_activated (const Gtk::TreePath&, Gtk::TreeViewColumn*)
{
set_page_complete (session_vbox, true);
set_page_complete (ic_vbox, true);
move_along_now ();
}
@ -1406,7 +1376,8 @@ ArdourStartup::existing_session_selected ()
{
_existing_session_chooser_used = true;
set_page_complete (session_vbox, true);
session_selected ();
set_page_complete (ic_vbox, true);
move_along_now ();
}

View File

@ -113,10 +113,8 @@ class ArdourStartup : public Gtk::Assistant {
void setup_initial_choice_page ();
Gtk::VBox ic_vbox;
Gtk::RadioButton ic_new_session_button;
Gtk::RadioButton ic_existing_session_button;
bool initial_button_clicked(GdkEventButton*);
void initial_button_activated();
Gtk::Button ic_new_session_button;
void new_session_button_clicked ();
/* monitoring choices */
@ -134,11 +132,6 @@ class ArdourStartup : public Gtk::Assistant {
Gtk::RadioButton no_monitor_section_button;
void setup_monitor_section_choice_page ();
/* session page (could be new or existing) */
void setup_session_page ();
Gtk::VBox session_vbox;
Gtk::HBox session_hbox;
/* recent sessions */
@ -171,6 +164,7 @@ class ArdourStartup : public Gtk::Assistant {
void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
void existing_session_selected ();
void session_selected ();
/* new sessions */
@ -278,7 +272,7 @@ class ArdourStartup : public Gtk::Assistant {
gint default_folder_page_index;
gint monitoring_page_index;
gint monitor_section_page_index;
gint session_page_index;
gint new_session_page_index;
gint initial_choice_index;
gint final_page_index;
gint session_options_page_index;