summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-03-02 21:02:28 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-03-02 21:02:28 +0000
commit2c31494d846ff1dfa528323da1784e8573961456 (patch)
tree49bf1d22db495f18ff6906cfbb66a6d9af78cc12 /gtk2_ardour
parent6eccd043f22d9ddfa6418c4342e0a9fd5476a7dd (diff)
disable redirect cut operation in menu if it cannot be done (from carl)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4721 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/redirect_box.cc24
-rw-r--r--gtk2_ardour/redirect_box.h2
2 files changed, 24 insertions, 2 deletions
diff --git a/gtk2_ardour/redirect_box.cc b/gtk2_ardour/redirect_box.cc
index 2a696e2d2e..761426bb3c 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 bb00d820c3..f75ae0a078 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);