[Summary] Implementation of the AUTO LOCK TIMER and minor improvement of session_lock_dialog

[Review] GZharun
This commit is contained in:
nikolay 2014-07-03 17:52:57 +03:00
parent 1bdf3a8bda
commit f28dcaa77f
12 changed files with 133 additions and 64 deletions

View file

@ -386,6 +386,8 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
WM::Manager::instance().register_window (&audio_port_matrix);
WM::Manager::instance().register_window (&midi_port_matrix);
session_lock_dialog->set_deletable (false);
/* We need to instantiate the theme manager because it loads our
theme files. This should really change so that its window
and its functionality are separate
@ -2271,11 +2273,30 @@ ARDOUR_UI::stop_blinking ()
}
}
void
ARDOUR_UI::on_lock_button_pressed () {
lock_button_was_pressed();
}
void
ARDOUR_UI::lock_session () {
if( screen_lock_is_allowed () )
session_lock_dialog->run ();
}
bool
ARDOUR_UI::screen_lock_is_allowed() const
{
if(!_session)
return false;
if( (_session->record_status() == Session::Recording) && (ARDOUR_UI::config()->get_auto_lock_timer () != 0) )
return true;
else
return false;
}
/** Ask the user for the name of a new snapshot and then take it.
*/

View file

@ -168,6 +168,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
/// @return true if session was successfully unloaded.
int unload_session (bool hide_stuff = false);
void close_session();
void lock_session ();
int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
void save_state (const std::string & state_name = "", bool switch_to_it = false);
@ -308,6 +309,10 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
void set_header_format(ARDOUR::HeaderFormat hf) {_header_format = hf;}
void set_timecode_format(Timecode::TimecodeFormat tc) {_timecode_format = tc;}
bool screen_lock_is_allowed() const;
void on_lock_button_pressed ();
PBD::Signal0<void> lock_button_was_pressed;
protected:
friend class PublicEditor;
@ -604,7 +609,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
guint32 last_key_press_time;
void lock_session ();
void snapshot_session (bool switch_to_it);
void rename_session ();
void setup_order_hint ();

View file

@ -143,7 +143,7 @@ ARDOUR_UI::install_actions ()
hide_return (sigc::bind (sigc::mem_fun(*editor, &PublicEditor::export_video), false)));
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::register_action (main_actions, X_("LockSession"), _("Lock this session"), sigc::mem_fun(*this, &ARDOUR_UI::lock_session));
ActionManager::register_action (main_actions, X_("LockSession"), _("Lock this session"), sigc::mem_fun(*this, &ARDOUR_UI::on_lock_button_pressed));
ActionManager::register_action (main_actions, X_("ToggleMultiOutMode"), "Multi Out", sigc::mem_fun(*this, &ARDOUR_UI::toggle_multi_out_mode));
ActionManager::register_action (main_actions, X_("ToggleStereoOutMode"), "Stereo Out", sigc::mem_fun(*this, &ARDOUR_UI::toggle_stereo_out_mode));

View file

