From 841147d9a7e48356d68f8e7c05f60ab1b537f6fc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 5 Sep 2010 20:41:48 +0000 Subject: [PATCH] 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 --- gtk2_ardour/processor_box.cc | 41 ++++++++++++++++++++++++++++++++---- gtk2_ardour/processor_box.h | 4 ++++ 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 ProcessorBox::paste_action; RefPtr ProcessorBox::cut_action; RefPtr ProcessorBox::rename_action; +RefPtr ProcessorBox::edit_action; Glib::RefPtr SendProcessorEntry::_slider; ProcessorEntry::ProcessorEntry (boost::shared_ptr 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) +{ + boost::shared_ptr at = boost::dynamic_pointer_cast (_route); + if (at && at->freeze_state() == AudioTrack::Frozen) { + return false; + } + + if ( + boost::dynamic_pointer_cast (processor) || + boost::dynamic_pointer_cast (processor) || + boost::dynamic_pointer_cast (processor) || + boost::dynamic_pointer_cast (processor) + ) { + return true; + } + + return false; +} + +bool +ProcessorBox::one_processor_can_be_edited () +{ + list selection = processor_display.selection (); + list::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) { @@ -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 cut_action; static Glib::RefPtr paste_action; static Glib::RefPtr rename_action; + static Glib::RefPtr edit_action; void paste_processor_state (const XMLNodeList&, boost::shared_ptr); void activate_processor (boost::shared_ptr); @@ -316,6 +317,9 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD std::list _processor_window_proxies; void set_processor_ui (boost::shared_ptr, Gtk::Window *); void maybe_add_processor_to_ui_list (boost::weak_ptr); + + bool one_processor_can_be_edited (); + bool processor_can_be_edited (boost::shared_ptr); }; #endif /* __ardour_gtk_processor_box__ */