2 Copyright (C) 2002-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <gtkmm/label.h>
21 #include <gtkmm/enums.h>
22 #include <gtkmm/image.h>
23 #include <gtkmm/stock.h>
24 #include <gtkmm/messagedialog.h>
25 #include <gtkmm/menu.h>
26 #include <gtkmm/menu_elems.h>
27 #include <gtkmm/menuitem.h>
28 #include <gtkmm/menushell.h>
29 #include <glibmm/objectbase.h>
30 #include <gtkmm2ext/doi.h>
31 #include <ardour/port_insert.h>
32 #include "ardour/session.h"
33 #include "ardour/io.h"
34 #include "ardour/audioengine.h"
35 #include "ardour/track.h"
36 #include "ardour/audio_track.h"
37 #include "ardour/midi_track.h"
38 #include "ardour/data_type.h"
39 #include "io_selector.h"
41 #include "gui_thread.h"
44 /** Add a port to a group.
45 * @param p Port name, with or without prefix.
49 PortGroup::add (std::string const & p)
51 if (prefix.empty() == false && p.substr (0, prefix.length()) == prefix) {
52 ports.push_back (p.substr (prefix.length()));
59 PortGroupTable::PortGroupTable (
60 PortGroup& g, boost::shared_ptr<ARDOUR::IO> io, bool for_input
62 : _port_group (g), _ignore_check_button_toggle (false),
63 _io (io), _for_input (for_input)
65 ARDOUR::DataType const t = _io->default_type();
69 rows = _io->n_inputs().get(t);
71 rows = _io->n_outputs().get(t);
74 int const ports = _port_group.ports.size();
76 if (rows == 0 || ports == 0) {
80 /* Sort out the table and the checkbuttons inside it */
82 _table.resize (rows, ports);
83 _check_buttons.resize (rows);
84 for (int i = 0; i < rows; ++i) {
85 _check_buttons[i].resize (ports);
88 for (int i = 0; i < rows; ++i) {
89 for (uint32_t j = 0; j < _port_group.ports.size(); ++j) {
90 Gtk::CheckButton* b = new Gtk::CheckButton;
91 b->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &PortGroupTable::check_button_toggled), b, i, _port_group.prefix + _port_group.ports[j]));
92 _check_buttons[i][j] = b;
93 _table.attach (*b, j, j + 1, i, i + 1);
99 _ignore_check_button_toggle = true;
101 /* Set the state of the check boxes according to current connections */
102 for (int i = 0; i < rows; ++i) {
103 const char **connections = _for_input ? _io->input(i)->get_connections() : _io->output(i)->get_connections();
104 for (uint32_t j = 0; j < _port_group.ports.size(); ++j) {
106 std::string const t = _port_group.prefix + _port_group.ports[j];
108 bool required_state = false;
110 while (connections && connections[k]) {
111 if (std::string(connections[k]) == t) {
112 required_state = true;
118 _check_buttons[i][j]->set_active (required_state);
122 _ignore_check_button_toggle = false;
125 /** @return Width and height of a single check button in a port group table */
127 PortGroupTable::unit_size () const
129 if (_check_buttons.empty() || _check_buttons[0].empty()) {
130 return std::pair<int, int> (0, 0);
133 return std::make_pair (
134 _check_buttons[0][0]->get_width() + _table.get_col_spacing (0),
135 _check_buttons[0][0]->get_height() + _table.get_row_spacing (0)
140 PortGroupTable::get_widget ()
146 /** Handle a toggle of a check button */
148 PortGroupTable::check_button_toggled (Gtk::CheckButton* b, int r, std::string const & p)
150 if (_ignore_check_button_toggle) {
154 bool const new_state = b->get_active ();
158 _io->connect_input (_io->input(r), p, 0);
160 _io->connect_output (_io->output(r), p, 0);
164 _io->disconnect_input (_io->input(r), p, 0);
166 _io->disconnect_output (_io->output(r), p, 0);
172 RotatedLabelSet::RotatedLabelSet (PortGroupList& g)
173 : Glib::ObjectBase ("RotatedLabelSet"), Gtk::Widget (), _port_group_list (g), _base_width (128)
175 set_flags (Gtk::NO_WINDOW);
179 RotatedLabelSet::~RotatedLabelSet ()
185 /** Set the angle that the labels are drawn at.
186 * @param degrees New angle in degrees.
190 RotatedLabelSet::set_angle (int degrees)
192 _angle_degrees = degrees;
193 _angle_radians = M_PI * _angle_degrees / 180;
199 RotatedLabelSet::on_size_request (Gtk::Requisition* requisition)
201 *requisition = Gtk::Requisition ();
203 if (_pango_layout == 0) {
207 /* Our height is the highest label */
208 requisition->height = 0;
209 for (PortGroupList::const_iterator i = _port_group_list.begin(); i != _port_group_list.end(); ++i) {
210 for (std::vector<std::string>::const_iterator j = i->ports.begin(); j != i->ports.end(); ++j) {
211 std::pair<int, int> const d = setup_layout (*j);
212 if (d.second > requisition->height) {
213 requisition->height = d.second;
218 /* And our width is the base plus the width of the last label */
219 requisition->width = _base_width;
220 int const n = _port_group_list.n_visible_ports ();
222 std::pair<int, int> const d = setup_layout (_port_group_list.get_port_by_index (n - 1, false));
223 requisition->width += d.first;
228 RotatedLabelSet::on_size_allocate (Gtk::Allocation& allocation)
230 set_allocation (allocation);
233 _gdk_window->move_resize (
234 allocation.get_x(), allocation.get_y(), allocation.get_width(), allocation.get_height()
240 RotatedLabelSet::on_realize ()
242 Gtk::Widget::on_realize ();
244 Glib::RefPtr<Gtk::Style> style = get_style ();
247 GdkWindowAttr attributes;
248 memset (&attributes, 0, sizeof (attributes));
250 Gtk::Allocation allocation = get_allocation ();
251 attributes.x = allocation.get_x ();
252 attributes.y = allocation.get_y ();
253 attributes.width = allocation.get_width ();
254 attributes.height = allocation.get_height ();
256 attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK;
257 attributes.window_type = GDK_WINDOW_CHILD;
258 attributes.wclass = GDK_INPUT_OUTPUT;
260 _gdk_window = Gdk::Window::create (get_window (), &attributes, GDK_WA_X | GDK_WA_Y);
261 unset_flags (Gtk::NO_WINDOW);
262 set_window (_gdk_window);
264 _bg_colour = style->get_bg (Gtk::STATE_NORMAL );
265 modify_bg (Gtk::STATE_NORMAL, _bg_colour);
266 _fg_colour = style->get_fg (Gtk::STATE_NORMAL);
268 _gdk_window->set_user_data (gobj ());
270 /* Set up Pango stuff */
271 _pango_context = create_pango_context ();
273 Pango::Matrix matrix = PANGO_MATRIX_INIT;
274 pango_matrix_rotate (&matrix, _angle_degrees);
275 _pango_context->set_matrix (matrix);
277 _pango_layout = Pango::Layout::create (_pango_context);
278 _gc = Gdk::GC::create (get_window ());
283 RotatedLabelSet::on_unrealize()
285 _gdk_window.clear ();
287 Gtk::Widget::on_unrealize ();
291 /** Set up our Pango layout to plot a given string, and compute its dimensions once
292 * it has been rotated.
293 * @param s String to use.
294 * @return width and height of the rotated string, in pixels.
298 RotatedLabelSet::setup_layout (std::string const & s)
300 _pango_layout->set_text (s);
302 /* Here's the unrotated size */
305 _pango_layout->get_pixel_size (w, h);
307 /* Rotate the width and height as appropriate. I thought Pango might be able
308 to do this for us, but I can't find out how... */
309 std::pair<int, int> d;
310 d.first = int (w * cos (_angle_radians) - h * sin (_angle_radians));
311 d.second = int (w * sin (_angle_radians) + h * cos (_angle_radians));
317 RotatedLabelSet::on_expose_event (GdkEventExpose* event)
323 int const height = get_allocation().get_height ();
324 double const spacing = double (_base_width) / _port_group_list.n_visible_ports();
326 /* Plot all the visible labels; really we should clip for efficiency */
328 for (PortGroupList::const_iterator i = _port_group_list.begin(); i != _port_group_list.end(); ++i) {
330 for (uint32_t j = 0; j < i->ports.size(); ++j) {
331 std::pair<int, int> const d = setup_layout (i->ports[j]);
332 get_window()->draw_layout (_gc, int ((n + 0.25) * spacing), height - d.second, _pango_layout, _fg_colour, _bg_colour);
341 /** Set the `base width'. This is the width of the base of the label set, ie:
352 RotatedLabelSet::set_base_width (int w)
359 /** Construct an IOSelector.
360 * @param session Session to operate on.
361 * @param io IO to operate on.
362 * @param for_input true if the selector is for an input, otherwise false.
365 IOSelector::IOSelector (ARDOUR::Session& session, boost::shared_ptr<ARDOUR::IO> io, bool for_input)
366 : _port_group_list (session, io, for_input), _io (io), _for_input (for_input),
367 _row_labels_vbox (0), _column_labels (_port_group_list), _left_vbox_pad (0)
369 Gtk::HBox* c = new Gtk::HBox;
370 for (PortGroupList::iterator i = _port_group_list.begin(); i != _port_group_list.end(); ++i) {
371 Gtk::CheckButton* b = new Gtk::CheckButton (i->name);
372 b->set_active (true);
373 b->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &IOSelector::group_visible_toggled), b, i->name));
374 c->pack_start (*Gtk::manage (b));
376 pack_start (*Gtk::manage (c));
378 _left_vbox.pack_start (*Gtk::manage (new Gtk::Label ("")));
379 _overall_hbox.pack_start (_left_vbox, false, false);
380 _scrolled_window.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_NEVER);
381 _scrolled_window.set_shadow_type (Gtk::SHADOW_NONE);
382 Gtk::VBox* b = new Gtk::VBox;
383 b->pack_start (_column_labels, false, false);
384 b->pack_start (_port_group_hbox, false, false);
385 Gtk::Alignment* a = new Gtk::Alignment (0, 1, 0, 0);
386 a->add (*Gtk::manage (b));
387 _scrolled_window.add (*Gtk::manage (a));
388 _overall_hbox.pack_start (_scrolled_window);
389 pack_start (_overall_hbox);
391 _port_group_hbox.signal_size_allocate().connect (sigc::hide (sigc::mem_fun (*this, &IOSelector::setup_dimensions)));
393 /* Listen for ports changing on the IO */
395 _io->input_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
397 _io->output_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
402 IOSelector::~IOSelector ()
407 /** Clear out the things that change when the number of source or destination ports changes */
411 for (std::vector<Gtk::EventBox*>::iterator i = _row_labels.begin(); i != _row_labels.end(); ++i) {
414 _row_labels.clear ();
416 if (_row_labels_vbox) {
417 _left_vbox.remove (*_row_labels_vbox);
419 delete _row_labels_vbox;
420 _row_labels_vbox = 0;
422 if (_left_vbox_pad) {
423 _left_vbox.remove (*_left_vbox_pad);
425 delete _left_vbox_pad;
428 for (std::vector<PortGroupTable*>::iterator i = _port_group_tables.begin(); i != _port_group_tables.end(); ++i) {
429 _port_group_hbox.remove ((*i)->get_widget());
433 _port_group_tables.clear ();
437 /** Set up dimensions of some of our widgets which depend on other dimensions
438 * within the dialogue.
441 IOSelector::setup_dimensions ()
443 /* Get some dimensions from various places */
444 int const scrollbar_height = _scrolled_window.get_hscrollbar()->get_height();
446 std::pair<int, int> unit_size (0, 0);
447 int port_group_tables_height = 0;
448 for (std::vector<PortGroupTable*>::iterator i = _port_group_tables.begin(); i != _port_group_tables.end(); ++i) {
449 std::pair<int, int> const u = (*i)->unit_size ();
450 unit_size.first = std::max (unit_size.first, u.first);
451 unit_size.second = std::max (unit_size.second, u.second);
452 port_group_tables_height = std::max (
453 port_group_tables_height, (*i)->get_widget().get_height()
458 _column_labels.set_base_width (_port_group_list.n_visible_ports () * unit_size.first);
460 /* Scrolled window */
461 /* XXX: really shouldn't set a minimum horizontal size here, but if we don't
462 the window starts up very small */
463 _scrolled_window.set_size_request (
464 std::min (_column_labels.get_width(), 640),
465 _column_labels.get_height() + port_group_tables_height + scrollbar_height + 16
469 for (std::vector<Gtk::EventBox*>::iterator i = _row_labels.begin(); i != _row_labels.end(); ++i) {
470 (*i)->get_child()->set_size_request (-1, unit_size.second);
474 if (_left_vbox_pad) {
475 _left_vbox_pad->set_size_request (-1, scrollbar_height + unit_size.second / 4);
480 /** Set up the dialogue */
486 /* Work out how many rows we have */
487 ARDOUR::DataType const t = _io->default_type();
491 rows = _io->n_inputs().get(t);
493 rows = _io->n_outputs().get(t);
497 _row_labels_vbox = new Gtk::VBox;
498 for (int i = 0; i < rows; ++i) {
499 Gtk::Label* label = new Gtk::Label (_for_input ? _io->input(i)->name() : _io->output(i)->name());
500 Gtk::EventBox* b = new Gtk::EventBox;
501 b->set_events (Gdk::BUTTON_PRESS_MASK);
502 b->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &IOSelector::row_label_button_pressed), i));
503 b->add (*Gtk::manage (label));
504 _row_labels.push_back (b);
505 _row_labels_vbox->pack_start (*b, false, false);
507 _left_vbox.pack_start (*_row_labels_vbox, false, false);
508 _left_vbox_pad = new Gtk::Label ("");
509 _left_vbox.pack_start (*_left_vbox_pad, false, false);
511 /* Checkbutton tables */
513 for (PortGroupList::iterator i = _port_group_list.begin(); i != _port_group_list.end(); ++i) {
514 PortGroupTable* t = new PortGroupTable (*i, _io, _for_input);
516 /* XXX: this is a bit of a hack; should probably use a configurable colour here */
517 Gdk::Color alt_bg = get_style()->get_bg (Gtk::STATE_NORMAL);
518 alt_bg.set_rgb (alt_bg.get_red() + 4096, alt_bg.get_green() + 4096, alt_bg.get_blue () + 4096);
520 t->get_widget().modify_bg (Gtk::STATE_NORMAL, alt_bg);
523 _port_group_tables.push_back (t);
524 _port_group_hbox.pack_start (t->get_widget(), false, false);
532 IOSelector::ports_changed (ARDOUR::IOChange change, void *src)
534 ENSURE_GUI_THREAD (bind (mem_fun (*this, &IOSelector::ports_changed), change, src));
541 IOSelector::redisplay ()
543 _port_group_list.refresh ();
548 /** Handle a button press on a row label */
550 IOSelector::row_label_button_pressed (GdkEventButton* e, int r)
552 if (e->type != GDK_BUTTON_PRESS || e->button != 3) {
556 Gtk::Menu* menu = Gtk::manage (new Gtk::Menu);
557 Gtk::Menu_Helpers::MenuList& items = menu->items ();
558 menu->set_name ("ArdourContextMenu");
563 ARDOUR::DataType const t = _io->default_type();
566 can_add = _io->input_maximum().get(t) > _io->n_inputs().get(t);
567 can_remove = _io->input_minimum().get(t) < _io->n_inputs().get(t);
568 name = _io->input(r)->name();
570 can_add = _io->output_maximum().get(t) > _io->n_outputs().get(t);
571 can_remove = _io->output_minimum().get(t) < _io->n_outputs().get(t);
572 name = _io->output(r)->name();
576 Gtk::Menu_Helpers::MenuElem (_("Add port"), sigc::mem_fun (*this, &IOSelector::add_port))
579 items.back().set_sensitive (can_add);
582 Gtk::Menu_Helpers::MenuElem (_("Remove port '") + name + _("'"), sigc::bind (sigc::mem_fun (*this, &IOSelector::remove_port), r))
585 items.back().set_sensitive (can_remove);
587 menu->popup (e->button, e->time);
593 IOSelector::add_port ()
595 // The IO selector only works for single typed IOs
596 const ARDOUR::DataType t = _io->default_type ();
601 _io->add_input_port ("", this);
604 catch (ARDOUR::AudioEngine::PortRegistrationFailure& err) {
605 Gtk::MessageDialog msg (0, _("There are no more JACK ports available."));
612 _io->add_output_port ("", this);
615 catch (ARDOUR::AudioEngine::PortRegistrationFailure& err) {
616 Gtk::MessageDialog msg (0, _("There are no more JACK ports available."));
623 IOSelector::remove_port (int r)
625 // The IO selector only works for single typed IOs
626 const ARDOUR::DataType t = _io->default_type ();
629 _io->remove_input_port (_io->input (r), this);
631 _io->remove_output_port (_io->output (r), this);
636 IOSelector::group_visible_toggled (Gtk::CheckButton* b, std::string const & n)
638 PortGroupList::iterator i = _port_group_list.begin();
639 while (i != _port_group_list.end() & i->name != n) {
643 if (i == _port_group_list.end()) {
647 i->visible = b->get_active ();
649 /* Update PortGroupTable visibility */
651 for (std::vector<PortGroupTable*>::iterator j = _port_group_tables.begin(); j != _port_group_tables.end(); ++j) {
652 if ((*j)->port_group().visible) {
653 (*j)->get_widget().show();
655 (*j)->get_widget().hide();
659 _column_labels.queue_draw ();
663 PortGroupList::PortGroupList (ARDOUR::Session & session, boost::shared_ptr<ARDOUR::IO> io, bool for_input)
664 : _session (session), _io (io), _for_input (for_input)
670 PortGroupList::refresh ()
674 /* Find the ports provided by ardour; we can't derive their type just from their
675 names, so we'll have to be more devious. */
677 boost::shared_ptr<ARDOUR::Session::RouteList> routes = _session.get_routes ();
679 PortGroup buss (_("Buss"), "ardour:");
680 PortGroup track (_("Track"), "ardour:");
682 for (ARDOUR::Session::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
685 if (_io->default_type() == ARDOUR::DataType::AUDIO && dynamic_cast<ARDOUR::AudioTrack*> ((*i).get())) {
686 /* Audio track for an audio IO */
688 } else if (_io->default_type() == ARDOUR::DataType::MIDI && dynamic_cast<ARDOUR::MidiTrack*> ((*i).get())) {
689 /* Midi track for a MIDI IO */
691 } else if (_io->default_type() == ARDOUR::DataType::AUDIO && dynamic_cast<ARDOUR::MidiTrack*> ((*i).get()) == 0) {
692 /* Non-MIDI track for an Audio IO; must be an audio buss */
697 ARDOUR::PortSet const & p = _for_input ? ((*i)->outputs()) : ((*i)->inputs());
698 for (uint32_t j = 0; j < p.num_ports(); ++j) {
699 g->add (p.port(j)->name ());
702 std::sort (g->ports.begin(), g->ports.end());
707 /* XXX: inserts, sends, plugin inserts? */
709 /* Now we need to find the non-ardour ports; we do this by first
710 finding all the ports that we can connect to. */
711 const char **ports = _session.engine().get_ports (
712 "", _io->default_type().to_jack_type(), _for_input ? JackPortIsOutput : JackPortIsInput
715 PortGroup system (_("System"), "system:");
716 PortGroup other (_("Other"), "");
722 std::string const p = ports[n];
724 if (p.substr(0, strlen ("system:")) == "system:") {
728 if (p.substr(0, strlen("ardour:")) != "ardour:") {
729 /* other (non-ardour) prefix */
745 PortGroupList::n_visible_ports () const
749 for (const_iterator i = begin(); i != end(); ++i) {
751 n += i->ports.size();
759 PortGroupList::get_port_by_index (int n, bool with_prefix) const
761 /* XXX: slightly inefficient algorithm */
763 for (const_iterator i = begin(); i != end(); ++i) {
764 for (std::vector<std::string>::const_iterator j = i->ports.begin(); j != i->ports.end(); ++j) {
767 return i->prefix + *j;
780 IOSelectorWindow::IOSelectorWindow (
781 ARDOUR::Session& session, boost::shared_ptr<ARDOUR::IO> io, bool for_input, bool can_cancel
783 : ArdourDialog ("I/O selector"),
784 _selector (session, io, for_input),
785 ok_button (can_cancel ? _("OK"): _("Close")),
786 cancel_button (_("Cancel")),
787 rescan_button (_("Rescan"))
790 add_events (Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
791 set_name ("IOSelectorWindow2");
795 title = string_compose(_("%1 input"), io->name());
797 title = string_compose(_("%1 output"), io->name());
800 ok_button.set_name ("IOSelectorButton");
802 ok_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CLOSE, Gtk::ICON_SIZE_BUTTON)));
804 cancel_button.set_name ("IOSelectorButton");
805 rescan_button.set_name ("IOSelectorButton");
806 rescan_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::REFRESH, Gtk::ICON_SIZE_BUTTON)));
808 get_action_area()->pack_start (rescan_button, false, false);
811 cancel_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CANCEL, Gtk::ICON_SIZE_BUTTON)));
812 get_action_area()->pack_start (cancel_button, false, false);
814 cancel_button.hide();
817 get_action_area()->pack_start (ok_button, false, false);
819 get_vbox()->set_spacing (8);
820 get_vbox()->pack_start (_selector);
822 ok_button.signal_clicked().connect (mem_fun(*this, &IOSelectorWindow::accept));
823 cancel_button.signal_clicked().connect (mem_fun(*this, &IOSelectorWindow::cancel));
824 rescan_button.signal_clicked().connect (mem_fun(*this, &IOSelectorWindow::rescan));
827 set_position (Gtk::WIN_POS_MOUSE);
831 signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window *> (this)));
834 IOSelectorWindow::~IOSelectorWindow()
840 IOSelectorWindow::rescan ()
842 _selector.redisplay ();
846 IOSelectorWindow::cancel ()
848 _selector.Finished (IOSelector::Cancelled);
853 IOSelectorWindow::accept ()
855 _selector.Finished (IOSelector::Accepted);
860 IOSelectorWindow::on_map ()
862 _selector.redisplay ();
867 PortInsertUI::PortInsertUI (ARDOUR::Session& sess, boost::shared_ptr<ARDOUR::PortInsert> pi)
868 : input_selector (sess, pi->io(), true),
869 output_selector (sess, pi->io(), false)
871 hbox.pack_start (output_selector, true, true);
872 hbox.pack_start (input_selector, true, true);
878 PortInsertUI::redisplay ()
880 input_selector.redisplay();
881 output_selector.redisplay();
885 PortInsertUI::finished (IOSelector::Result r)
887 input_selector.Finished (r);
888 output_selector.Finished (r);
892 PortInsertWindow::PortInsertWindow (ARDOUR::Session& sess, boost::shared_ptr<ARDOUR::PortInsert> pi, bool can_cancel)
893 : ArdourDialog ("port insert dialog"),
894 _portinsertui (sess, pi),
895 ok_button (can_cancel ? _("OK"): _("Close")),
896 cancel_button (_("Cancel")),
897 rescan_button (_("Rescan"))
900 set_name ("IOSelectorWindow");
901 string title = _("ardour: ");
905 ok_button.set_name ("IOSelectorButton");
907 ok_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CLOSE, Gtk::ICON_SIZE_BUTTON)));
909 cancel_button.set_name ("IOSelectorButton");
910 rescan_button.set_name ("IOSelectorButton");
911 rescan_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::REFRESH, Gtk::ICON_SIZE_BUTTON)));
913 get_action_area()->pack_start (rescan_button, false, false);
915 cancel_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CANCEL, Gtk::ICON_SIZE_BUTTON)));
916 get_action_area()->pack_start (cancel_button, false, false);
918 cancel_button.hide();
920 get_action_area()->pack_start (ok_button, false, false);
922 get_vbox()->pack_start (_portinsertui);
924 ok_button.signal_clicked().connect (mem_fun (*this, &PortInsertWindow::accept));
925 cancel_button.signal_clicked().connect (mem_fun (*this, &PortInsertWindow::cancel));
926 rescan_button.signal_clicked().connect (mem_fun (*this, &PortInsertWindow::rescan));
928 signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window *> (this)));
930 going_away_connection = pi->GoingAway.connect (mem_fun (*this, &PortInsertWindow::plugin_going_away));
934 PortInsertWindow::plugin_going_away ()
936 ENSURE_GUI_THREAD (mem_fun (*this, &PortInsertWindow::plugin_going_away));
938 going_away_connection.disconnect ();
939 delete_when_idle (this);
943 PortInsertWindow::on_map ()
945 _portinsertui.redisplay ();
951 PortInsertWindow::rescan ()
953 _portinsertui.redisplay ();
957 PortInsertWindow::cancel ()
959 _portinsertui.finished (IOSelector::Cancelled);
964 PortInsertWindow::accept ()
966 _portinsertui.finished (IOSelector::Accepted);