mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-23 07:06:23 +01:00
[Summary]: add Recent Session menuitems
This commit is contained in:
parent
d035ffdeb2
commit
a8d3424cf9
6 changed files with 169 additions and 4 deletions
|
|
@ -1416,6 +1416,92 @@ ARDOUR_UI::open_recent_session ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ARDOUR_UI::get_recent_session_names_and_paths(std::vector<std::string>& session_names,std::vector<std::string>& session_paths)
|
||||||
|
{
|
||||||
|
ARDOUR::RecentSessions rs;
|
||||||
|
ARDOUR::read_recent_sessions (rs);
|
||||||
|
|
||||||
|
/* after reading we should check that */
|
||||||
|
/* recent_session is still existing */
|
||||||
|
|
||||||
|
int i=0;
|
||||||
|
for (ARDOUR::RecentSessions::iterator it = rs.begin();
|
||||||
|
(i < MAX_RECENT_SESSION_COUNTS) && (it != rs.end());
|
||||||
|
++it)
|
||||||
|
{
|
||||||
|
std::vector<std::string> state_file_paths;
|
||||||
|
|
||||||
|
// now get available states for this session
|
||||||
|
|
||||||
|
get_state_files_in_directory ((*it).second, state_file_paths);
|
||||||
|
|
||||||
|
// vector<const gchar*> item;
|
||||||
|
string dirname = (*it).second;
|
||||||
|
|
||||||
|
/* remove any trailing / */
|
||||||
|
if (dirname[dirname.length()-1] == '/') {
|
||||||
|
dirname = dirname.substr (0, dirname.length()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check whether session still exists */
|
||||||
|
if (!Glib::file_test(dirname.c_str(), Glib::FILE_TEST_EXISTS)) {
|
||||||
|
/* session doesn't exist */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now get available states for this session */
|
||||||
|
|
||||||
|
vector<string> states;
|
||||||
|
states = Session::possible_states (dirname);
|
||||||
|
|
||||||
|
if (states.empty()) {
|
||||||
|
/* no state file? */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<string> state_file_names(get_file_names_no_extension (state_file_paths));
|
||||||
|
|
||||||
|
if (state_file_names.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
session_paths.push_back(Glib::build_filename((*it).second,state_file_names.front() + statefile_suffix) );
|
||||||
|
session_names.push_back(state_file_names.front());
|
||||||
|
//std::cout<<"state_file_names.front()= "<<state_file_names.front()<<std::endl;
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ARDOUR_UI::open_recent_session_from_menuitem(unsigned int num_of_recent_session)
|
||||||
|
{
|
||||||
|
std::string cur_recent_session_path=recent_session_full_paths[num_of_recent_session];
|
||||||
|
//std::cout<<"ARDOUR_UI::open_recent_session_from_menuitem: "<<cur_recent_session_path<<std::endl;
|
||||||
|
if (cur_recent_session_path== "")
|
||||||
|
return;
|
||||||
|
|
||||||
|
//check that cur_recent_session_path is still existing
|
||||||
|
if ( !Glib::file_test (cur_recent_session_path, Glib::FileTest (G_FILE_TEST_EXISTS)) )
|
||||||
|
{
|
||||||
|
WavesMessageDialog session_deleted ("",string_compose (_("There is no existing session at \"%1\""), cur_recent_session_path.c_str() ),WavesMessageDialog::BUTTON_OK);
|
||||||
|
session_deleted.run ();
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
string path, name;
|
||||||
|
bool isnew;
|
||||||
|
if (ARDOUR::find_session (cur_recent_session_path, path, name, isnew) == 0) {
|
||||||
|
_session_is_new = isnew;
|
||||||
|
load_session (path, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ARDOUR_UI::check_audioengine ()
|
ARDOUR_UI::check_audioengine ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -260,6 +260,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
||||||
void update_bit_depth_button ();
|
void update_bit_depth_button ();
|
||||||
void update_sample_rate_dropdown ();
|
void update_sample_rate_dropdown ();
|
||||||
void update_frame_rate_button ();
|
void update_frame_rate_button ();
|
||||||
|
void update_recent_session_menuitems();
|
||||||
|
|
||||||
PBD::ScopedConnectionList update_connections_to_toolbar_buttons;
|
PBD::ScopedConnectionList update_connections_to_toolbar_buttons;
|
||||||
|
|
||||||
|
|
@ -571,6 +572,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
||||||
return ARDOUR::cmp_nocase(a.first, b.first) == -1;
|
return ARDOUR::cmp_nocase(a.first, b.first) == -1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* opening recent sessions from menuitems */
|
||||||
|
void open_recent_session_from_menuitem (unsigned int);
|
||||||
|
|
||||||
/* menu bar and associated stuff */
|
/* menu bar and associated stuff */
|
||||||
|
|
||||||
|
|
@ -821,6 +825,16 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
||||||
Timecode::TimecodeFormat _timecode_format;
|
Timecode::TimecodeFormat _timecode_format;
|
||||||
|
|
||||||
PBD::ScopedConnection connection_with_session_config;
|
PBD::ScopedConnection connection_with_session_config;
|
||||||
|
|
||||||
|
//get names and paths of recent sessions
|
||||||
|
void get_recent_session_names_and_paths(std::vector<std::string>& session_names,std::vector<std::string>& session_paths);
|
||||||
|
|
||||||
|
//recent session menuitem id
|
||||||
|
const std::string recent_session_menuitem_id="recent-session-";
|
||||||
|
|
||||||
|
//full path to recent sessions
|
||||||
|
std::vector<std::string> recent_session_full_paths;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __ardour_gui_h__ */
|
#endif /* __ardour_gui_h__ */
|
||||||
|
|
|
||||||
|
|
@ -447,6 +447,47 @@ ARDOUR_UI::update_frame_rate_button ()
|
||||||
_frame_rate_button->set_text (timecode_format_string);
|
_frame_rate_button->set_text (timecode_format_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ARDOUR_UI::update_recent_session_menuitems ()
|
||||||
|
{
|
||||||
|
std::vector<std::string> recent_session_names;
|
||||||
|
recent_session_full_paths.clear();
|
||||||
|
get_recent_session_names_and_paths(recent_session_names,recent_session_full_paths);
|
||||||
|
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i=0;i<recent_session_names.size();++i){
|
||||||
|
Glib::RefPtr<Action> act;
|
||||||
|
|
||||||
|
std::string label=string_compose( ("%1%2"), recent_session_menuitem_id.c_str(),i ) ;
|
||||||
|
act=ActionManager::get_action_from_name(X_(label.c_str()));
|
||||||
|
|
||||||
|
// set label for existing recent session menuitem
|
||||||
|
act->set_label(X_(recent_session_names[i].c_str()));
|
||||||
|
|
||||||
|
/*
|
||||||
|
act->set_visible(true);
|
||||||
|
std::cout<<"i= "<<i<<" visible="<<act->get_visible()<<std::endl;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//hide empty recent_session_menuitems
|
||||||
|
for(;i<MAX_RECENT_SESSION_COUNTS;++i){
|
||||||
|
Glib::RefPtr<Action> act;
|
||||||
|
std::string label=recent_session_menuitem_id+string_compose ("%1", i);
|
||||||
|
act=ActionManager::get_action_from_name(X_(label.c_str()));
|
||||||
|
|
||||||
|
act->set_label(X_(""));
|
||||||
|
recent_session_full_paths.push_back("");
|
||||||
|
|
||||||
|
//act->set_visible(false);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ARDOUR_UI::install_actions ()
|
ARDOUR_UI::install_actions ()
|
||||||
{
|
{
|
||||||
|
|
@ -456,7 +497,8 @@ ARDOUR_UI::install_actions ()
|
||||||
|
|
||||||
/* menus + submenus that need action items */
|
/* menus + submenus that need action items */
|
||||||
|
|
||||||
ActionManager::register_action (main_menu_actions, X_("Session"), _("File"));
|
act=ActionManager::register_action (main_menu_actions, X_("Session"), _("File"));
|
||||||
|
ActionManager::session_sensitive_actions.push_back (act);
|
||||||
act = ActionManager::register_action (main_actions, X_("Cleanup"), _("CleanUp"));
|
act = ActionManager::register_action (main_actions, X_("Cleanup"), _("CleanUp"));
|
||||||
ActionManager::session_sensitive_actions.push_back (act);
|
ActionManager::session_sensitive_actions.push_back (act);
|
||||||
ActionManager::register_action (main_menu_actions, X_("Sync"), _("Sync"));
|
ActionManager::register_action (main_menu_actions, X_("Sync"), _("Sync"));
|
||||||
|
|
@ -481,7 +523,14 @@ ARDOUR_UI::install_actions ()
|
||||||
act = ActionManager::register_action (main_actions, X_("New"), _("New"), hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::get_session_parameters), false, true, "")));
|
act = ActionManager::register_action (main_actions, X_("New"), _("New"), hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::get_session_parameters), false, true, "")));
|
||||||
|
|
||||||
ActionManager::register_action (main_actions, X_("Open"), _("Open"), sigc::mem_fun(*this, &ARDOUR_UI::open_session));
|
ActionManager::register_action (main_actions, X_("Open"), _("Open"), sigc::mem_fun(*this, &ARDOUR_UI::open_session));
|
||||||
ActionManager::register_action (main_actions, X_("Recent"), _("Recent Sessions"), sigc::mem_fun(*this, &ARDOUR_UI::open_recent_session));
|
ActionManager::register_action (main_actions, X_("Recent"), _("Recent"), sigc::mem_fun(*this, &ARDOUR_UI::open_recent_session));
|
||||||
|
/* register act for recent_session_menuitems */
|
||||||
|
for(int i=0;i<MAX_RECENT_SESSION_COUNTS;++i){
|
||||||
|
std::string label=string_compose( ("%1%2"), recent_session_menuitem_id.c_str(),i ) ;
|
||||||
|
ActionManager::register_action (main_actions, X_(label.c_str()), _(""), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::open_recent_session_from_menuitem), i));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
act = ActionManager::register_action (main_actions, X_("Close"), _("Close"), sigc::mem_fun(*this, &ARDOUR_UI::close_session));
|
act = ActionManager::register_action (main_actions, X_("Close"), _("Close"), sigc::mem_fun(*this, &ARDOUR_UI::close_session));
|
||||||
ActionManager::session_sensitive_actions.push_back (act);
|
ActionManager::session_sensitive_actions.push_back (act);
|
||||||
|
|
||||||
|
|
@ -553,8 +602,7 @@ ARDOUR_UI::install_actions ()
|
||||||
act = ActionManager::register_action (main_actions, X_("ShowUnused"), _("Show Unused"), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::open_dead_folder));
|
act = ActionManager::register_action (main_actions, X_("ShowUnused"), _("Show Unused"), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::open_dead_folder));
|
||||||
//ActionManager::session_sensitive_actions.push_back (act);
|
//ActionManager::session_sensitive_actions.push_back (act);
|
||||||
|
|
||||||
ActionManager::write_sensitive_actions.push_back (act);
|
ActionManager::register_action (main_actions, X_("recent-sessions"), _("Recent Sessions"));
|
||||||
|
|
||||||
act = ActionManager::register_action (main_actions, X_("FlushWastebasket"), _("Flush Wastebasket"), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::flush_trash));
|
act = ActionManager::register_action (main_actions, X_("FlushWastebasket"), _("Flush Wastebasket"), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::flush_trash));
|
||||||
ActionManager::write_sensitive_actions.push_back (act);
|
ActionManager::write_sensitive_actions.push_back (act);
|
||||||
ActionManager::session_sensitive_actions.push_back (act);
|
ActionManager::session_sensitive_actions.push_back (act);
|
||||||
|
|
|
||||||
|
|
@ -1527,6 +1527,10 @@ Editor::set_session (Session *t)
|
||||||
_master_bus_ui->master_bus_set_visible ( set_master_bus_visible );
|
_master_bus_ui->master_bus_set_visible ( set_master_bus_visible );
|
||||||
|
|
||||||
_set_session_in_progress = false;
|
_set_session_in_progress = false;
|
||||||
|
|
||||||
|
/* it is neccessary to update recent session menuitems */
|
||||||
|
/* because new session could be created */
|
||||||
|
ARDOUR_UI::instance()->update_recent_session_menuitems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,7 @@ SessionDialog::redisplay_recent_sessions ()
|
||||||
++session_snapshot_count;
|
++session_snapshot_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ARDOUR_UI::instance()->update_recent_session_menuitems();
|
||||||
return session_snapshot_count;
|
return session_snapshot_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,18 @@
|
||||||
<menuitem action='SaveAs'/>
|
<menuitem action='SaveAs'/>
|
||||||
<menuitem action='Close'/>
|
<menuitem action='Close'/>
|
||||||
<menuitem action='Recent'/>
|
<menuitem action='Recent'/>
|
||||||
|
<menu name='recent-sessions' action='recent-sessions'>
|
||||||
|
<menuitem action='recent-session-0'/>
|
||||||
|
<menuitem action='recent-session-1'/>
|
||||||
|
<menuitem action='recent-session-2'/>
|
||||||
|
<menuitem action='recent-session-3'/>
|
||||||
|
<menuitem action='recent-session-4'/>
|
||||||
|
<menuitem action='recent-session-5'/>
|
||||||
|
<menuitem action='recent-session-6'/>
|
||||||
|
<menuitem action='recent-session-7'/>
|
||||||
|
<menuitem action='recent-session-8'/>
|
||||||
|
<menuitem action='recent-session-9'/>
|
||||||
|
</menu>
|
||||||
<separator/>
|
<separator/>
|
||||||
<menuitem action='toggle-tracks-control-panel'/>
|
<menuitem action='toggle-tracks-control-panel'/>
|
||||||
<separator/>
|
<separator/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue