diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 169b150d70..cb0881c620 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -1706,14 +1706,20 @@ ARDOUR_UI::new_session (bool startup, std::string predetermined_path) m_new_session_dialog->show_all(); m_new_session_dialog->set_modal(true); m_new_session_dialog->set_name(predetermined_path); + m_new_session_dialog->reset_recent(); int response = Gtk::RESPONSE_CANCEL; do { response = m_new_session_dialog->run (); - if(response == Gtk::RESPONSE_CANCEL) { + if(response == Gtk::RESPONSE_CANCEL || response == Gtk::RESPONSE_DELETE_EVENT) { quit(); return; + + } else if (response == 0) { + /* Clear was pressed */ + m_new_session_dialog->reset(); + } else if (response == Gtk::RESPONSE_YES) { /* YES == OPEN, but there's no enum for that */ std::string session_name = m_new_session_dialog->session_name(); @@ -1803,7 +1809,7 @@ ARDOUR_UI::new_session (bool startup, std::string predetermined_path) } } - } while(response == Gtk::RESPONSE_HELP); + } while (response == 0); m_new_session_dialog->hide_all(); show(); diff --git a/gtk2_ardour/glade/new_session_dialog.glade b/gtk2_ardour/glade/new_session_dialog.glade index 5824ab4952..5ecee3b386 100644 --- a/gtk2_ardour/glade/new_session_dialog.glade +++ b/gtk2_ardour/glade/new_session_dialog.glade @@ -27,19 +27,6 @@ GTK_BUTTONBOX_DEFAULT_STYLE - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - True - -11 - - - True diff --git a/gtk2_ardour/new_session_dialog.cc b/gtk2_ardour/new_session_dialog.cc index 106fea7339..533cd2aa96 100644 --- a/gtk2_ardour/new_session_dialog.cc +++ b/gtk2_ardour/new_session_dialog.cc @@ -77,77 +77,17 @@ NewSessionDialog::NewSessionDialog(BaseObjectType* cobject, xml->get_widget(X_("TheTreeview"), m_treeview); xml->get_widget(X_("OkButton"), m_okbutton); - if (m_treeview) { - /* Shamelessly ripped from ardour_ui.cc */ - std::vector *sessions; - std::vector::iterator i; - RecentSessionsSorter cmp; - recent_model = Gtk::TreeStore::create (recent_columns); m_treeview->set_model (recent_model); m_treeview->append_column (_("Recent Sessions"), recent_columns.visible_name); m_treeview->set_headers_visible (false); m_treeview->get_selection()->set_mode (Gtk::SELECTION_SINGLE); - - recent_model->clear (); - - ARDOUR::RecentSessions rs; - ARDOUR::read_recent_sessions (rs); - - /* sort them alphabetically */ - sort (rs.begin(), rs.end(), cmp); - sessions = new std::vector; - - for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) { - sessions->push_back (new string ((*i).second)); - } - - for (i = sessions->begin(); i != sessions->end(); ++i) { - - std::vector* states; - std::vector item; - std::string fullpath = *(*i); - - /* remove any trailing / */ - - if (fullpath[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; - } - - Gtk::TreeModel::Row row = *(recent_model->append()); - - row[recent_columns.visible_name] = PBD::basename (fullpath); - row[recent_columns.fullpath] = fullpath; - - if (states->size() > 1) { - - /* add the children */ - - for (std::vector::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; - } - } - - delete states; - } - delete sessions; + } - + m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, false); + m_new_session_dialog->set_response_sensitive (0, false); m_new_session_dialog->set_default_response (Gtk::RESPONSE_OK); m_notebook->show_all_children(); m_notebook->set_current_page(0); @@ -321,6 +261,7 @@ NewSessionDialog::entry_key_release (GdkEventKey* ev) { if (m_name->get_text() != "") { m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, true); + m_new_session_dialog->set_response_sensitive (0, true); } else { m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, false); } @@ -331,6 +272,7 @@ void NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum) { if (pagenum == 1) { + m_new_session_dialog->set_response_sensitive (0, false); m_okbutton->set_label(_("Open")); m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON))); if (m_treeview->get_selection()->count_selected_rows() == 0) { @@ -339,6 +281,9 @@ NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum) m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, true); } } else { + if (m_name->get_text() != "") { + m_new_session_dialog->set_response_sensitive (0, true); + } m_okbutton->set_label(_("New")); m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON))); if (m_name->get_text() == "") { @@ -386,6 +331,71 @@ NewSessionDialog::reset_template() } +void +NewSessionDialog::reset_recent() +{ + /* Shamelessly ripped from ardour_ui.cc */ + std::vector *sessions; + std::vector::iterator i; + RecentSessionsSorter cmp; + + recent_model->clear (); + + ARDOUR::RecentSessions rs; + ARDOUR::read_recent_sessions (rs); + + /* sort them alphabetically */ + sort (rs.begin(), rs.end(), cmp); + sessions = new std::vector; + + for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) { + sessions->push_back (new string ((*i).second)); + } + + for (i = sessions->begin(); i != sessions->end(); ++i) { + + std::vector* states; + std::vector item; + std::string fullpath = *(*i); + + /* remove any trailing / */ + + if (fullpath[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; + } + + Gtk::TreeModel::Row row = *(recent_model->append()); + + row[recent_columns.visible_name] = PBD::basename (fullpath); + row[recent_columns.fullpath] = fullpath; + + if (states->size() > 1) { + + /* add the children */ + + for (std::vector::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; + } + } + + delete states; + } + delete sessions; +} + void NewSessionDialog::reset() { diff --git a/gtk2_ardour/new_session_dialog.h b/gtk2_ardour/new_session_dialog.h index 5e5e9723dd..8ee4a93969 100644 --- a/gtk2_ardour/new_session_dialog.h +++ b/gtk2_ardour/new_session_dialog.h @@ -93,15 +93,16 @@ public: bool connect_outs_to_master() const; bool connect_outs_to_physical() const ; int get_current_page(); + void reset_recent(); + + // reset everything to default values. + void reset(); protected: void reset_name(); void reset_template(); - // reset everything to default values. - void reset(); - // references to widgets we care about. Gtk::Dialog* m_new_session_dialog; Gtk::Entry* m_name;