diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index f0f7fb6da3..fbd83e9057 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -440,8 +440,6 @@ ARDOUR_UI::ask_about_saving_session (const string & what) Gtk::Label prompt_label; Gtk::Image* dimage = manage (new Gtk::Image(Stock::DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG)); - dimage->set_alignment(ALIGN_LEFT, ALIGN_TOP); - string msg; msg = string_compose(_("Don't %1"), what); @@ -464,14 +462,14 @@ ARDOUR_UI::ask_about_saving_session (const string & what) } else { type = _("snapshot"); } - prompt = string_compose(_("The %1\n\"%2\"\nhas not been saved.\n\nAny changes made this time\nwill be lost unless you save it.\n\nWhat do you want to do?"), + prompt = string_compose(_("The %1\"%2\"\nhas not been saved.\n\nAny changes made this time\nwill be lost unless you save it.\n\nWhat do you want to do?"), type, session->snap_name()); prompt_label.set_text (prompt); prompt_label.set_name (X_("PrompterLabel")); prompt_label.set_alignment(ALIGN_LEFT, ALIGN_TOP); dhbox.set_homogeneous (false); - dhbox.pack_start (*dimage, true, false, 5); + dhbox.pack_start (*dimage, false, false, 5); dhbox.pack_start (prompt_label, true, false, 5); window.get_vbox()->pack_start (dhbox); @@ -1710,8 +1708,29 @@ ARDOUR_UI::new_session (bool startup, std::string predetermined_path) do { response = m_new_session_dialog->run (); - - if(response == Gtk::RESPONSE_OK) { + if(response == Gtk::RESPONSE_CANCEL) { + quit(); + return; + } 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(); + std::string session_path = m_new_session_dialog->session_folder(); + load_session (session_path, session_name); + + + } else if (response == Gtk::RESPONSE_OK) { + if (m_new_session_dialog->get_current_page() == 1) { + + /* XXX this is a bit of a hack.. + i really want the new sesion dialog to return RESPONSE_YES + if we're on page 1 (the load page) + Unfortunately i can't see how atm.. + */ + std::string session_name = m_new_session_dialog->session_name(); + std::string session_path = m_new_session_dialog->session_folder(); + load_session (session_path, session_name); + + } else { _session_is_new = true; @@ -1777,11 +1796,21 @@ ARDOUR_UI::new_session (bool startup, std::string predetermined_path) nphysin, nphysout, engine->frame_rate() * 60 * 5); - } + } + } } - + } while(response == Gtk::RESPONSE_HELP); m_new_session_dialog->hide_all(); + show(); + +} + +void +ARDOUR_UI::close_session() +{ + unload_session(); + new_session (); } int @@ -1834,6 +1863,8 @@ ARDOUR_UI::make_session_clean () session->set_clean (); } + show (); + return FALSE; } diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index cff822e2f3..89ae4df7da 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -130,10 +130,10 @@ class ARDOUR_UI : public Gtkmm2ext::UI _will_create_new_session_automatically = yn; } - void new_session(bool startup = false, std::string path = string()); + void new_session(bool startup = false, std::string path = string()); gint cmdline_new_session (string path); int unload_session (); - void close_session() { unload_session(); } + void close_session(); int save_state_canfail (string state_name = ""); void save_state (const string & state_name = ""); diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index a6f0e2dc50..1c270ef38d 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -158,7 +158,7 @@ ARDOUR_UI::unload_session () break; } } - + editor->hide (); second_connection.disconnect (); point_one_second_connection.disconnect (); point_zero_one_second_connection.disconnect(); diff --git a/gtk2_ardour/glade/new_session_dialog.glade b/gtk2_ardour/glade/new_session_dialog.glade index 529df7419b..5824ab4952 100644 --- a/gtk2_ardour/glade/new_session_dialog.glade +++ b/gtk2_ardour/glade/new_session_dialog.glade @@ -12,10 +12,10 @@ False True False - False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST True + False True @@ -41,11 +41,11 @@ - + True True True - gtk-cancel + gtk-quit True GTK_RELIEF_NORMAL True @@ -86,172 +86,307 @@ - - 5 - 4 - 2 - False - 1 - 1 + + True + True + True + True + GTK_POS_TOP + False + False - - Session Name - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 0 - 1 - - - - - - True - True - 0 - - True - * - False - - - 1 - 2 - 0 - 1 - - - - - - Session Location - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 1 - 2 - - - - - - Select A Folder - GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER - True - False - -1 - - - 1 - 2 - 1 - 2 - - - - - - Session Template - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 2 - 3 - - - - - - Select A File - GTK_FILE_CHOOSER_ACTION_OPEN - True - False - -1 - - - 1 - 2 - 2 - 3 - - - - - - 10 - True - True - True - 0 + + 5 + 4 + 2 + False + 1 + 1 - + + Session Name + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + + + + + + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + Session Location + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + + + + + + Select A Folder + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER + True + False + False + -1 + + + 1 + 2 + 1 + 2 + + + + + + Session Template + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + + + + + + Select a File + GTK_FILE_CHOOSER_ACTION_OPEN + True + False + False + -1 + + + 1 + 2 + 2 + 3 + + + + + + 10 True - False + True + True 0 - + True - 3 - 2 - True - 0 - 0 + False + 0 - + True - Channel Count + 3 + 2 + True + 0 + 0 + + + + True + Channel Count + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 0 + 1 + + + + + + + + True + True + Create Control Bus + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 2 0 100 1 10 10 + + + 1 + 2 + 2 + 3 + + + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 2 0 100 1 10 10 + + + 1 + 2 + 1 + 2 + + + + + + + + True + True + Create Master Bus + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 0 + 1 + 1 + 2 + fill + + + + + + 0 + False + False + + + + + + True + Track/Bus connection options False False GTK_JUSTIFY_LEFT False False - 0 + 0.5 0.5 0 0 @@ -261,114 +396,503 @@ 0 - 1 - 2 - 0 - 1 - - + 14 + False + False - + True - True - Create Control Bus - True - GTK_RELIEF_NORMAL - True - False - False - True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + 1 + 1 + False + 0 + 0 + + + + True + False + 0 + + + + True + True + Automatically connect inputs + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + False + 0 + + + + True + True + Port limit + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + + 0 + True + True + + + + + 0 + True + False + + + + + 0 + 1 + 0 + 1 + + + + + + + + + + True + <b>Input</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + - 0 - 1 - 2 - 3 - fill - + 0 + True + True - + True - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 2 0 100 1 10 10 - - - 1 - 2 - 2 - 3 - - - - + 0 + 0.5 + GTK_SHADOW_NONE - - - True - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 2 0 100 1 10 10 - - - 1 - 2 - 1 - 2 - - - - + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 - - - True - True - Create Master Bus - True - GTK_RELIEF_NORMAL - True - True - False - True + + + True + False + 0 + + + + True + False + 0 + + + + True + True + Automatically connect outputs + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + False + 0 + + + + True + True + Port limit + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + + 0 + True + True + + + + + 0 + True + False + + + + + 0 + True + True + + + + + + True + False + 0 + + + + True + True + Connect to Master Bus + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + Connect to physical outputs + True + GTK_RELIEF_NORMAL + True + False + False + True + ConnectOutsToMaster + + + 0 + False + False + + + + + 0 + True + True + + + + + + + + + + True + <b>Output</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + - 0 - 1 - 1 - 2 - fill - + 0 + True + True - - 0 - False - False - - + True - Track/Bus connection options + <b>Advanced</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + 2 + 3 + 4 + fill + + + + + False + True + + + + + + True + New Session + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + True + False + 0 + + + + 10 + True + 0 + 0.5 + GTK_SHADOW_IN + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 0 + + + + Open Session + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + True + + + + + + + + + + Select a Session + GTK_FILE_CHOOSER_ACTION_OPEN + True + False + False + -1 + + + 0 + True + True + + + + + + + + + + + + + + True + Open Session False False GTK_JUSTIFY_LEFT @@ -384,383 +908,121 @@ 0 - 14 - False - False - - - - - - True - 0 - 0.5 - GTK_SHADOW_NONE - - - - True - 0.5 - 0.5 - 1 - 1 - 0 - 0 - 12 - 0 - - - - True - 1 - 1 - False - 0 - 0 - - - - True - False - 0 - - - - True - True - Automatically connect inputs - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - - True - False - 0 - - - - True - True - Port limit - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - - True - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 1 0 100 1 10 10 - - - 0 - True - True - - - - - 0 - True - False - - - - - 0 - 1 - 0 - 1 - - - - - - - - - - True - <b>Input</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - label_item - - - - - 0 - True - True - - - - - - True - 0 - 0.5 - GTK_SHADOW_NONE - - - - True - 0.5 - 0.5 - 1 - 1 - 0 - 0 - 12 - 0 - - - - True - False - 0 - - - - True - False - 0 - - - - True - True - Automatically connect outputs - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - - True - False - 0 - - - - True - True - Port limit - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - - True - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 1 0 100 1 10 10 - - - 0 - True - True - - - - - 0 - True - False - - - - - 0 - True - True - - - - - - True - False - 0 - - - - True - True - Connect to Master Bus - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - - True - True - Connect to physical outputs - True - GTK_RELIEF_NORMAL - True - False - False - True - ConnectOutsToMaster - - - 0 - False - False - - - - - 0 - True - True - - - - - - - - - - True - <b>Output</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - label_item - - - - - 0 - True - True + label_item + + 0 + False + False + - + + 10 True - <b>Advanced</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + 0 + 0.5 + GTK_SHADOW_IN + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + 10 + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + False + False + True + + + + + + + + + + True + Open Recent Session + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + - label_item + 5 + True + True - 0 - 2 - 3 - 4 - fill + False + True + + + + + + True + Open Session + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index edff606329..00b91e00e7 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -436,9 +436,8 @@ To create it from the command line, start ardour as \"ardour --new %1"), path) } else { ui->hide_splash (); - ui->show (); if (!Config->get_no_new_session_dialog()) { - ui->new_session (true); + ui->new_session (true); } } diff --git a/gtk2_ardour/new_session_dialog.cc b/gtk2_ardour/new_session_dialog.cc index 90b3500a91..106fea7339 100644 --- a/gtk2_ardour/new_session_dialog.cc +++ b/gtk2_ardour/new_session_dialog.cc @@ -22,11 +22,19 @@ #include "new_session_dialog.h" #include "glade_path.h" +#include +#include + +#include + #include #include #include #include #include +#include +#include + const char* NewSessionDialogFactory::s_m_top_level_widget_name = X_("NewSessionDialog"); const char* NewSessionDialogFactory::top_level_widget_name() { return s_m_top_level_widget_name; } @@ -43,7 +51,7 @@ NewSessionDialog::NewSessionDialog(BaseObjectType* cobject, : Gtk::Dialog(cobject) { // look up the widgets we care about. - + xml->get_widget(X_("NewSessionDialog"), m_new_session_dialog); xml->get_widget(X_("SessionNameEntry"), m_name); xml->get_widget(X_("SessionFolderChooser"), m_folder); xml->get_widget(X_("SessionTemplateChooser"), m_template); @@ -64,8 +72,99 @@ NewSessionDialog::NewSessionDialog(BaseObjectType* cobject, xml->get_widget(X_("ConnectOutsToMaster"), m_connect_outputs_to_master); xml->get_widget(X_("ConnectOutsToPhysical"), m_connect_outputs_to_physical); + xml->get_widget(X_("OpenFilechooserButton"), m_open_filechooser); + xml->get_widget(X_("TheNotebook"), m_notebook); + 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_default_response (Gtk::RESPONSE_OK); + m_notebook->show_all_children(); + m_notebook->set_current_page(0); + + Gtk::FileFilter* filter = manage (new (Gtk::FileFilter)); + + filter->add_pattern(X_("*.ardour")); + filter->add_pattern(X_("*.ardour.bak")); + m_open_filechooser->set_filter (*filter); + ///@ todo connect some signals + m_name->signal_key_release_event().connect(mem_fun (*this, &NewSessionDialog::entry_key_release)); + 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)); + m_open_filechooser->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::file_chosen)); } void @@ -77,19 +176,51 @@ NewSessionDialog::set_session_name(const Glib::ustring& name) std::string NewSessionDialog::session_name() const { - return Glib::filename_from_utf8(m_name->get_text()); + 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 ('.'); + str = str.substr (0, position); + + /* + XXX what to do if it's a .bak file? + load_session doesn't allow it! + + if ((position = str.rfind(".bak")) != string::npos) { + str = str.substr (0, position); + } + */ + + if (m_notebook->get_current_page() == 0) { + return Glib::filename_from_utf8(m_name->get_text()); + } else { + if (m_treeview->get_selection()->count_selected_rows() == 0) { + return Glib::filename_from_utf8(str); + } + Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected(); + return (*i)[recent_columns.visible_name]; + } } std::string NewSessionDialog::session_folder() const { - return Glib::filename_from_utf8(m_folder->get_current_folder()); + if (m_notebook->get_current_page() == 0) { + 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()); + } + 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()) return false; + if(m_template->get_filename().empty() && (m_notebook->get_current_page() == 0)) return false; return true; } @@ -171,6 +302,12 @@ NewSessionDialog::connect_outs_to_physical() const return m_connect_outputs_to_physical->get_active(); } +int +NewSessionDialog::get_current_page() +{ + return m_notebook->get_current_page(); + +} void NewSessionDialog::reset_name() @@ -179,6 +316,69 @@ NewSessionDialog::reset_name() } +bool +NewSessionDialog::entry_key_release (GdkEventKey* ev) +{ + if (m_name->get_text() != "") { + m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, true); + } else { + m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, false); + } + return true; +} + +void +NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum) +{ + if (pagenum == 1) { + 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) { + m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, false); + } else { + m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, true); + } + } else { + m_okbutton->set_label(_("New")); + m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON))); + if (m_name->get_text() == "") { + m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, false); + } else { + m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, true); + } + } +} + +void +NewSessionDialog::treeview_selection_changed () +{ + if (m_treeview->get_selection()->count_selected_rows() == 0) { + if (!m_open_filechooser->get_filename().empty()) { + m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, true); + } else { + m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, false); + } + } else { + m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, true); + } +} + +void +NewSessionDialog::file_chosen () +{ + m_treeview->get_selection()->unselect_all(); + + if (m_treeview->get_selection()->count_selected_rows() == 0) { + m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, true); + } +} + +void +NewSessionDialog::recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col) +{ + m_new_session_dialog->response (Gtk::RESPONSE_YES); +} + /// @todo void NewSessionDialog::reset_template() diff --git a/gtk2_ardour/new_session_dialog.h b/gtk2_ardour/new_session_dialog.h index ec3a3eb033..5e5e9723dd 100644 --- a/gtk2_ardour/new_session_dialog.h +++ b/gtk2_ardour/new_session_dialog.h @@ -25,6 +25,14 @@ #include #include +#include +#include +#include +#include +#include + +#include + #include namespace Gtk { @@ -33,6 +41,8 @@ namespace Gtk { class SpinButton; class CheckButton; class RadioButton; + class TreeView; + class Notebook; } #include "glade_factory.h" @@ -82,6 +92,7 @@ public: bool connect_outs_to_master() const; bool connect_outs_to_physical() const ; + int get_current_page(); protected: @@ -92,7 +103,7 @@ protected: void reset(); // references to widgets we care about. - + Gtk::Dialog* m_new_session_dialog; Gtk::Entry* m_name; Gtk::FileChooserButton* m_folder; Gtk::FileChooserButton* m_template; @@ -113,6 +124,39 @@ protected: Gtk::RadioButton* m_connect_outputs_to_master; Gtk::RadioButton* m_connect_outputs_to_physical; + Gtk::Button* m_okbutton; + + Gtk::FileChooserButton* m_open_filechooser; + Gtk::TreeView* m_treeview; + Gtk::Notebook* m_notebook; + Gtk::ScrolledWindow* m_scrolledwindow; + private: + struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord { + RecentSessionModelColumns() { + add (visible_name); + add (fullpath); + } + Gtk::TreeModelColumn visible_name; + Gtk::TreeModelColumn fullpath; + }; + + RecentSessionModelColumns recent_columns; + Glib::RefPtr recent_model; + + void recent_session_selection_changed (); + void nsd_redisplay_recent_sessions(); + void nsd_recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col); + struct RecentSessionsSorter { + bool operator() (std::pair a, std::pair b) const { + return cmp_nocase(a.first, b.first) == -1; + } + }; + bool entry_key_release (GdkEventKey*); + void notebook_page_changed (GtkNotebookPage*, uint); + void treeview_selection_changed (); + void file_chosen (); + void recent_row_activated (const Gtk::TreePath&, Gtk::TreeViewColumn*); + };