X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fardour_ui.cc;h=fcbb5b45028c770d912b6a6e49171f266a45ad85;hb=ba82e673fd4435065ae9689411d7ed0d232b8cde;hp=d6671205a77bf28b1151aaed9db5791e03db52bd;hpb=ac8f4baa002db37506a84088861b7a288dcdfae6;p=ardour.git diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index d6671205a7..fcbb5b4502 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -56,6 +56,7 @@ #include "pbd/compose.h" #include "pbd/convert.h" #include "pbd/failed_constructor.h" +#include "pbd/file_archive.h" #include "pbd/enumwriter.h" #include "pbd/memento_command.h" #include "pbd/openuri.h" @@ -162,6 +163,7 @@ typedef uint64_t microseconds_t; #include "route_params_ui.h" #include "save_as_dialog.h" #include "script_selector.h" +#include "session_archive_dialog.h" #include "session_dialog.h" #include "session_metadata_dialog.h" #include "session_option_editor.h" @@ -1069,6 +1071,45 @@ ARDOUR_UI::starting () } } + // TODO: maybe IFF brand_new_user + if (ARDOUR::Profile->get_mixbus () && Config->get_copy_demo_sessions ()) { + std::string dspd (Config->get_default_session_parent_dir()); + Searchpath ds (ARDOUR::ardour_data_search_path()); + ds.add_subdirectory_to_paths ("sessions"); + vector demos; + find_files_matching_pattern (demos, ds, "*.tar.xz"); + + ARDOUR::RecentSessions rs; + ARDOUR::read_recent_sessions (rs); + + for (vector::iterator i = demos.begin(); i != demos.end (); ++i) { + /* "demo-session" must be inside "demo-session.tar.xz" + * strip ".tar.xz" + */ + std::string name = basename_nosuffix (basename_nosuffix (*i)); + std::string path = Glib::build_filename (dspd, name); + /* skip if session-dir already exists */ + if (Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_DIR)) { + continue; + } + /* skip sessions that are already in 'recent'. + * eg. a new user changed shorly after installation + */ + for (ARDOUR::RecentSessions::iterator r = rs.begin(); r != rs.end(); ++r) { + if ((*r).first == name) { + continue; + } + } + try { + PBD::FileArchive ar (*i); + if (0 == ar.inflate (dspd)) { + store_recent_sessions (name, path); + info << string_compose (_("Copied Demo Session %1."), name) << endmsg; + } + } catch (...) {} + } + } + #ifdef NO_PLUGIN_STATE ARDOUR::RecentSessions rs; @@ -1284,6 +1325,10 @@ If you still wish to quit, please use the\n\n\ */ save_ardour_state (); + if (key_editor.get (false)) { + key_editor->disconnect (); + } + close_all_dialogs (); if (_session) { @@ -2654,6 +2699,32 @@ ARDOUR_UI::save_session_as () } } +void +ARDOUR_UI::archive_session () +{ + if (!_session) { + return; + } + + time_t n; + time (&n); + Glib::DateTime gdt (Glib::DateTime::create_now_local (n)); + + SessionArchiveDialog sad; + sad.set_name (_session->name() + gdt.format ("_%F_%H%M%S")); + int response = sad.run (); + + if (response != Gtk::RESPONSE_OK) { + sad.hide (); + return; + } + + if (_session->archive_session (sad.target_folder(), sad.name(), sad.encode_option (), sad.only_used_sources (), &sad)) { + MessageDialog msg (_("Session Archiving failed.")); + msg.run (); + } +} + void ARDOUR_UI::quick_snapshot_session (bool switch_to_it) { @@ -2731,14 +2802,8 @@ ARDOUR_UI::snapshot_session (bool switch_to_it) if (switch_to_it) { prompter.set_initial_text (_session->snap_name()); } else { - char timebuf[128]; - time_t n; - struct tm local_time; - - time (&n); - localtime_r (&n, &local_time); - strftime (timebuf, sizeof(timebuf), "%FT%H.%M.%S", &local_time); - prompter.set_initial_text (timebuf); + Glib::DateTime tm (g_date_time_new_now_local ()); + prompter.set_initial_text (tm.format ("%FT%H.%M.%S")); } bool finished = false; @@ -3969,7 +4034,7 @@ ARDOUR_UI::cleanup_peakfiles () } PresentationInfo::order_t -ARDOUR_UI::translate_order (AddRouteDialog::InsertAt place) +ARDOUR_UI::translate_order (RouteDialogs::InsertAt place) { if (editor->get_selection().tracks.empty()) { return PresentationInfo::max_order; @@ -3982,18 +4047,18 @@ ARDOUR_UI::translate_order (AddRouteDialog::InsertAt place) the highest order key in the selection + 1 (if available). */ - if (place == AddRouteDialog::AfterSelection) { + if (place == RouteDialogs::AfterSelection) { RouteTimeAxisView *rtav = dynamic_cast (editor->get_selection().tracks.back()); if (rtav) { order_hint = rtav->route()->presentation_info().order(); order_hint++; } - } else if (place == AddRouteDialog::BeforeSelection) { + } else if (place == RouteDialogs::BeforeSelection) { RouteTimeAxisView *rtav = dynamic_cast (editor->get_selection().tracks.front()); if (rtav) { order_hint = rtav->route()->presentation_info().order(); } - } else if (place == AddRouteDialog::First) { + } else if (place == RouteDialogs::First) { order_hint = 0; } else { /* leave order_hint at max_order */ @@ -4061,9 +4126,9 @@ ARDOUR_UI::add_route_dialog_finished (int r) if (!template_path.empty()) { if (add_route_dialog->name_template_is_default()) { - _session->new_route_from_template (count, template_path, string()); + _session->new_route_from_template (count, order, template_path, string()); } else { - _session->new_route_from_template (count, template_path, add_route_dialog->name_template()); + _session->new_route_from_template (count, order, template_path, add_route_dialog->name_template()); } return; } @@ -4986,16 +5051,21 @@ ARDOUR_UI::record_state_changed () { ENSURE_GUI_THREAD (*this, &ARDOUR_UI::record_state_changed); - if (!_session || !big_clock_window) { + if (!_session) { /* why bother - the clock isn't visible */ return; } - if (_session->record_status () == Session::Recording && _session->have_rec_enabled_track ()) { - big_clock->set_active (true); - } else { - big_clock->set_active (false); + ActionManager::set_sensitive (ActionManager::rec_sensitive_actions, !_session->actively_recording()); + + if (big_clock_window) { + if (_session->record_status () == Session::Recording && _session->have_rec_enabled_track ()) { + big_clock->set_active (true); + } else { + big_clock->set_active (false); + } } + } bool @@ -5397,16 +5467,16 @@ ARDOUR_UI::setup_toplevel_window (Gtk::Window& window, const string& name, void* if (window_icons.empty()) { Glib::RefPtr icon; - if ((icon = ::get_icon (PROGRAM_NAME "-icon_16px")) != 0) { + if ((icon = ::get_icon (PROGRAM_NAME "-icon_16px"))) { window_icons.push_back (icon); } - if ((icon = ::get_icon (PROGRAM_NAME "-icon_22px")) != 0) { + if ((icon = ::get_icon (PROGRAM_NAME "-icon_22px"))) { window_icons.push_back (icon); } - if ((icon = ::get_icon (PROGRAM_NAME "-icon_32px")) != 0) { + if ((icon = ::get_icon (PROGRAM_NAME "-icon_32px"))) { window_icons.push_back (icon); } - if ((icon = ::get_icon (PROGRAM_NAME "-icon_48px")) != 0) { + if ((icon = ::get_icon (PROGRAM_NAME "-icon_48px"))) { window_icons.push_back (icon); } } @@ -5664,3 +5734,55 @@ ARDOUR_UI::cancel_solo () _session->cancel_all_solo (); } } + +void +ARDOUR_UI::reset_focus (Gtk::Widget* w) +{ + /* this resets focus to the first focusable parent of the given widget, + * or, if there is no focusable parent, cancels focus in the toplevel + * window that the given widget is packed into (if there is one). + */ + + if (!w) { + return; + } + + Gtk::Widget* top = w->get_toplevel(); + + if (!top || !top->is_toplevel()) { + return; + } + + w = w->get_parent (); + + while (w) { + + if (w->is_toplevel()) { + /* Setting the focus widget to a Gtk::Window causes all + * subsequent calls to ::has_focus() on the nominal + * focus widget in that window to return + * false. Workaround: never set focus to the toplevel + * itself. + */ + break; + } + + if (w->get_can_focus ()) { + Gtk::Window* win = dynamic_cast (top); + win->set_focus (*w); + return; + } + w = w->get_parent (); + } + + if (top == &_main_window) { + + } + + /* no focusable parent found, cancel focus in top level window. + C++ API cannot be used for this. Thanks, references. + */ + + gtk_window_set_focus (GTK_WINDOW(top->gobj()), 0); + +}