From c6509b8f86c29f05e64e98093fda7635ac951ebb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 19 Jul 2009 20:12:59 +0000 Subject: Restore add channel option to port matrix context menu. git-svn-id: svn://localhost/ardour2/branches/3.0@5383 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/bundle_manager.cc | 22 +++++++--------------- gtk2_ardour/bundle_manager.h | 3 ++- gtk2_ardour/global_port_matrix.h | 1 - gtk2_ardour/io_selector.cc | 25 ++++++++++++++++++++++--- gtk2_ardour/io_selector.h | 10 ++++++++-- gtk2_ardour/port_matrix.cc | 33 +++++++++++++++------------------ gtk2_ardour/port_matrix.h | 7 ++++++- gtk2_ardour/session_option_editor.cc | 1 - 8 files changed, 60 insertions(+), 42 deletions(-) diff --git a/gtk2_ardour/bundle_manager.cc b/gtk2_ardour/bundle_manager.cc index 16d9500d51..8fd7c05973 100644 --- a/gtk2_ardour/bundle_manager.cc +++ b/gtk2_ardour/bundle_manager.cc @@ -80,8 +80,14 @@ BundleEditorMatrix::get_state (ARDOUR::BundleChannel c[2]) const return PortMatrixNode::ASSOCIATED; } +std::string +BundleEditorMatrix::add_channel_name () const +{ + return _bundle->name (); +} + void -BundleEditorMatrix::add_channel (boost::shared_ptr b) +BundleEditorMatrix::add_channel () { NameChannelDialog d; d.set_position (Gtk::WIN_POS_MOUSE); @@ -178,20 +184,6 @@ BundleEditor::BundleEditor (ARDOUR::Session& session, boost::shared_ptrpack_start (_matrix); get_vbox()->set_spacing (4); - /* Add Channel button */ - Gtk::Button* add_channel_button = Gtk::manage (new Gtk::Button (_("Add Channel"))); - add_channel_button->set_name ("IOSelectorButton"); - add_channel_button->set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON))); - get_action_area()->pack_start (*add_channel_button, false, false); - add_channel_button->signal_clicked().connect (sigc::bind (sigc::mem_fun (_matrix, &BundleEditorMatrix::add_channel), boost::shared_ptr ())); - - if (add) { - add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button (Gtk::Stock::ADD, Gtk::RESPONSE_ACCEPT); - } else { - add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_ACCEPT); - } - show_all (); } diff --git a/gtk2_ardour/bundle_manager.h b/gtk2_ardour/bundle_manager.h index 035bc6ffac..e7ce049da5 100644 --- a/gtk2_ardour/bundle_manager.h +++ b/gtk2_ardour/bundle_manager.h @@ -39,7 +39,8 @@ class BundleEditorMatrix : public PortMatrix void set_state (ARDOUR::BundleChannel c[2], bool s); PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const; - void add_channel (boost::shared_ptr); + std::string add_channel_name () const; + void add_channel (); bool can_remove_channels (int d) const { return d == OURS; } diff --git a/gtk2_ardour/global_port_matrix.h b/gtk2_ardour/global_port_matrix.h index 1372c651f1..4f3bedd1fd 100644 --- a/gtk2_ardour/global_port_matrix.h +++ b/gtk2_ardour/global_port_matrix.h @@ -36,7 +36,6 @@ public: void set_state (ARDOUR::BundleChannel c[2], bool); PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const; - void add_channel (boost::shared_ptr) {} bool can_remove_channels (int d) const { return false; } diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc index 3c1e4c91ed..eab6ff9865 100644 --- a/gtk2_ardour/io_selector.cc +++ b/gtk2_ardour/io_selector.cc @@ -145,11 +145,15 @@ IOSelector::n_io_ports () const } } +string +IOSelector::add_channel_name () const +{ + return _io->name (); +} + void -IOSelector::add_channel (boost::shared_ptr b) +IOSelector::add_channel () { - /* we ignore the bundle parameter, as we know what it is that we're adding to */ - // The IO selector only works for single typed IOs const ARDOUR::DataType t = _io->default_type (); @@ -197,6 +201,8 @@ IOSelectorWindow::IOSelectorWindow (ARDOUR::Session& session, boost::shared_ptr< signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), this)); resize (32768, 32768); + + _selector.MaxSizeChanged.connect (mem_fun (*this, &IOSelectorWindow::max_size_changed)); } void @@ -226,7 +232,12 @@ void IOSelectorWindow::on_realize () { Window::on_realize (); + set_max_size (); +} +void +IOSelectorWindow::set_max_size () +{ pair const m = _selector.max_size (); GdkGeometry g; @@ -236,6 +247,14 @@ IOSelectorWindow::on_realize () set_geometry_hints (*this, g, Gdk::HINT_MAX_SIZE); } +void +IOSelectorWindow::max_size_changed () +{ + set_max_size (); + resize (32768, 32768); +} + + PortInsertUI::PortInsertUI (ARDOUR::Session& sess, boost::shared_ptr pi) : input_selector (sess, pi->input()) diff --git a/gtk2_ardour/io_selector.h b/gtk2_ardour/io_selector.h index eccdd91a26..fd5cb2fb50 100644 --- a/gtk2_ardour/io_selector.h +++ b/gtk2_ardour/io_selector.h @@ -36,10 +36,14 @@ class IOSelector : public PortMatrix void set_state (ARDOUR::BundleChannel c[2], bool); PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const; - void add_channel (boost::shared_ptr); + std::string add_channel_name () const; + + void add_channel (); + bool can_remove_channels (int d) const { return d == _ours; } + void remove_channel (ARDOUR::BundleChannel); bool can_rename_channels (int d) const { return false; @@ -67,7 +71,7 @@ class IOSelector : public PortMatrix } private: - + int _other; int _ours; boost::shared_ptr _io; @@ -90,6 +94,8 @@ class IOSelectorWindow : public Gtk::Window IOSelector _selector; void io_name_changed (void *src); + void set_max_size (); + void max_size_changed (); }; diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index 001d06081f..c535ef6769 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -264,6 +264,12 @@ PortMatrix::popup_menu ( char buf [64]; + std::string const n = add_channel_name (); + if (!n.empty()) { + snprintf (buf, sizeof (buf), _("Add channel to '%s'"), n.c_str()); + items.push_back (MenuElem (buf, mem_fun (*this, &PortMatrix::add_channel))); + } + for (int dim = 0; dim < 2; ++dim) { if (pg[dim]) { @@ -289,36 +295,28 @@ PortMatrix::popup_menu ( } if (bc[dim].bundle) { - bool have_one = false; - - if (can_rename_channels (dim)) { - snprintf (buf, sizeof (buf), _("Rename '%s'..."), bc[dim].bundle->channel_name (bc[dim].channel).c_str()); - boost::weak_ptr w (bc[dim].bundle); + boost::weak_ptr w (bc[dim].bundle); + + if (can_remove_channels (dim)) { + snprintf (buf, sizeof (buf), _("Remove '%s'"), bc[dim].bundle->channel_name (bc[dim].channel).c_str()); items.push_back ( MenuElem ( buf, - bind (mem_fun (*this, &PortMatrix::rename_channel_proxy), w, bc[dim].channel) + bind (mem_fun (*this, &PortMatrix::remove_channel_proxy), w, bc[dim].channel) ) ); - - have_one = true; - } + } - if (can_remove_channels (dim)) { - snprintf (buf, sizeof (buf), _("Remove '%s'"), bc[dim].bundle->channel_name (bc[dim].channel).c_str()); - boost::weak_ptr w (bc[dim].bundle); + if (can_rename_channels (dim)) { + snprintf (buf, sizeof (buf), _("Rename '%s'..."), bc[dim].bundle->channel_name (bc[dim].channel).c_str()); items.push_back ( MenuElem ( buf, - bind (mem_fun (*this, &PortMatrix::remove_channel_proxy), w, bc[dim].channel) + bind (mem_fun (*this, &PortMatrix::rename_channel_proxy), w, bc[dim].channel) ) ); - - have_one = true; } - boost::weak_ptr w (bc[dim].bundle); - if (_show_only_bundles) { snprintf (buf, sizeof (buf), _("%s all from '%s'"), disassociation_verb().c_str(), bc[dim].bundle->name().c_str()); } else { @@ -349,7 +347,6 @@ PortMatrix::popup_menu ( _menu->popup (1, t); } - void PortMatrix::remove_channel_proxy (boost::weak_ptr b, uint32_t c) { diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h index 885745aa6a..f2b45369c2 100644 --- a/gtk2_ardour/port_matrix.h +++ b/gtk2_ardour/port_matrix.h @@ -124,7 +124,12 @@ public: virtual PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const = 0; virtual bool list_is_global (int) const = 0; - virtual void add_channel (boost::shared_ptr) = 0; + /** If adding a channel is allowed in this situation, return the name of the + * thing that it would be added to. + * @return Name. + */ + virtual std::string add_channel_name () const { return ""; } + virtual void add_channel () {} virtual bool can_remove_channels (int) const = 0; virtual void remove_channel (ARDOUR::BundleChannel) = 0; virtual bool can_rename_channels (int) const = 0; diff --git a/gtk2_ardour/session_option_editor.cc b/gtk2_ardour/session_option_editor.cc index 5defe27e9d..cf7e856def 100644 --- a/gtk2_ardour/session_option_editor.cc +++ b/gtk2_ardour/session_option_editor.cc @@ -93,7 +93,6 @@ public: return (dim == OTHER); } - void add_channel (boost::shared_ptr) {} bool can_remove_channels (int) const { return false; } -- cgit v1.2.3