View Issue Details

IDProjectCategoryView StatusLast Update
0002483ardourbugspublic2020-04-19 20:13
Reportercth103 Assigned Topaul  
PrioritylowSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product VersionSVN/2.0-ongoing 
Summary0002483: Redirect cut menu option should be disabled if it is not appropriate
DescriptionThe redirect box menu has a cut option which only operates on plugins. I think this should be disabled if no plugins are selected. The attached patch implements this.
TagsNo tags attached.

Activities

2008-12-06 13:18

 

disable-cut.patch (2,922 bytes)   
diff --git a/gtk2_ardour/redirect_box.cc b/gtk2_ardour/redirect_box.cc
index 2a696e2..761426b 100644
--- a/gtk2_ardour/redirect_box.cc
+++ b/gtk2_ardour/redirect_box.cc
@@ -78,6 +78,7 @@ using namespace Glib;
 using namespace Gtkmm2ext;
 
 RedirectBox* RedirectBox::_current_redirect_box = 0;
+RefPtr<Action> RedirectBox::cut_action;
 RefPtr<Action> RedirectBox::paste_action;
 bool RedirectBox::get_colors = true;
 Gdk::Color* RedirectBox::active_redirect_color;
@@ -254,6 +255,8 @@ RedirectBox::show_redirect_menu (gint arg)
 		plugin_menu_item->set_submenu (_plugin_selector.plugin_menu());
 	}
 
+	cut_action->set_sensitive (can_cut_redirects ());
+	
 	paste_action->set_sensitive (!_rr_selection.redirects.empty());
 
 	redirect_menu->popup (1, arg);
@@ -762,6 +765,23 @@ RedirectBox::rename_redirects ()
 	}
 }
 
+bool
+RedirectBox::can_cut_redirects ()
+{
+	vector<boost::shared_ptr<Redirect> > sel;
+	get_selected_redirects (sel);
+	
+	/* cut_redirects () does not cut inserts or sends */
+	for (vector<boost::shared_ptr<Redirect> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
+
+		if (boost::dynamic_pointer_cast<PluginInsert>(*i) != 0) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
 void
 RedirectBox::cut_redirects ()
 {
@@ -1206,8 +1226,8 @@ RedirectBox::register_actions ()
 	ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear"),  sigc::ptr_fun (RedirectBox::rb_clear));
 
 	/* standard editing stuff */
-	act = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),  sigc::ptr_fun (RedirectBox::rb_cut));
-	ActionManager::plugin_selection_sensitive_actions.push_back(act);
+	cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),  sigc::ptr_fun (RedirectBox::rb_cut));
+	ActionManager::plugin_selection_sensitive_actions.push_back (cut_action);
 	act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),  sigc::ptr_fun (RedirectBox::rb_copy));
 	ActionManager::plugin_selection_sensitive_actions.push_back(act);
 
diff --git a/gtk2_ardour/redirect_box.h b/gtk2_ardour/redirect_box.h
index bb00d82..f75ae0a 100644
--- a/gtk2_ardour/redirect_box.h
+++ b/gtk2_ardour/redirect_box.h
@@ -99,6 +99,7 @@ class RedirectBox : public Gtk::HBox, public PluginInterestedObject
 	RouteRedirectSelection  & _rr_selection;
 
 	void route_going_away ();
+	bool can_cut_redirects ();
 
 	struct ModelColumns : public Gtk::TreeModel::ColumnRecord {
 	    ModelColumns () {
@@ -183,6 +184,7 @@ class RedirectBox : public Gtk::HBox, public PluginInterestedObject
 	void for_selected_redirects (void (RedirectBox::*pmf)(boost::shared_ptr<ARDOUR::Redirect>));
 	void get_selected_redirects (vector<boost::shared_ptr<ARDOUR::Redirect> >&);
 
+	static Glib::RefPtr<Gtk::Action> cut_action;
 	static Glib::RefPtr<Gtk::Action> paste_action;
 	void paste_redirect_list (const std::list<boost::shared_ptr<ARDOUR::Redirect> >& redirects);
 	
disable-cut.patch (2,922 bytes)   

paul

2009-03-02 21:02

administrator   ~0005786

committed in rev 4721. carl, is something similar needed for 3.0?

system

2020-04-19 20:13

developer   ~0021835

Issue has been closed automatically, by Trigger Close Plugin.
Feel free to re-open with additional information if you think the issue is not resolved.

Issue History

Date Modified Username Field Change
2008-12-06 13:18 cth103 New Issue
2008-12-06 13:18 cth103 File Added: disable-cut.patch
2008-12-06 13:18 cth103 cost => 0.00
2008-12-06 13:19 cth103 Status new => assigned
2008-12-06 13:19 cth103 Assigned To => paul
2009-03-02 21:02 paul Status assigned => resolved
2009-03-02 21:02 paul Resolution open => fixed
2009-03-02 21:02 paul Note Added: 0005786
2020-04-19 20:13 system Note Added: 0021835
2020-04-19 20:13 system Status resolved => closed