summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-09-05 20:41:48 +0000
committerCarl Hetherington <carl@carlh.net>2010-09-05 20:41:48 +0000
commit841147d9a7e48356d68f8e7c05f60ab1b537f6fc (patch)
treea56f420d330a131daaa3d0367159fd90c71b5aee /gtk2_ardour
parent852ec4c77b76bf8acafdb533face9bb14a8d75a0 (diff)
Desensitize edit menu item in the processor box menu if there is nothing selected which can be edited.
git-svn-id: svn://localhost/ardour2/branches/3.0@7742 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/processor_box.cc41
-rw-r--r--gtk2_ardour/processor_box.h4
2 files changed, 41 insertions, 4 deletions
diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc
index fb421cab3d..ee32102c9b 100644
--- a/gtk2_ardour/processor_box.cc
+++ b/gtk2_ardour/processor_box.cc
@@ -89,6 +89,7 @@ ProcessorBox* ProcessorBox::_current_processor_box = 0;
RefPtr<Action> ProcessorBox::paste_action;
RefPtr<Action> ProcessorBox::cut_action;
RefPtr<Action> ProcessorBox::rename_action;
+RefPtr<Action> ProcessorBox::edit_action;
Glib::RefPtr<Gdk::Pixbuf> SendProcessorEntry::_slider;
ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
@@ -693,8 +694,9 @@ ProcessorBox::build_processor_menu ()
void
ProcessorBox::selection_changed ()
{
- bool sensitive = (processor_display.selection().empty()) ? false : true;
+ bool const sensitive = (processor_display.selection().empty()) ? false : true;
ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
+ edit_action->set_sensitive (one_processor_can_be_edited ());
/* disallow rename for multiple selections and for plugin inserts */
rename_action->set_sensitive (
@@ -1509,6 +1511,38 @@ ProcessorBox::clear_processors (Placement p)
}
}
+bool
+ProcessorBox::processor_can_be_edited (boost::shared_ptr<Processor> processor)
+{
+ boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (_route);
+ if (at && at->freeze_state() == AudioTrack::Frozen) {
+ return false;
+ }
+
+ if (
+ boost::dynamic_pointer_cast<Send> (processor) ||
+ boost::dynamic_pointer_cast<Return> (processor) ||
+ boost::dynamic_pointer_cast<PluginInsert> (processor) ||
+ boost::dynamic_pointer_cast<PortInsert> (processor)
+ ) {
+ return true;
+ }
+
+ return false;
+}
+
+bool
+ProcessorBox::one_processor_can_be_edited ()
+{
+ list<ProcessorEntry*> selection = processor_display.selection ();
+ list<ProcessorEntry*>::iterator i = selection.begin();
+ while (i != selection.end() && processor_can_be_edited ((*i)->processor()) == false) {
+ ++i;
+ }
+
+ return (i != selection.end());
+}
+
void
ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
{
@@ -1688,9 +1722,8 @@ ProcessorBox::register_actions ()
sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
/* show editors */
- act = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit..."),
- sigc::ptr_fun (ProcessorBox::rb_edit));
- ActionManager::plugin_selection_sensitive_actions.push_back(act);
+ edit_action = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit..."),
+ sigc::ptr_fun (ProcessorBox::rb_edit));
ActionManager::add_action_group (popup_act_grp);
}
diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h
index 80b0cd818a..d5382d37b2 100644
--- a/gtk2_ardour/processor_box.h
+++ b/gtk2_ardour/processor_box.h
@@ -277,6 +277,7 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD
static Glib::RefPtr<Gtk::Action> cut_action;
static Glib::RefPtr<Gtk::Action> paste_action;
static Glib::RefPtr<Gtk::Action> rename_action;
+ static Glib::RefPtr<Gtk::Action> edit_action;
void paste_processor_state (const XMLNodeList&, boost::shared_ptr<ARDOUR::Processor>);
void activate_processor (boost::shared_ptr<ARDOUR::Processor>);
@@ -316,6 +317,9 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD
std::list<ProcessorWindowProxy*> _processor_window_proxies;
void set_processor_ui (boost::shared_ptr<ARDOUR::Processor>, Gtk::Window *);
void maybe_add_processor_to_ui_list (boost::weak_ptr<ARDOUR::Processor>);
+
+ bool one_processor_can_be_edited ();
+ bool processor_can_be_edited (boost::shared_ptr<ARDOUR::Processor>);
};
#endif /* __ardour_gtk_processor_box__ */