14
#=========================================================================
16
class InstrumentConnectionsDialog:
17
""" This class handles all of the processing associated with the
18
Instrument Connections dialog.
20
#_____________________________________________________________________
22
def __init__(self, project, parent):
25
self.project = project
29
self.res = gtk.glade.XML(parent.GLADE_PATH, "InstrumentConnectionsDialog")
32
"on_close_clicked" : self.OnClose,
35
self.res.signal_autoconnect(self.signals)
37
self.window = self.res.get_widget("InstrumentConnectionsDialog")
38
self.vbox = self.res.get_widget("vbox")
40
if len(self.project.instruments) > 0:
43
self.res.get_widget("explainLabel").set_text("There are no instruments to connect")
46
self.window.set_icon(self.parent.icon)
47
self.window.show_all()
49
#_____________________________________________________________________
51
def OnClose(self, button):
57
for device in AlsaDevices.GetAlsaList("capture").values():
59
#Don't want the default device twice (once as 'default' and once as its actual hw ref)
60
if device == "default":
63
mixer = gst.element_factory_make('alsamixer')
64
mixer.set_property("device", device)
65
mixer.set_state(gst.STATE_READY)
67
if not mixer.implements_interface(gst.interfaces.Mixer):
68
print 'Cannot get mixer tracks from the device. Check permissions on the mixer device.'
70
self.mixers[device] = mixer.list_tracks()
72
mixer.set_state(gst.STATE_NULL)
74
for instr in self.project.instruments:
79
image.set_from_pixbuf(instrument.pixbuf)
80
label = gtk.Label(instrument.name)
82
liststore = gtk.ListStore(gobject.TYPE_STRING)
83
combobox = gtk.ComboBox(liststore)
84
cell = gtk.CellRendererText()
85
combobox.pack_start(cell, True)
86
combobox.add_attribute(cell, 'text', 0)
91
for device in self.mixers:
92
mixertracks = self.mixers[device]
94
if t.flags & gst.interfaces.MIXER_TRACK_INPUT:
95
combobox.append_text(t.label)
96
if instr.inTrack and instr.input == device and t.label == instr.inTrack:
97
combobox.set_active(currentItem)
98
self.AlsaID.append(device)
101
combobox.connect("changed", self.OnSelected, instr)
102
row.pack_start(combobox, False, False)
103
row.pack_start(image, False, False)
104
row.pack_start(label, False, False)
108
def OnSelected(self, widget, instr):
109
'''Set the instrument's input'''
110
device = self.AlsaID[widget.get_active()]
111
mixertracks = self.mixers[device]
112
for track in mixertracks:
113
if track.label == widget.get_active_text():
114
inTrack = track.label
116
if device != instr.input or inTrack != instr.inTrack:
118
instr.inTrack = inTrack
119
self.project.unsavedChanges = True