13
0

Add browse button to recent session dialogue. Fixes #3357.

git-svn-id: svn://localhost/ardour2/branches/3.0@7498 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-07-26 01:55:08 +00:00
parent ecb5201332
commit 035de2a367
2 changed files with 101 additions and 21 deletions

View File

@ -1,3 +1,22 @@
/*
Copyright (C) 2010 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <fstream>
#include <algorithm>
@ -44,12 +63,13 @@ ArdourStartup::ArdourStartup ()
, monitor_via_hardware_button (_("Use an external mixer or the hardware mixer of your audio interface.\n\
Ardour will play NO role in monitoring"))
, monitor_via_ardour_button (string_compose (_("Ask %1 to playback material as it is being recorded"), PROGRAM_NAME))
, _have_setup_existing_session_page (false)
, new_folder_chooser (FILE_CHOOSER_ACTION_SELECT_FOLDER)
, more_new_session_options_button (_("I'd like more options for this session"))
, _output_limit_count_adj (1, 0, 100, 1, 10, 0)
, _input_limit_count_adj (1, 0, 100, 1, 10, 0)
, _master_bus_channel_count_adj (2, 0, 100, 1, 10, 0)
, _existing_session_chooser_used (false)
{
audio_page_index = -1;
initial_choice_index = -1;
@ -189,7 +209,12 @@ ArdourStartup::session_name (bool& should_be_new)
if (ic_new_session_button.get_active()) {
should_be_new = true;
return new_name_entry.get_text ();
} 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;
TreeIter iter = recent_session_display.get_selection()->get_selected();
@ -208,7 +233,11 @@ ArdourStartup::session_folder ()
if (ic_new_session_button.get_active()) {
Glib::ustring 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 */
TreeIter iter = recent_session_display.get_selection()->get_selected();
if (iter) {
@ -866,26 +895,25 @@ ArdourStartup::recent_session_row_selected ()
void
ArdourStartup::setup_existing_session_page ()
{
if (!session_hbox.get_children().empty()) {
session_hbox.remove (**session_hbox.get_children().begin());
}
if (recent_scroller.get_children().empty()) {
recent_session_model = TreeStore::create (recent_session_columns);
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_session_model = TreeStore::create (recent_session_columns);
redisplay_recent_sessions ();
if (_have_setup_existing_session_page) {
return;
}
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 ();
@ -895,9 +923,27 @@ ArdourStartup::setup_existing_session_page ()
recent_scroller.set_size_request (-1, 300);
}
session_hbox.pack_start (recent_scroller, true, true);
VBox* vbox = manage (new VBox);
vbox->set_spacing (8);
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));
HBox* hbox = manage (new HBox);
hbox->set_spacing (4);
hbox->pack_start (*manage (new Label (_("Browse:"))), PACK_SHRINK);
hbox->pack_start (existing_session_chooser);
vbox->pack_start (*hbox);
hbox->show_all ();
vbox->show_all ();
session_hbox.pack_start (*vbox, true, true);
set_page_title (session_vbox, _("Select a session"));
set_page_type (session_vbox, ASSISTANT_PAGE_CONFIRM);
_have_setup_existing_session_page = true;
}
void
@ -1227,3 +1273,12 @@ ArdourStartup::recent_row_activated (const Gtk::TreePath&, Gtk::TreeViewColumn*)
set_page_complete (session_vbox, true);
move_along_now ();
}
void
ArdourStartup::existing_session_selected ()
{
_existing_session_chooser_used = true;
set_page_complete (session_vbox, true);
move_along_now ();
}

View File

@ -1,3 +1,22 @@
/*
Copyright (C) 2010 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __gtk2_ardour_startup_h__
#define __gtk2_ardour_startup_h__
@ -122,6 +141,8 @@ class ArdourStartup : public Gtk::Assistant {
/* recent sessions */
void setup_existing_session_page ();
/** true when setup_existing_session_page () has already been called at least once */
bool _have_setup_existing_session_page;
struct RecentSessionsSorter {
bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
@ -142,10 +163,13 @@ class ArdourStartup : public Gtk::Assistant {
Gtk::TreeView recent_session_display;
Glib::RefPtr<Gtk::TreeStore> recent_session_model;
Gtk::ScrolledWindow recent_scroller;
Gtk::FileChooserButton existing_session_chooser;
int redisplay_recent_sessions ();
void recent_session_row_selected ();
void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
void existing_session_selected ();
/* audio setup page */
void setup_audio_page ();
@ -264,6 +288,7 @@ class ArdourStartup : public Gtk::Assistant {
void move_along_now ();
bool _existing_session_chooser_used; ///< set to true when the existing session chooser has been used
};
#endif /* __gtk2_ardour_startup_h__ */