Fix thinkos in cubasish theme
[ardour.git] / gtk2_ardour / io_selector.cc
index fea21ced0f369cd5bc7ada867f80793e49c79ab9..ab4a4d65f02088c2197f3aecb070097176f704a0 100644 (file)
@@ -1,45 +1,47 @@
 /*
-    Copyright (C) 2002-2007 Paul Davis
+ * Copyright (C) 2005-2007 Doug McLain <doug@nostar.net>
+ * Copyright (C) 2005-2016 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
+ * Copyright (C) 2006-2012 David Robillard <d@drobilla.net>
+ * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2008 Hans Baier <hansfbaier@googlemail.com>
+ * Copyright (C) 2013-2015 Robin Gareus <robin@gareus.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdint.h>
 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include <gtkmm/messagedialog.h>
 #include <glibmm/objectbase.h>
 
 #include <gtkmm2ext/doi.h>
 
-#include "ardour/port_insert.h"
-#include "ardour/session.h"
-#include "ardour/io.h"
 #include "ardour/audioengine.h"
-#include "ardour/track.h"
-#include "ardour/audio_track.h"
-#include "ardour/midi_track.h"
-#include "ardour/mtdm.h"
+#include "ardour/bundle.h"
 #include "ardour/data_type.h"
+#include "ardour/io.h"
 #include "ardour/port.h"
-#include "ardour/bundle.h"
+#include "ardour/session.h"
 
 #include "io_selector.h"
 #include "utils.h"
 #include "gui_thread.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
+using namespace ARDOUR_UI_UTILS;
 using namespace Gtk;
 
 IOSelector::IOSelector (Gtk::Window* p, ARDOUR::Session* session, boost::shared_ptr<ARDOUR::IO> io)
@@ -119,7 +121,7 @@ IOSelector::setup_ports (int dim)
 
        if (dim == _other) {
 
-               _ports[_other].gather (_session, type(), _find_inputs_for_io_outputs, false);
+               _ports[_other].gather (_session, type(), _find_inputs_for_io_outputs, false, show_only_bundles ());
 
        } else {
 
@@ -144,11 +146,15 @@ IOSelector::set_state (ARDOUR::BundleChannel c[2], bool s)
                                return;
                        }
 
-                        if (s) {
-                                _io->connect (f, *j, 0);
-                        } else {
-                                _io->disconnect (f, *j, 0);
-                        }
+                       if (s) {
+                               if (!f->connected_to (*j)) {
+                                       _io->connect (f, *j, 0);
+                               }
+                       } else {
+                               if (f->connected_to (*j)) {
+                                       _io->disconnect (f, *j, 0);
+                               }
+                       }
                }
        }
 }
@@ -204,27 +210,25 @@ IOSelector::list_is_global (int dim) const
        return (dim == _other);
 }
 
-string
+std::string
 IOSelector::disassociation_verb () const
 {
        return _("Disconnect");
 }
 
-string
+std::string
 IOSelector::channel_noun () const
 {
        return _("port");
 }
 
 IOSelectorWindow::IOSelectorWindow (ARDOUR::Session* session, boost::shared_ptr<ARDOUR::IO> io, bool /*can_cancel*/)
-       : ArdourDialog (_("I/O selector"))
-        , _selector (this, session, io)
+       : ArdourWindow (_("I/O selector"))
+       , _selector (this, session, io)
 {
        set_name ("IOSelectorWindow2");
 
-       get_vbox()->pack_start (_selector);
-
-       set_position (Gtk::WIN_POS_MOUSE);
+       add (_selector);
 
        io_name_changed (this);
 
@@ -237,8 +241,7 @@ bool
 IOSelectorWindow::wm_delete (GdkEventAny* /*event*/)
 {
        _selector.Finished (IOSelector::Accepted);
-       hide ();
-       return true;
+       return false;
 }
 
 
@@ -253,7 +256,7 @@ void
 IOSelectorWindow::on_show ()
 {
        Gtk::Window::on_show ();
-       pair<uint32_t, uint32_t> const pm_max = _selector.max_size ();
+       std::pair<uint32_t, uint32_t> const pm_max = _selector.max_size ();
        resize_window_to_proportion_of_monitor (this, pm_max.first, pm_max.second);
 }
 
@@ -262,7 +265,7 @@ IOSelectorWindow::io_name_changed (void*)
 {
        ENSURE_GUI_THREAD (*this, &IOSelectorWindow::io_name_changed, src)
 
-       string title;
+       std::string title;
 
        if (!_selector.find_inputs_for_io_outputs()) {
                title = string_compose(_("%1 input"), _selector.io()->name());