New session dialog now opens as well as makes new sessions. Avoid seeing an ugly blank editor. Some dialog tweaks.
git-svn-id: svn://localhost/trunk/ardour2@467 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
d9343ed8bd
commit
484debb45c
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 = "");
|
||||
|
@ -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();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,19 @@
|
||||
#include "new_session_dialog.h"
|
||||
#include "glade_path.h"
|
||||
|
||||
#include <ardour/recent_sessions.h>
|
||||
#include <ardour/session.h>
|
||||
|
||||
#include <pbd/basename.h>
|
||||
|
||||
#include <gtkmm/entry.h>
|
||||
#include <gtkmm/filechooserbutton.h>
|
||||
#include <gtkmm/spinbutton.h>
|
||||
#include <gtkmm/checkbutton.h>
|
||||
#include <gtkmm/radiobutton.h>
|
||||
#include <gtkmm/filefilter.h>
|
||||
#include <gtkmm/stock.h>
|
||||
|
||||
|
||||
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<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_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()
|
||||
|
@ -25,6 +25,14 @@
|
||||
|
||||
#include <string>
|
||||
#include <gtkmm/dialog.h>
|
||||
#include <gtkmm/treeview.h>
|
||||
#include <gtkmm/treestore.h>
|
||||
#include <gtkmm/treepath.h>
|
||||
#include <gtkmm/scrolledwindow.h>
|
||||
#include <gtkmm/notebook.h>
|
||||
|
||||
#include <ardour/utils.h>
|
||||
|
||||
#include <glibmm/refptr.h>
|
||||
|
||||
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<std::string> visible_name;
|
||||
Gtk::TreeModelColumn<std::string> fullpath;
|
||||
};
|
||||
|
||||
RecentSessionModelColumns recent_columns;
|
||||
Glib::RefPtr<Gtk::TreeStore> 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<std::string,std::string> a, std::pair<std::string,std::string> 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*);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user