From e8dc5539a049b421523533c68104a9a845d30175 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 7 Aug 2010 23:31:07 +0000 Subject: [PATCH] Use a ticked Lock item for markers rather than Lock / Unlock. Fixes #2136. git-svn-id: svn://localhost/ardour2/branches/3.0@7561 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.h | 4 ++-- gtk2_ardour/editor_markers.cc | 33 +++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 15758b97fb..27e20e698b 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1464,7 +1464,7 @@ public: void marker_menu_edit (); void marker_menu_remove (); void marker_menu_rename (); - void marker_menu_lock (bool yn); + void toggle_marker_menu_lock (); void marker_menu_hide (); void marker_menu_loop_range (); void marker_menu_select_all_selectables_using_range (); @@ -1486,7 +1486,7 @@ public: void transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*); void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*); void build_range_marker_menu (bool loop_or_punch); - void build_marker_menu (bool); + void build_marker_menu (bool, ARDOUR::Location *); void build_tempo_or_meter_marker_menu (bool); void build_new_transport_marker_menu (); void dynamic_cast_marker_object (void*, MeterMarker**, TempoMarker**) const; diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index ae11b5bfbe..0a17c072a7 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -535,13 +535,12 @@ Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item) if (loc->is_mark()) { Menu *markerMenu; if (loc->is_session_range ()) { - if (session_range_marker_menu == 0) { - build_marker_menu (true); - } + delete session_range_marker_menu; + build_marker_menu (true, loc); markerMenu = session_range_marker_menu; } else { - if (marker_menu == 0) - build_marker_menu (false); + delete marker_menu; + build_marker_menu (false, loc); markerMenu = marker_menu; } @@ -596,7 +595,7 @@ Editor::transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item*) } void -Editor::build_marker_menu (bool session_range) +Editor::build_marker_menu (bool session_range, Location* loc) { using namespace Menu_Helpers; @@ -622,9 +621,14 @@ Editor::build_marker_menu (bool session_range) return; } items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &Editor::marker_menu_rename))); - items.push_back (MenuElem (_("Lock"), sigc::bind (sigc::mem_fun(*this, &Editor::marker_menu_lock), true))); - items.push_back (MenuElem (_("Unlock"), sigc::bind (sigc::mem_fun(*this, &Editor::marker_menu_lock), false))); + items.push_back (CheckMenuElem (_("Lock"))); + CheckMenuItem* lock_item = static_cast (&items.back()); + if (loc->locked ()) { + lock_item->set_active (); + } + lock_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_lock)); + items.push_back (SeparatorElem()); items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove))); @@ -1029,9 +1033,8 @@ Editor::marker_menu_remove () } void -Editor::marker_menu_lock (bool yn) +Editor::toggle_marker_menu_lock () { - Marker* marker; if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { @@ -1044,12 +1047,14 @@ Editor::marker_menu_lock (bool yn) loc = find_location_from_marker (marker, ignored); - if (!loc) return; + if (!loc) { + return; + } - if (yn) { - loc->lock(); - } else { + if (loc->locked()) { loc->unlock (); + } else { + loc->lock (); } }