- MIDI::Manager::PortMap::const_iterator i;
- const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
- int n;
-
- /* remove all existing widgets */
-
- // XXX broken in gtkmm 2.10
- // midi_port_table.clear ();
-
- for (vector<Widget*>::iterator w = midi_port_table_widgets.begin(); w != midi_port_table_widgets.end(); ++w) {
- midi_port_table.remove (**w);
- }
-
- midi_port_table_widgets.clear ();
-
- midi_port_table.resize (ports.size() + 4, 12);
-
- Gtk::Label* label;
-
- label = (manage (new Label (_("Port"))));
- label->show ();
- midi_port_table_widgets.push_back (label);
- midi_port_table.attach (*label, 0, 1, 0, 1);
- label = (manage (new Label (_("Offline"))));
- label->show ();
- midi_port_table_widgets.push_back (label);
- midi_port_table.attach (*label, 1, 2, 0, 1);
- label = (manage (new Label (_("Trace\nInput"))));
- label->show ();
- midi_port_table_widgets.push_back (label);
- midi_port_table.attach (*label, 2, 3, 0, 1);
- label = (manage (new Label (_("Trace\nOutput"))));
- label->show ();
- midi_port_table_widgets.push_back (label);
- midi_port_table.attach (*label, 3, 4, 0, 1);
- label = (manage (new Label (_("MTC"))));
- label->show ();
- midi_port_table_widgets.push_back (label);
- midi_port_table.attach (*label, 4, 5, 0, 1);
- label = (manage (new Label (_("MIDI\nClock"))));
- label->show ();
- midi_port_table_widgets.push_back (label);
- midi_port_table.attach (*label, 6, 7, 0, 1);
- label = (manage (new Label (_("MMC"))));
- label->show ();
- midi_port_table_widgets.push_back (label);
- midi_port_table.attach (*label, 8, 9, 0, 1);
- label = (manage (new Label (_("MIDI Parameter\nControl"))));
- label->show ();
- midi_port_table_widgets.push_back (label);
- midi_port_table.attach (*label, 10, 11, 0, 1);
-
- Gtk::HSeparator* hsep = (manage (new HSeparator()));
- hsep->show ();
- midi_port_table_widgets.push_back (hsep);
- midi_port_table.attach (*hsep, 0, 11, 1, 2);
- Gtk::VSeparator* vsep = (manage (new VSeparator()));
- vsep->show ();
- midi_port_table_widgets.push_back (vsep);
- midi_port_table.attach (*vsep, 5, 6, 0, 8);
- vsep = (manage (new VSeparator()));
- vsep->show ();
- midi_port_table_widgets.push_back (vsep);
- midi_port_table.attach (*vsep, 7, 8, 0, 8);
- vsep = (manage (new VSeparator()));
- vsep->show ();
- midi_port_table_widgets.push_back (vsep);
- midi_port_table.attach (*vsep, 9, 10, 0, 8);
-
- for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
-
- ToggleButton* tb;
- RadioButton* rb;
- Button* bb;
-
- /* the remove button. create early so we can pass it to various callbacks */
-
- bb = manage (new Button (Stock::REMOVE));
- bb->set_name ("OptionEditorToggleButton");
- bb->show ();
- midi_port_table_widgets.push_back (bb);
- midi_port_table.attach (*bb, 11, 12, n+2, n+3, FILL|EXPAND, FILL);
- bb->signal_clicked().connect (bind (mem_fun(*this, &OptionEditor::remove_midi_port), i->second));
- bb->set_sensitive (port_removable (i->second));
-
- label = (manage (new Label (i->first)));
- label->show ();
- midi_port_table_widgets.push_back (label);
- midi_port_table.attach (*label, 0, 1, n+2, n+3,FILL|EXPAND, FILL );
-
- tb = manage (new ToggleButton (_("online")));
- tb->set_name ("OptionEditorToggleButton");
-
- /* remember, we have to handle the i18n case where the relative
- lengths of the strings in language N is different than in english.
- */
-
- if (strlen (_("offline")) > strlen (_("online"))) {
- set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
- } else {
- set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
- }
-
- if (i->second->input()) {
- tb->set_active (!i->second->input()->offline());
- tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), i->second, tb));
- i->second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
- }
- tb->show ();
- midi_port_table_widgets.push_back (tb);
- midi_port_table.attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
-
- // Trace MIDI Input
- tb = manage (new ToggleButton ());
- tb->set_name ("OptionEditorToggleButton");
- tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
- tb->set_size_request (10, 10);
- tb->show ();
- midi_port_table_widgets.push_back (tb);
- midi_port_table.attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
-
- // Trace MIDI Output
- tb = manage (new ToggleButton ());
- tb->set_name ("OptionEditorToggleButton");
- tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
- tb->set_size_request (10, 10);
- tb->show ();
- midi_port_table_widgets.push_back (tb);
- midi_port_table.attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
-
- // MTC Radio Button
- rb = manage (new RadioButton ());
- rb->set_name ("OptionEditorToggleButton");
- if (n == 0) {
- mtc_button_group = rb->get_group();
- } else {
- rb->set_group (mtc_button_group);
- }
- rb->show ();
- midi_port_table_widgets.push_back (rb);
- midi_port_table.attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
- rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb, bb));
-
- if (session && i->second == session->mtc_port()) {
- rb->set_active (true);
- }
-
- // MIDI Clock Radio Button
- rb = manage (new RadioButton ());
- rb->set_name ("OptionEditorToggleButton");
- if (n == 0) {
- midi_clock_button_group = rb->get_group();
- } else {
- rb->set_group (midi_clock_button_group);
- }
- rb->show ();
- midi_port_table_widgets.push_back (rb);
- midi_port_table.attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
- rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_clock_port_chosen), (*i).second, rb, bb));
-
- if (session && i->second == session->midi_clock_port()) {
- rb->set_active (true);
- }
-
- rb = manage (new RadioButton ());
- rb->set_name ("OptionEditorToggleButton");
- if (n == 0) {
- mmc_button_group = rb->get_group();
- } else {
- rb->set_group (mmc_button_group);
- }
- rb->show ();
- midi_port_table_widgets.push_back (rb);
- midi_port_table.attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
- rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb, bb));
-
- if (session && i->second == session->mmc_port()) {
- rb->set_active (true);
- }
-
- rb = manage (new RadioButton ());
- rb->set_name ("OptionEditorToggleButton");
- if (n == 0) {
- midi_button_group = rb->get_group();
- } else {
- rb->set_group (midi_button_group);
- }
- rb->show ();
- midi_port_table_widgets.push_back (rb);
- midi_port_table.attach (*rb, 10, 11, n+2, n+3, FILL|EXPAND, FILL);
- rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb, bb));
-
- if (session && i->second == session->midi_port()) {
- rb->set_active (true);
- }
-
- }
-
- midi_port_table.show();