fix stupid button sensitivity issue in IO Selector
[ardour.git] / gtk2_ardour / io_selector.cc
1 /*
2     Copyright (C) 2002-2003 Paul Davis 
3
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.
8
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.
13
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.
17
18     $Id$
19 */
20
21 #include <map>
22 #include <vector>
23
24 #include <sigc++/bind.h>
25
26 #include <gtkmm/messagedialog.h>
27
28 #include <glibmm/thread.h>
29
30 #include <ardour/io.h>
31 #include <ardour/route.h>
32 #include <ardour/audioengine.h>
33 #include <ardour/port.h>
34 #include <ardour/insert.h>
35 #include <ardour/session.h>
36 #include <ardour/audio_diskstream.h>
37
38 #include <gtkmm2ext/doi.h>
39 #include <gtkmm2ext/gtk_ui.h>
40 #include <gtkmm2ext/utils.h>
41
42 #include "utils.h"
43 #include "io_selector.h"
44 #include "keyboard.h"
45 #include "gui_thread.h"
46
47 #include "i18n.h"
48
49 using namespace std;
50 using namespace Gtk;
51 using namespace Glib;
52 using namespace sigc;
53 using namespace ARDOUR;
54 using namespace PBD;
55 using namespace Gtkmm2ext;
56
57 IOSelectorWindow::IOSelectorWindow (Session& sess, boost::shared_ptr<IO> ior, bool input, bool can_cancel)
58         : ArdourDialog ("i/o selector"),
59           _selector (sess, ior, input),
60           ok_button (can_cancel ? _("OK"): _("Close")),
61           cancel_button (_("Cancel")),
62           rescan_button (_("Rescan"))
63
64 {
65         add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
66         set_name ("IOSelectorWindow");
67
68         string title;
69         if (input) {
70                 title = string_compose(_("%1 input"), ior->name());
71         } else {
72                 title = string_compose(_("%1 output"), ior->name());
73         }
74
75         ok_button.set_name ("IOSelectorButton");
76         cancel_button.set_name ("IOSelectorButton");
77         rescan_button.set_name ("IOSelectorButton");
78
79         button_box.set_spacing (5);
80         button_box.set_border_width (5);
81         button_box.set_homogeneous (true);
82         button_box.pack_start (rescan_button);
83
84         if (can_cancel) {
85                 button_box.pack_start (cancel_button);
86         } else {
87                 cancel_button.hide();
88         }
89                 
90         button_box.pack_start (ok_button);
91
92         get_vbox()->pack_start (_selector);
93         get_vbox()->pack_start (button_box, false, false);
94
95         ok_button.signal_clicked().connect (mem_fun(*this, &IOSelectorWindow::accept));
96         cancel_button.signal_clicked().connect (mem_fun(*this, &IOSelectorWindow::cancel));
97         rescan_button.signal_clicked().connect (mem_fun(*this, &IOSelectorWindow::rescan));
98
99         set_title (title);
100         set_position (WIN_POS_MOUSE);
101
102         signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window *> (this)));
103 }
104
105 IOSelectorWindow::~IOSelectorWindow()
106 {
107 }
108
109 void
110 IOSelectorWindow::rescan ()
111 {
112         _selector.redisplay ();
113 }
114
115 void
116 IOSelectorWindow::cancel ()
117 {
118         _selector.Finished(IOSelector::Cancelled);
119         hide ();
120 }
121
122 void
123 IOSelectorWindow::accept ()
124 {
125         _selector.Finished(IOSelector::Accepted);
126         hide ();
127 }
128
129 void
130 IOSelectorWindow::on_map ()
131 {
132         _selector.redisplay ();
133         Window::on_map ();
134 }
135
136 /*************************
137   The IO Selector "widget"
138  *************************/  
139
140 IOSelector::IOSelector (Session& sess, boost::shared_ptr<IO> ior, bool input)
141         : session (sess),
142           io (ior),
143           for_input (input),
144           port_frame (for_input? _("Inputs") : _("Outputs")),
145           add_port_button (for_input? _("Add Input") : _("Add Output")),
146           remove_port_button (for_input? _("Remove Input") : _("Remove Output")),
147           clear_connections_button (_("Disconnect All"))
148 {
149         selected_port = 0;
150
151         notebook.set_name ("IOSelectorNotebook");
152         notebook.set_size_request (-1, 125);
153
154         clear_connections_button.set_name ("IOSelectorButton");
155         add_port_button.set_name ("IOSelectorButton");
156         remove_port_button.set_name ("IOSelectorButton");
157
158         selector_frame.set_name ("IOSelectorFrame");
159         port_frame.set_name ("IOSelectorFrame");
160
161         selector_frame.set_label (_("Available connections"));
162         
163         selector_button_box.set_spacing (5);
164         selector_button_box.set_border_width (5);
165
166         selector_box.set_spacing (5);
167         selector_box.set_border_width (5);
168         selector_box.pack_start (notebook);
169         selector_box.pack_start (selector_button_box, false, false);
170
171         selector_frame.add (selector_box);
172
173         port_box.set_spacing (5);
174         port_box.set_border_width (5);
175
176         port_display_scroller.set_name ("IOSelectorNotebook");
177         port_display_scroller.set_border_width (0);
178         port_display_scroller.set_size_request (-1, 170);
179         port_display_scroller.add (port_box);
180         port_display_scroller.set_policy (POLICY_NEVER,
181                                           POLICY_AUTOMATIC);
182
183         port_button_box.set_spacing (5);
184         port_button_box.set_border_width (5);
185
186         port_button_box.pack_start (add_port_button, false, false);
187         port_button_box.pack_start (remove_port_button, false, false);
188         port_button_box.pack_start (clear_connections_button, false, false);
189
190         port_and_button_box.set_border_width (5);
191         port_and_button_box.pack_start (port_button_box, false, false);
192         port_and_button_box.pack_start (port_display_scroller);
193
194         port_frame.add (port_and_button_box);
195
196         port_and_selector_box.set_spacing (5);
197         port_and_selector_box.pack_start (port_frame);
198         port_and_selector_box.pack_start (selector_frame);
199
200         set_spacing (5);
201         set_border_width (5);
202         pack_start (port_and_selector_box);
203
204         rescan();
205         display_ports ();
206
207         clear_connections_button.signal_clicked().connect (mem_fun(*this, &IOSelector::clear_connections));
208
209         add_port_button.signal_clicked().connect (mem_fun(*this, &IOSelector::add_port));
210         remove_port_button.signal_clicked().connect (mem_fun(*this, &IOSelector::remove_port));
211
212         if (for_input) {
213                 io->input_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
214         } else {
215                 io->output_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
216         }
217
218         io->name_changed.connect (mem_fun(*this, &IOSelector::name_changed));
219 }
220
221 IOSelector::~IOSelector ()
222 {
223 }
224
225 void 
226 IOSelector::set_button_sensitivity ()
227 {
228         if (for_input) {
229
230                 if (io->input_maximum() < 0 || io->input_maximum() > (int) io->n_inputs()) {
231                         add_port_button.set_sensitive (true);
232                 } else {
233                         add_port_button.set_sensitive (false);
234                 }
235
236         } else {
237
238                 if (io->output_maximum() < 0 || io->output_maximum() > (int) io->n_outputs()) {
239                         add_port_button.set_sensitive (true);
240                 } else {
241                         add_port_button.set_sensitive (false);
242                 }
243                         
244         }
245
246         if (for_input) {
247                 if (io->n_inputs() && (io->input_minimum() < 0 || io->input_minimum() < (int) io->n_inputs())) {
248                         remove_port_button.set_sensitive (true);
249                 } else {
250                         remove_port_button.set_sensitive (false);
251                 }
252                         
253         } else {
254                 if (io->n_outputs() && (io->output_minimum() < 0 || io->output_minimum() < (int) io->n_outputs())) {
255                         remove_port_button.set_sensitive (true);
256                 } else {
257                         remove_port_button.set_sensitive (false);
258                 }
259         }
260 }
261
262
263 void
264 IOSelector::name_changed (void* src)
265 {
266         ENSURE_GUI_THREAD(bind (mem_fun(*this, &IOSelector::name_changed), src));
267         
268         display_ports ();
269 }
270
271 void
272 IOSelector::clear_connections ()
273 {
274         if (for_input) {
275                 io->disconnect_inputs (this);
276         } else {
277                 io->disconnect_outputs (this);
278         }
279 }
280
281 void
282 IOSelector::rescan ()
283 {
284         using namespace Notebook_Helpers;
285
286         typedef std::map<string,vector<pair<string,string> > > PortMap;
287         PortMap portmap;
288         const char **ports;
289         PageList& pages = notebook.pages();
290         gint current_page;
291         vector<string> rowdata;
292
293         page_selection_connection.disconnect ();
294
295         current_page = notebook.get_current_page ();
296
297         cerr << "clear notebook\n";
298
299         pages.clear ();
300
301         /* get relevant current JACK ports */
302
303         ports = session.engine().get_ports ("", JACK_DEFAULT_AUDIO_TYPE, for_input ? JackPortIsOutput : JackPortIsInput);
304
305         if (ports == 0) {
306                 cerr << "no ports\n";
307                 return;
308         }
309
310         /* find all the client names and group their ports into a list-by-client */
311         
312         for (int n = 0; ports[n]; ++n) {
313
314                 pair<string,vector<pair<string,string> > > newpair;
315                 pair<string,string> strpair;
316                 pair<PortMap::iterator,bool> result;
317
318                 string str = ports[n];
319                 string::size_type pos;
320                 string portname;
321
322                 pos = str.find (':');
323
324                 newpair.first = str.substr (0, pos);
325                 portname = str.substr (pos+1);
326
327                 result = portmap.insert (newpair);
328
329                 strpair.first = portname;
330                 strpair.second = str;
331
332                 result.first->second.push_back (strpair);
333         }
334
335         PortMap::iterator i;
336
337         for (i = portmap.begin(); i != portmap.end(); ++i) {
338                 
339                 Box *client_box = manage (new VBox);
340                 TreeView *display = manage (new TreeView);
341                 RefPtr<ListStore> model = ListStore::create (port_display_columns);
342                 ScrolledWindow *scroller = manage (new ScrolledWindow);
343
344                 display->set_model (model);
345                 display->append_column (X_("notvisible"), port_display_columns.displayed_name);
346                 display->set_headers_visible (false);
347                 display->get_selection()->set_mode (SELECTION_SINGLE);
348                 display->set_name ("IOSelectorList");
349
350                 for (vector<pair<string,string> >::iterator s = i->second.begin(); s != i->second.end(); ++s) {
351                         
352                         TreeModel::Row row = *(model->append ());
353
354                         row[port_display_columns.displayed_name] = s->first;
355                         row[port_display_columns.full_name] = s->second;
356                 }
357
358                 display->signal_button_release_event().connect (bind (mem_fun(*this, &IOSelector::port_selection_changed), display));
359                 Label *tab_label = manage (new Label);
360
361                 tab_label->set_name ("IOSelectorNotebookTab");
362                 tab_label->set_text ((*i).first);
363
364                 scroller->add (*display);
365                 scroller->set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
366
367                 client_box->pack_start (*scroller);
368
369                 pages.push_back (TabElem (*client_box, *tab_label));
370         }
371
372         cerr << "notebook should have " << portmap.size() << " pages\n";
373
374         notebook.set_current_page (current_page);
375         page_selection_connection = notebook.signal_show().connect (bind (mem_fun (notebook, &Notebook::set_current_page), current_page));
376         selector_box.show_all ();
377 }       
378
379 void
380 IOSelector::display_ports ()
381 {
382         TreeView *firsttview = 0;
383         TreeView *selected_port_tview = 0;
384         {
385                 Glib::Mutex::Lock lm  (port_display_lock);
386                 Port *port;
387                 uint32_t limit;
388                 
389                 if (for_input) {
390                         limit = io->n_inputs();
391                 } else {
392                         limit = io->n_outputs();
393                 }
394                 
395                 for (slist<TreeView *>::iterator i = port_displays.begin(); i != port_displays.end(); ) {
396                         
397                         slist<TreeView *>::iterator tmp;
398                         
399                         tmp = i;
400                         ++tmp;
401                         
402                         port_box.remove (**i);
403                         delete *i;
404                         port_displays.erase (i);
405                         
406                         i = tmp;
407                 } 
408                 
409                 for (uint32_t n = 0; n < limit; ++n) {
410                         
411                         TreeView* tview;
412                         //ScrolledWindow *scroller;
413                         string really_short_name;
414                         
415                         if (for_input) {
416                                 port = io->input (n);
417                         } else {
418                                 port = io->output (n);
419                         }
420                         
421                         /* we know there is '/' because we put it there */
422                         
423                         really_short_name = port->short_name();
424                         really_short_name = really_short_name.substr (really_short_name.find ('/') + 1);
425                         
426                         tview = manage (new TreeView());
427                         RefPtr<ListStore> port_model = ListStore::create (port_display_columns);
428                         
429                         if (!firsttview) {
430                                 firsttview = tview;
431                         }
432                         
433                         tview->set_model (port_model);
434                         tview->append_column (really_short_name, port_display_columns.displayed_name);
435                         tview->get_selection()->set_mode (SELECTION_SINGLE);
436                         tview->set_data ("port", port);
437                         tview->set_headers_visible (true);
438                         tview->set_name ("IOSelectorPortList");
439                         
440                         port_box.pack_start (*tview);
441                         port_displays.insert (port_displays.end(), tview);
442                         
443                         /* now fill the clist with the current connections */
444                         
445                         
446                         const char **connections = port->get_connections ();
447                         
448                         if (connections) {
449                                 for (uint32_t c = 0; connections[c]; ++c) {
450                                         TreeModel::Row row = *(port_model->append());
451                                         row[port_display_columns.displayed_name] = connections[c];
452                                         row[port_display_columns.full_name] = connections[c];
453                                 }
454                         }
455                         
456                         if (for_input) {
457                                 
458                                 if (io->input_maximum() == 1) {
459                                         selected_port = port;
460                                         selected_port_tview = tview;
461                                 } else {
462                                         if (port == selected_port) {
463                                                 selected_port_tview = tview;
464                                         }
465                                 }
466                                 
467                         } else {
468                                 
469                                 if (io->output_maximum() == 1) {
470                                         selected_port = port;
471                                         selected_port_tview = tview;
472                                 } else {
473                                         if (port == selected_port) {
474                                                 selected_port_tview = tview;
475                                         }
476                                 }
477                         }
478                         
479                         TreeViewColumn* col = tview->get_column (0);
480                         
481                         col->set_clickable (true);
482                         
483                         /* handle button events on the column header ... */
484                         col->signal_clicked().connect (bind (mem_fun(*this, &IOSelector::select_treeview), tview));
485
486                         /* ... and within the treeview itself */
487                         tview->signal_button_release_event().connect (bind (mem_fun(*this, &IOSelector::connection_button_release), tview));
488                 }
489                 
490                 port_box.show_all ();
491         }
492         
493         if (!selected_port_tview) {
494                 selected_port_tview = firsttview;
495         }
496
497         if (selected_port_tview) {
498                 select_treeview (selected_port_tview);
499         }
500 }
501
502 bool
503 IOSelector::port_selection_changed (GdkEventButton *ev, TreeView* treeview)
504 {
505         TreeModel::iterator i = treeview->get_selection()->get_selected();
506         int status;
507
508         if (!i) {
509                 return 0;
510         }
511
512         if (selected_port == 0) {
513                 return 0;
514         }
515
516         ustring other_port_name = (*i)[port_display_columns.full_name];
517         
518         if (for_input) {
519                 if ((status = io->connect_input (selected_port, other_port_name, this)) == 0) {
520                         Port *p = session.engine().get_port_by_name (other_port_name);
521                         p->enable_metering();
522                 }
523         } else {
524                 status = io->connect_output (selected_port, other_port_name, this);
525         }
526
527         if (status == 0) {
528                 select_next_treeview ();
529         }
530         
531         treeview->get_selection()->unselect_all();
532         return 0;
533 }
534
535 void
536 IOSelector::ports_changed (IOChange change, void *src)
537 {
538         ENSURE_GUI_THREAD(bind (mem_fun(*this, &IOSelector::ports_changed), change, src));
539         
540         display_ports ();
541 }
542
543 void
544 IOSelector::add_port ()
545 {
546         /* add a new port, then hide the button if we're up to the maximum allowed */
547
548         if (for_input) {
549
550                 try {
551                         io->add_input_port ("", this);
552                 }
553
554                 catch (AudioEngine::PortRegistrationFailure& err) {
555                         MessageDialog msg (0,  _("There are no more JACK ports available."));
556                         msg.run ();
557                 }
558
559         } else {
560
561                 try {
562                         io->add_output_port ("", this);
563                 }
564
565                 catch (AudioEngine::PortRegistrationFailure& err) {
566                         MessageDialog msg (0, _("There are no more JACK ports available."));
567                         msg.run ();
568                 }
569         }
570                 
571         set_button_sensitivity ();
572 }
573
574 void
575 IOSelector::remove_port ()
576 {
577         uint32_t nports;
578
579         // always remove last port
580         
581         if (for_input) {
582                 if ((nports = io->n_inputs()) > 0) {
583                         io->remove_input_port (io->input(nports-1), this);
584                 }
585
586         } else {
587                 if ((nports = io->n_outputs()) > 0) {
588                         io->remove_output_port (io->output(nports-1), this);
589                 }
590         }
591         
592         set_button_sensitivity ();
593 }
594
595 gint
596 IOSelector::connection_button_release (GdkEventButton *ev, TreeView *treeview)
597 {
598         /* this handles button release on a port name row: i.e. a connection
599            between the named port and the port represented by the treeview.
600         */
601
602         Gtk::TreeModel::iterator iter;
603         TreeModel::Path path;
604         TreeViewColumn* column;
605         int cellx;
606         int celly;
607
608         /* only handle button1 events here */
609
610         if (ev->button != 1) {
611                 return false;
612         }
613         
614         if (!treeview->get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
615                 return false;
616         }
617
618         if ((iter = treeview->get_model()->get_iter (path.to_string()))) {
619
620                 /* path is valid */
621                 ustring connected_port_name = (*iter)[port_display_columns.full_name];
622                 Port *port = reinterpret_cast<Port *> (treeview->get_data (_("port")));
623                 
624                 if (for_input) {
625                         Port *p = session.engine().get_port_by_name (connected_port_name);
626                         p->disable_metering();
627                         io->disconnect_input (port, connected_port_name, this);
628                 } else {
629                         io->disconnect_output (port, connected_port_name, this);
630                 }
631         }
632
633         return true;
634 }
635
636 void
637 IOSelector::select_next_treeview ()
638 {
639         slist<TreeView*>::iterator next;
640
641         if (port_displays.empty() || port_displays.size() == 1) {
642                 return;
643         }
644
645         for (slist<TreeView *>::iterator i = port_displays.begin(); i != port_displays.end(); ++i) {
646
647                 if ((*i)->get_name() == "IOSelectorPortListSelected") {
648
649                         ++i;
650
651                         if (i == port_displays.end()) {
652                                 select_treeview (port_displays.front());
653                         } else {
654                                 select_treeview (*i);
655                         }
656                         
657                         break;
658                 }
659         }
660 }
661
662 void
663 IOSelector::select_treeview (TreeView* tview)
664 {
665         /* Gack. TreeView's don't respond visually to a change
666            in their state, so rename them to force a style
667            switch.
668         */
669
670         Glib::Mutex::Lock lm  (port_display_lock);
671         Port* port = reinterpret_cast<Port *> (tview->get_data (_("port")));
672
673         selected_port = port;
674
675         tview->set_name ("IOSelectorPortListSelected");
676         tview->queue_draw ();
677
678         /* ugly hack to force the column header button to change as well */
679
680         TreeViewColumn* col = tview->get_column (0);
681         GtkTreeViewColumn* ccol = col->gobj();
682         
683         if (ccol->button) {
684                 gtk_widget_set_name (ccol->button, "IOSelectorPortListSelected");       
685                 gtk_widget_queue_draw (ccol->button);
686         }
687
688         for (slist<TreeView*>::iterator i = port_displays.begin(); i != port_displays.end(); ++i) {
689                 if (*i == tview) {
690                         continue;
691                 }
692                 
693                 col = (*i)->get_column (0);
694                 ccol = col->gobj();
695                 
696                 if (ccol->button) {
697                         gtk_widget_set_name (ccol->button, "IOSelectorPortList");
698                         gtk_widget_queue_draw (ccol->button);
699                 }
700                 
701                 (*i)->set_name ("IOSelectorPortList");
702                 (*i)->queue_draw ();
703         }
704
705         selector_box.show_all ();
706 }
707
708 void
709 IOSelector::redisplay ()
710 {
711         display_ports ();
712
713         if (for_input) {
714                 if (io->input_maximum() != 0) {
715                         rescan ();
716                 }
717         } else {
718                 if (io->output_maximum() != 0) {
719                         rescan();
720                 }
721         }
722 }
723
724 PortInsertUI::PortInsertUI (Session& sess, boost::shared_ptr<PortInsert> pi)
725         : input_selector (sess, pi, true),
726           output_selector (sess, pi, false)
727 {
728         hbox.pack_start (output_selector, true, true);
729         hbox.pack_start (input_selector, true, true);
730
731
732         pack_start (hbox);
733 }
734
735 void
736 PortInsertUI::redisplay()
737 {
738
739         input_selector.redisplay();
740         output_selector.redisplay();
741 }
742
743 void
744 PortInsertUI::finished(IOSelector::Result r)
745 {
746         input_selector.Finished (r);
747         output_selector.Finished (r);
748 }
749
750
751 PortInsertWindow::PortInsertWindow (Session& sess, boost::shared_ptr<PortInsert> pi, bool can_cancel)
752         : ArdourDialog ("port insert dialog"),
753           _portinsertui (sess, pi),
754           ok_button (can_cancel ? _("OK"): _("Close")),
755           cancel_button (_("Cancel")),
756           rescan_button (_("Rescan"))
757 {
758
759         set_name ("IOSelectorWindow");
760         string title = _("ardour: ");
761         title += pi->name();
762         set_title (title);
763         
764         ok_button.set_name ("IOSelectorButton");
765         cancel_button.set_name ("IOSelectorButton");
766         rescan_button.set_name ("IOSelectorButton");
767
768         button_box.set_spacing (5);
769         button_box.set_border_width (5);
770         button_box.set_homogeneous (true);
771         button_box.pack_start (rescan_button);
772         if (can_cancel) {
773                 button_box.pack_start (cancel_button);
774         }
775         else {
776                 cancel_button.hide();
777         }
778         button_box.pack_start (ok_button);
779
780         get_vbox()->pack_start (_portinsertui);
781         get_vbox()->pack_start (button_box, false, false);
782
783         ok_button.signal_clicked().connect (mem_fun(*this, &PortInsertWindow::accept));
784         cancel_button.signal_clicked().connect (mem_fun(*this, &PortInsertWindow::cancel));
785         rescan_button.signal_clicked().connect (mem_fun(*this, &PortInsertWindow::rescan));
786
787         signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window *> (this))); 
788         pi->GoingAway.connect (mem_fun(*this, &PortInsertWindow::plugin_going_away));
789 }
790
791 void
792 PortInsertWindow::plugin_going_away ()
793 {
794         ENSURE_GUI_THREAD(mem_fun(*this, &PortInsertWindow::plugin_going_away));
795         
796         delete_when_idle (this);
797 }
798
799 void
800 PortInsertWindow::on_map ()
801 {
802         _portinsertui.redisplay ();
803         Window::on_map ();
804 }
805
806
807 void
808 PortInsertWindow::rescan ()
809 {
810         _portinsertui.redisplay();
811 }
812
813 void
814 PortInsertWindow::cancel ()
815 {
816         _portinsertui.finished(IOSelector::Cancelled);
817         hide ();
818 }
819
820 void
821 PortInsertWindow::accept ()
822 {
823         _portinsertui.finished(IOSelector::Accepted);
824         hide ();
825 }