Some fixes to the new session dialog.

git-svn-id: svn://localhost/trunk/ardour2@495 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Nick Mainsbridge 2006-05-10 10:22:38 +00:00
parent c67a576d61
commit 3732decd72
4 changed files with 85 additions and 81 deletions

View File

@ -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();

View File

@ -27,19 +27,6 @@
<widget class="GtkHButtonBox" id="hbuttonbox2">
<property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property>
<child>
<widget class="GtkButton" id="HelpButton">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-help</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-11</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="QuitButton">
<property name="visible">True</property>

View File

@ -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<string *> *sessions;
std::vector<string *>::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<std::string*>;
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<std::string*>* states;
std::vector<const gchar*> 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<std::string*>::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<string *> *sessions;
std::vector<string *>::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<std::string*>;
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<std::string*>* states;
std::vector<const gchar*> 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<std::string*>::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()
{

View File

@ -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;