Safeguard snapshot switch
Require double-click, and prompt user, before opening a session snapshot from the sidebar.
This commit is contained in:
parent
67f55d7b4e
commit
02b0ecdacb
@ -52,7 +52,7 @@ EditorSnapshots::EditorSnapshots ()
|
|||||||
{
|
{
|
||||||
_snapshot_model = ListStore::create (_columns);
|
_snapshot_model = ListStore::create (_columns);
|
||||||
_snapshot_display.set_model (_snapshot_model);
|
_snapshot_display.set_model (_snapshot_model);
|
||||||
_snapshot_display.append_column (_("Snapshot (click to load)"), _columns.visible_name);
|
_snapshot_display.append_column (_("Snapshot (dbl-click to load)"), _columns.visible_name);
|
||||||
_snapshot_display.append_column (_("Modified Date"), _columns.time_formatted);
|
_snapshot_display.append_column (_("Modified Date"), _columns.time_formatted);
|
||||||
_snapshot_display.set_size_request (75, -1);
|
_snapshot_display.set_size_request (75, -1);
|
||||||
_snapshot_display.set_headers_visible (true);
|
_snapshot_display.set_headers_visible (true);
|
||||||
@ -60,7 +60,6 @@ EditorSnapshots::EditorSnapshots ()
|
|||||||
_scroller.add (_snapshot_display);
|
_scroller.add (_snapshot_display);
|
||||||
_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
||||||
|
|
||||||
_snapshot_display.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &EditorSnapshots::selection_changed));
|
|
||||||
_snapshot_display.signal_button_press_event().connect (sigc::mem_fun (*this, &EditorSnapshots::button_press), false);
|
_snapshot_display.signal_button_press_event().connect (sigc::mem_fun (*this, &EditorSnapshots::button_press), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,31 +71,6 @@ EditorSnapshots::set_session (Session* s)
|
|||||||
redisplay ();
|
redisplay ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A new snapshot has been selected. */
|
|
||||||
void
|
|
||||||
EditorSnapshots::selection_changed ()
|
|
||||||
{
|
|
||||||
if (_snapshot_display.get_selection()->count_selected_rows() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TreeModel::iterator i = _snapshot_display.get_selection()->get_selected();
|
|
||||||
|
|
||||||
std::string snap_name = (*i)[_columns.real_name];
|
|
||||||
|
|
||||||
if (snap_name.length() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_session->snap_name() == snap_name) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_snapshot_display.set_sensitive (false);
|
|
||||||
ARDOUR_UI::instance()->load_session (_session->path(), string (snap_name));
|
|
||||||
_snapshot_display.set_sensitive (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
EditorSnapshots::button_press (GdkEventButton* ev)
|
EditorSnapshots::button_press (GdkEventButton* ev)
|
||||||
{
|
{
|
||||||
@ -115,6 +89,44 @@ EditorSnapshots::button_press (GdkEventButton* ev)
|
|||||||
popup_context_menu (ev->button, ev->time, row[_columns.real_name]);
|
popup_context_menu (ev->button, ev->time, row[_columns.real_name]);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} else if (ev->type == GDK_2BUTTON_PRESS) {
|
||||||
|
Gtk::TreeModel::Path path;
|
||||||
|
Gtk::TreeViewColumn* col;
|
||||||
|
int cx;
|
||||||
|
int cy;
|
||||||
|
string snap_name;
|
||||||
|
_snapshot_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, col, cx, cy);
|
||||||
|
Gtk::TreeModel::iterator iter = _snapshot_model->get_iter (path);
|
||||||
|
if (iter) {
|
||||||
|
Gtk::TreeModel::Row row = *iter;
|
||||||
|
snap_name = row[_columns.real_name];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (snap_name.length() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_session->snap_name() == snap_name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArdourDialog confirm (_("Load Snapshot?"), true);
|
||||||
|
Gtk::Label* m = Gtk::manage (new Gtk::Label (string_compose ("%1\n%2", _("Do you want to load this snapshot?"), snap_name)));
|
||||||
|
confirm.get_vbox()->pack_start (*m, true, true);
|
||||||
|
confirm.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||||
|
confirm.add_button (_("Yes, Load It"), Gtk::RESPONSE_ACCEPT);
|
||||||
|
confirm.show_all ();
|
||||||
|
switch (confirm.run()) {
|
||||||
|
case RESPONSE_ACCEPT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_snapshot_display.set_sensitive (false);
|
||||||
|
ARDOUR_UI::instance()->load_session (_session->path(), string (snap_name));
|
||||||
|
_snapshot_display.set_sensitive (true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,6 @@ private:
|
|||||||
Gtk::Menu _menu;
|
Gtk::Menu _menu;
|
||||||
|
|
||||||
bool button_press (GdkEventButton *);
|
bool button_press (GdkEventButton *);
|
||||||
void selection_changed ();
|
|
||||||
void popup_context_menu (int, int32_t, std::string);
|
void popup_context_menu (int, int32_t, std::string);
|
||||||
void remove (std::string);
|
void remove (std::string);
|
||||||
void rename (std::string);
|
void rename (std::string);
|
||||||
|
Loading…
Reference in New Issue
Block a user