def input_channel_serialization_name():
return "input_channel"
+
+class output_channel(channel):
+ def __init__(self, mixer, gui_factory, name, stereo):
+ channel.__init__(self, mixer, gui_factory, name, stereo)
+
+ def realize(self):
+ channel.realize(self)
+ self.channel = self.mixer.add_output_channel(self.channel_name, self.stereo)
+ if self.channel == None:
+ raise Exception,"Cannot create a channel"
+ channel.realize(self)
+
+ self.channel.midi_scale = self.slider_scale.scale
+ self.channel.midi_change_callback = self.midi_change_callback
+
+ self.on_volume_changed(self.slider_adjustment)
+ self.on_balance_changed(self.balance_adjustment)
+
+ # vbox child at upper part
+ self.vbox = gtk.VBox()
+ self.pack_start(self.vbox, False)
+ self.label_name = gtk.Label()
+ self.label_name.set_text(self.channel_name)
+ self.label_name.set_size_request(0, -1)
+ self.vbox.pack_start(self.label_name, False)
+ frame = gtk.Frame()
+ frame.set_shadow_type(gtk.SHADOW_IN)
+ frame.add(self.abspeak);
+ self.vbox.pack_start(frame, False)
+
+ # hbox child at lower part
+ self.hbox = gtk.HBox()
+ self.hbox.pack_start(self.slider, True)
+ frame = gtk.Frame()
+ frame.set_shadow_type(gtk.SHADOW_IN)
+ frame.add(self.meter);
+ self.hbox.pack_start(frame, True)
+ frame = gtk.Frame()
+ frame.set_shadow_type(gtk.SHADOW_IN)
+ frame.add(self.hbox);
+ self.pack_start(frame, True)
+
+ self.volume_digits.set_size_request(0, -1)
+ self.pack_start(self.volume_digits, False)
+
+ self.create_balance_widget()
+
+ def unrealize(self):
+ channel.unrealize(self)
+ self.channel = False
+
+ def serialization_name(self):
+ return output_channel_serialization_name()
+
+ def serialize(self, object_backend):
+ object_backend.add_property("name", self.channel_name)
+ if self.stereo:
+ object_backend.add_property("type", "stereo")
+ else:
+ object_backend.add_property("type", "mono")
+ channel.serialize(self, object_backend)
+
+ def unserialize_property(self, name, value):
+ if name == "name":
+ self.channel_name = str(value)
+ return True
+ if name == "type":
+ if value == "stereo":
+ self.stereo = True
+ return True
+ if value == "mono":
+ self.stereo = False
+ return True
+ return channel.unserialize_property(self, name, value)
+
+def output_channel_serialization_name():
+ return "output_channel"
+
class main_mix(channel):
def __init__(self, mixer, gui_factory):
channel.__init__(self, mixer, gui_factory, "MAIN", True)
'volume_cc': self.entry_volume_cc.get_text(),
'balance_cc': self.entry_balance_cc.get_text()
}
+
+class NewOutputChannelDialog(ChannelPropertiesDialog):
+ def __init__(self, parent, mixer):
+ gtk.Dialog.__init__(self, 'New Output Channel', parent)
+ self.mixer = mixer
+ self.create_ui()
+
+ # TODO: disable mode for output channels as mono output channels may
+ # not be correctly handled yet.
+ self.mode_hbox.set_sensitive(False)
+ self.stereo.set_active(True) # default to stereo
+
+ self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
+ self.add_button(gtk.STOCK_ADD, gtk.RESPONSE_OK)
+
+ def get_result(self):
+ return {'name': self.entry_name.get_text(),
+ 'stereo': self.stereo.get_active(),
+ 'volume_cc': self.entry_volume_cc.get_text(),
+ 'balance_cc': self.entry_balance_cc.get_text()
+ }
mixer_menu.append(add_input_channel)
add_input_channel.connect("activate", self.on_add_input_channel)
+ add_output_channel = gtk.ImageMenuItem('New _Output Channel')
+ mixer_menu.append(add_output_channel)
+ add_output_channel.connect("activate", self.on_add_output_channel)
+
if lash_client is None and xml_serialization is not None:
mixer_menu.append(gtk.SeparatorMenuItem())
open = gtk.ImageMenuItem(gtk.STOCK_OPEN)
self.hbox_top.set_spacing(0)
self.hbox_top.set_border_width(0)
self.channels = []
+ self.output_channels = []
self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.scrolled_window.add_with_viewport(self.hbox_inputs)
self.main_mix = main_mix(self.mixer, self.gui_factory)
self.main_mix.realize()
+ self.hbox_outputs = gtk.HBox()
+ self.hbox_outputs.set_spacing(0)
+ self.hbox_outputs.set_border_width(0)
frame = gtk.Frame()
frame.add(self.main_mix)
- self.hbox_top.pack_start(frame, False)
+ self.hbox_outputs.pack_start(frame, False)
+ self.hbox_top.pack_start(self.hbox_outputs, False)
self.window.connect("destroy", gtk.main_quit)
channel = self.add_channel(**result)
self.window.show_all()
+ def on_add_output_channel(self, widget):
+ dialog = NewOutputChannelDialog(parent=self.window, mixer=self.mixer)
+ dialog.set_transient_for(self.window)
+ dialog.show()
+ ret = dialog.run()
+ dialog.hide()
+
+ if ret == gtk.RESPONSE_OK:
+ result = dialog.get_result()
+ channel = self.add_output_channel(**result)
+ self.window.show_all()
+
def on_remove_channel(self, widget, channel, channel_remove_menu_item):
print 'Removing channel "%s"' % channel.channel_name
self.channel_remove_menu.remove(channel_remove_menu_item)
self.main_mix.read_meter()
return True
+ def add_output_channel(self, name, stereo, volume_cc, balance_cc):
+ try:
+ channel = output_channel(self.mixer, self.gui_factory, name, stereo)
+ self.add_output_channel_precreated(channel)
+ except Exception:
+ raise
+ err = gtk.MessageDialog(self.window,
+ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+ gtk.MESSAGE_ERROR,
+ gtk.BUTTONS_OK,
+ "Channel creation failed")
+ err.run()
+ err.destroy()
+ return
+ if volume_cc:
+ channel.channel.volume_midi_cc = int(volume_cc)
+ if balance_cc:
+ channel.channel.balance_midi_cc = int(balance_cc)
+ return channel
+
+ def add_output_channel_precreated(self, channel):
+ frame = gtk.Frame()
+ frame.add(channel)
+ self.hbox_outputs.pack_start(frame, False)
+ channel.realize()
+ # XXX: handle deletion of output channels
+ #channel_remove_menu_item = gtk.MenuItem(channel.channel_name)
+ #self.channel_remove_menu.append(channel_remove_menu_item)
+ #channel_remove_menu_item.connect("activate", self.on_remove_channel, channel, channel_remove_menu_item)
+ #self.channel_remove_menu_item.set_sensitive(True)
+ self.output_channels.append(channel)
+
def lash_check_events(self):
while lash.lash_get_pending_event_count(self.lash_client):
event = lash.lash_get_event(self.lash_client)
s = serializator()
s.unserialize(self, b)
for channel in self.unserialized_channels:
- self.add_channel_precreated(channel)
+ if isinstance(channel, input_channel):
+ self.add_channel_precreated(channel)
+ else:
+ self.add_output_channel_precreated(channel)
del self.unserialized_channels
self.window.show_all()
self.unserialized_channels.append(channel)
return channel
+ if name == output_channel_serialization_name():
+ channel = output_channel(self.mixer, self.gui_factory, "", True)
+ self.unserialized_channels.append(channel)
+ return channel
+
def serialization_get_childs(self):
'''Get child objects tha required and support serialization'''
- childs = self.channels[:]
+ childs = self.channels[:] + self.output_channels[:]
childs.append(self.main_mix)
return childs