summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-04-06 12:57:41 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-04-06 12:57:41 +0000
commitf388715a5937bdb30b221d31606ffa0d1b58c8f3 (patch)
tree1bcbf42e2444efc8872ee2171e3be3b0826f2300 /gtk2_ardour
parent0eafb1f3005d0ddf9f8ce8c6bde30f0ac641aa61 (diff)
don't let auditioning make transport buttons inaccessible; delete/rename snapshots (from carl & puddingpimp)
git-svn-id: svn://localhost/ardour2/trunk@1673 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/ardour_ui.cc2
-rw-r--r--gtk2_ardour/editor.cc92
-rw-r--r--gtk2_ardour/editor.h4
-rw-r--r--gtk2_ardour/editor_mouse.cc6
-rw-r--r--gtk2_ardour/editor_rulers.cc5
5 files changed, 107 insertions, 2 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index e450fb8c93..0eccc14b0f 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -1537,6 +1537,8 @@ ARDOUR_UI::name_io_setup (AudioEngine& engine,
}
}
+/** Ask the user for the name of a new shapshot and then take it.
+ */
void
ARDOUR_UI::snapshot_session ()
{
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 885b3027c4..8e711a3905 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -40,6 +40,7 @@
#include <gtkmm2ext/tearoff.h>
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/window_title.h>
+#include <gtkmm2ext/choice.h>
#include <ardour/audio_track.h>
#include <ardour/audio_diskstream.h>
@@ -3372,6 +3373,9 @@ Editor::control_layout_scroll (GdkEventScroll* ev)
return false;
}
+
+/** A new snapshot has been selected.
+ */
void
Editor::snapshot_display_selection_changed ()
{
@@ -3396,7 +3400,93 @@ Editor::snapshot_display_selection_changed ()
bool
Editor::snapshot_display_button_press (GdkEventButton* ev)
{
- return false;
+ if (ev->button == 3) {
+ /* Right-click on the snapshot list. Work out which snapshot it
+ was over. */
+ Gtk::TreeModel::Path path;
+ Gtk::TreeViewColumn* col;
+ int cx;
+ int cy;
+ snapshot_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, col, cx, cy);
+ Gtk::TreeModel::iterator iter = snapshot_display_model->get_iter (path);
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ popup_snapshot_context_menu (ev->button, ev->time, row[snapshot_display_columns.real_name]);
+ }
+ return true;
+ }
+
+ return false;
+}
+
+
+/** Pop up the snapshot display context menu.
+ * @param button Button used to open the menu.
+ * @param time Menu open time.
+ * @snapshot_name Name of the snapshot that the menu click was over.
+ */
+
+void
+Editor::popup_snapshot_context_menu (int button, int32_t time, Glib::ustring snapshot_name)
+{
+ using namespace Menu_Helpers;
+
+ MenuList& items (snapshot_context_menu.items());
+ items.clear ();
+
+ const bool modification_allowed = (session->snap_name() != snapshot_name && session->name() != snapshot_name);
+
+ items.push_back (MenuElem (_("Remove"), bind (mem_fun (*this, &Editor::remove_snapshot), snapshot_name)));
+ if (!modification_allowed) {
+ items.back().set_sensitive (false);
+ }
+
+ items.push_back (MenuElem (_("Rename"), bind (mem_fun (*this, &Editor::rename_snapshot), snapshot_name)));
+ if (!modification_allowed) {
+ items.back().set_sensitive (false);
+ }
+
+ snapshot_context_menu.popup (button, time);
+}
+
+void
+Editor::rename_snapshot (Glib::ustring old_name)
+{
+ ArdourPrompter prompter(true);
+
+ string new_name;
+
+ prompter.set_name ("Prompter");
+ prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
+ prompter.set_prompt (_("New name of snapshot"));
+ prompter.set_initial_text (old_name);
+
+ if (prompter.run() == RESPONSE_ACCEPT) {
+ prompter.get_result (new_name);
+ if (new_name.length()) {
+ session->rename_state (old_name, new_name);
+ redisplay_snapshots ();
+ }
+ }
+}
+
+
+void
+Editor::remove_snapshot (Glib::ustring name)
+{
+ vector<string> choices;
+
+ std::string prompt = string_compose (_("Do you really want to remove snapshot \"%1\" ?\n(cannot be undone)"), name);
+
+ choices.push_back (_("No, do nothing."));
+ choices.push_back (_("Yes, remove it."));
+
+ Gtkmm2ext::Choice prompter (prompt, choices);
+
+ if (prompter.run () == 1) {
+ session->remove_state (name);
+ redisplay_snapshots ();
+ }
}
void
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index fd3ecee508..800139f810 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -770,10 +770,12 @@ class Editor : public PublicEditor
SnapshotDisplayModelColumns snapshot_display_columns;
Glib::RefPtr<Gtk::ListStore> snapshot_display_model;
Gtk::TreeView snapshot_display;
+ Gtk::Menu snapshot_context_menu;
bool snapshot_display_button_press (GdkEventButton*);
void snapshot_display_selection_changed ();
void redisplay_snapshots();
+ void popup_snapshot_context_menu (int, int32_t, Glib::ustring);
/* named selections */
@@ -795,6 +797,8 @@ class Editor : public PublicEditor
void create_named_selection ();
void paste_named_selection (float times);
void remove_selected_named_selections ();
+ void remove_snapshot (Glib::ustring);
+ void rename_snapshot (Glib::ustring);
void handle_new_named_selection ();
void add_named_selection_to_named_selection_display (ARDOUR::NamedSelection&);
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index 356504d809..b5c8042672 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -1922,7 +1922,11 @@ Editor::start_cursor_grab (ArdourCanvas::Item* item, GdkEvent* event)
if (session && drag_info.was_rolling) {
session->request_stop ();
- }
+ }
+
+ if (session && session->is_auditioning()) {
+ session->cancel_audition ();
+ }
}
drag_info.pointer_frame_offset = drag_info.grab_frame - cursor->current_frame;
diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc
index 1a928002a8..6338993ae2 100644
--- a/gtk2_ardour/editor_rulers.cc
+++ b/gtk2_ardour/editor_rulers.cc
@@ -151,6 +151,11 @@ Editor::ruler_button_press (GdkEventButton* ev)
switch (ev->button) {
case 1:
+ // Since we are about to move the playhead, cancel any running
+ // auditions.
+ if (session->is_auditioning()) {
+ session->cancel_audition ();
+ }
/* transport playhead */
snap_to (where);
session->request_locate (where);