@ -314,7 +314,7 @@ Editor::Editor ()
last_update_frame = 0;
pre_press_cursor = 0;
_drags = new DragManager (this);
lock_dialog = 0;
current_mixer_strip = 0;
tempo_lines = 0;
@ -759,6 +759,11 @@ Editor::Editor ()
Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Editor::parameter_changed, this, _1), gui_context());
ARDOUR_UI::config()->ParameterChanged.connect (sigc::mem_fun (*this, &Editor::on_ardour_ui_config_changed));
ARDOUR_UI* ardour_ui = ARDOUR_UI::instance();
ardour_ui->lock_button_was_pressed.connect( *this, invalidator (*this), boost::bind (&Editor::lock, this), gui_context() );
TimeAxisView::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Editor::timeaxisview_deleted, this, _1), gui_context());
_ignore_region_action = false;
@ -1131,16 +1136,32 @@ Editor::on_realize ()
Window::on_realize ();
Realized ();
start_lock_event_timing ();
signal_event().connect (sigc::mem_fun (*this, &Editor::generic_event_handler));
}
// Update lock time
void
Editor::on_ardour_ui_config_changed(const std::string& param)
{
if (param=="auto-lock-timer" && ARDOUR_UI::instance()->screen_lock_is_allowed())
{
start_lock_event_timing();
}
}
void
Editor::start_lock_event_timing ()
{
/* check if we should lock the GUI every 30 seconds */
Glib::signal_timeout().connect (sigc::mem_fun (*this, &Editor::lock_timeout_callback), 30 * 1000);
ARDOUR_UI* ardour_ui = ARDOUR_UI::instance();
timeout_connection.disconnect();
if( !ardour_ui->screen_lock_is_allowed() )
return;
gettimeofday(&last_event_time, 0);
timeout_connection = Glib::signal_timeout().connect (sigc::mem_fun (*this, &Editor::lock_timeout_callback), 1 * 1000);
}
bool
@ -1164,13 +1185,16 @@ bool
Editor::lock_timeout_callback ()
{
struct timeval now, delta;
const uint32_t lock_timeout_secs = 5; /* 2 minutes */
gettimeofday (&now, 0);
timersub (&now, &last_event_time, &delta);
if (delta.tv_sec > lock_timeout_secs) {
if( !ARDOUR_UI::instance()->screen_lock_is_allowed() )
return false; // Returning false will effectively disconnect us from the timer callback.
if (delta.tv_sec > ARDOUR_UI::config()->get_auto_lock_timer ())
{
lock ();
/* don't call again. Returning false will effectively
disconnect us from the timer callback.
@ -1338,6 +1362,7 @@ Editor::set_session (Session *t)
_session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::refresh_location_display, this), gui_context());
_session->locations()->StateChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::refresh_location_display, this), gui_context());
_session->history().Changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::history_changed, this), gui_context());
_session->RecordStateChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&Editor::start_lock_event_timing, this), gui_context());
playhead_cursor->show ();

View file

@ -1359,15 +1359,18 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
DragManager* _drags;
void escape ();
void lock ();
void unlock ();
/* This dialog must NOT forward events */
Gtk::Dialog *lock_dialog;
struct timeval last_event_time;
bool generic_event_handler (GdkEvent*);
sigc::connection timeout_connection;
bool lock_timeout_callback ();
void start_lock_event_timing ();
void on_ardour_ui_config_changed (const std::string&);
Gtk::Menu fade_context_menu;
void popup_fade_context_menu (int, int, ArdourCanvas::Item*, ItemType);

View file

@ -7066,25 +7066,6 @@ Editor::toggle_midi_input_active (bool flip_others)
void
Editor::lock ()
{
if (!lock_dialog) {
/* the lock dialog must be a completely "vanilla" Dialog that does not forward
events in anyway. Using a class like ArdourDialog breaks this.
*/
lock_dialog = new Gtk::Dialog (string_compose (_("%1: Locked"), PROGRAM_NAME), true);
Gtk::Image* padlock = manage (new Gtk::Image (::get_icon ("padlock_closed")));
lock_dialog->get_vbox()->pack_start (*padlock);
ArdourButton* b = manage (new ArdourButton);
b->set_name ("lock button");
b->set_markup (string_compose ("<span size=\"large\" weight=\"bold\">%1</span>", _("Click to unlock")));
b->signal_clicked.connect (sigc::mem_fun (*this, &Editor::unlock));
lock_dialog->get_vbox()->pack_start (*b);
lock_dialog->get_vbox()->show_all ();
lock_dialog->set_size_request (200, 200);
}
#ifdef __APPLE__
/* The global menu bar continues to be accessible to applications
with modal dialogs, which means that we need to desensitize
@ -7093,13 +7074,10 @@ Editor::lock ()
*/
ActionManager::disable_all_actions ();
#endif
lock_dialog->present ();
}
void
Editor::unlock ()
{
lock_dialog->hide ();
timeout_connection.disconnect();
ARDOUR_UI::instance()->lock_session();
#ifdef __APPLE__
ActionManager::pop_action_state ();

View file

@ -93,6 +93,7 @@ TracksControlPanel::TracksControlPanel ()
, _bit_depth_combo (get_combo_box_text ("bit_depth_combo"))
, _frame_rate_combo (get_combo_box_text ("frame_rate_combo"))
, _browse_button(get_waves_button("browse_default_folder"))
, _auto_lock_timer_spin_button(get_spin_button("auto_lock_timer_spin_button"))
, _have_control (false)
, _ignore_changes (0)
{

View file

@ -76,6 +76,7 @@ class TracksControlPanel : public WavesDialog, public PBD::ScopedConnectionList
Gtk::ComboBoxText& _frame_rate_combo;
Gtk::Label& _latency_label;
Gtk::Label& _default_open_path;
Gtk::SpinButton& _auto_lock_timer_spin_button;
#include "tracks_control_panel.logic.h"
};

View file

@ -578,6 +578,18 @@ TracksControlPanel::refresh_session_settings_info()
void
TracksControlPanel::populate_auto_lock_timer()
{
using namespace std;
using namespace Gtk;
_auto_lock_timer_spin_button.set_max_length(3);
_auto_lock_timer_spin_button.set_numeric(true);
_auto_lock_timer_spin_button.set_update_policy(UPDATE_ALWAYS);
_auto_lock_timer_spin_button.set_range(0, 999);
_auto_lock_timer_spin_button.set_increments(1,1);
int time = ARDOUR_UI::config()->get_auto_lock_timer();
_auto_lock_timer_spin_button.set_value(time);
}
void
@ -1247,6 +1259,18 @@ TracksControlPanel::save_default_session_path()
}
}
void
TracksControlPanel::save_auto_lock_time()
{
using namespace std;
string s = _auto_lock_timer_spin_button.get_text();
int time = atoi(s);
ARDOUR_UI::config()->set_auto_lock_timer(time);
ARDOUR_UI::config()->save_state();
}
void TracksControlPanel::update_session_config ()
{
ARDOUR_UI* ardour_ui = ARDOUR_UI::instance();
@ -1264,6 +1288,17 @@ void TracksControlPanel::update_session_config ()
}
}
void
TracksControlPanel::update_configs()
{
// update session config
update_session_config();
// update global config
save_default_session_path();
save_auto_lock_time();
}
void
TracksControlPanel::on_ok (WavesButton*)
{
@ -1271,8 +1306,7 @@ TracksControlPanel::on_ok (WavesButton*)
EngineStateController::instance()->push_current_state_to_backend(true);
response(Gtk::RESPONSE_OK);
update_session_config();
save_default_session_path();
update_configs();
}
@ -1291,8 +1325,7 @@ TracksControlPanel::on_apply (WavesButton*)
EngineStateController::instance()->push_current_state_to_backend(true);
//response(Gtk::RESPONSE_APPLY);
update_session_config();
save_default_session_path();
update_configs();
}

