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