View file

@ -55,9 +55,11 @@
void on_stereo_out (WavesButton*);
void on_browse_button (WavesButton*);
void save_default_session_path();
void save_auto_lock_time();
void on_ok(WavesButton*);
void on_cancel(WavesButton*);
void on_apply(WavesButton*);
void update_configs();
void update_session_config();
void on_capture_active_changed (DeviceConnectionControl* capture_control, bool active);
void on_playback_active_changed (DeviceConnectionControl* playback_control, bool active);

View file

@ -239,7 +239,7 @@
<Label style="generic_control" text="SESSION FRAME RATE" x="24" y="100"/>
<ComboBoxText style="generic_control" id="frame_rate_combo" x="215" y="100" width="150" height="20" />
<Label style="generic_control" text="AUTO LOCK TIMER" x="24" y="175"/>
<ComboBoxText style="generic_control" id="auto_lock_timer_combo" x="215" y="175" width="150" height="20" />
<SpinButton style="generic_control" id="auto_lock_timer_spin_button" x="215" y="175" width="150" height="20" />
<Label style="generic_control" text="DEFAULT FOLDER FOR NEW SESSION" x = "24" y = "230" />
<Button

View file

@ -24,4 +24,5 @@ UI_CONFIG_VARIABLE(float, timeline_item_gradient_depth, "timeline-item-gradient-
UI_CONFIG_VARIABLE(bool, all_floating_windows_are_dialogs, "all-floating-windows-are-dialogs", false)
UI_CONFIG_VARIABLE (bool, color_regions_using_track_color, "color-regions-using-track-color", false)
UI_CONFIG_VARIABLE (bool, show_waveform_clipping, "show-waveform-clipping", true)
UI_CONFIG_VARIABLE (int, auto_lock_timer, "auto-lock-timer", 0)