2 # -*- coding: utf-8 -*-
4 # This file is part of jack_mixer
6 # Copyright (C) 2006-2009 Nedko Arnaudov <nedko@arnaudov.name>
7 # Copyright (C) 2009 Frederic Peters <fpeters@0d.be>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; version 2 of the License
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25 from argparse import ArgumentParser
28 gi.require_version('Gtk', '3.0')
29 from gi.repository import Gtk
30 from gi.repository import GObject
31 from gi.repository import GLib
33 # temporary change Python modules lookup path to look into installation
34 # directory ($prefix/share/jack_mixer/)
36 sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), '..', 'share', 'jack_mixer'))
44 from preferences import PreferencesDialog
46 from serialization_xml import XmlSerialization
47 from serialization import SerializedObject, Serializator
49 from nsmclient import NSMClient
51 # restore Python modules lookup path
54 class JackMixer(SerializedObject):
56 # scales suitable as meter scales
57 meter_scales = [scale.IEC268(), scale.Linear70dB(), scale.IEC268Minimalistic()]
59 # scales suitable as volume slider scales
60 slider_scales = [scale.Linear30dB(), scale.Linear70dB()]
62 # name of settngs file that is currently open
63 current_filename = None
65 _init_solo_channels = None
67 def __init__(self, client_name='jack_mixer'):
69 self.nsm_client = None
71 if os.environ.get('NSM_URL'):
72 self.nsm_client = NSMClient(prettyName = "jack_mixer",
73 saveCallback = self.nsm_save_cb,
74 openOrNewCallback = self.nsm_open_cb,
75 supportsSaveStatus = False,
76 hideGUICallback = self.nsm_hide_cb,
77 showGUICallback = self.nsm_show_cb,
78 exitProgramCallback = self.nsm_exit_cb,
79 loggingLevel = "error",
81 self.nsm_client.announceGuiVisibility(self.visible)
85 self.create_mixer(client_name, with_nsm = False)
87 def create_mixer(self, client_name, with_nsm = True):
88 self.create_ui(with_nsm)
89 self.mixer = jack_mixer_c.Mixer(client_name)
93 #self.mixer.midi_behavior_mode = self.gui_factory.midi_behavior_modes[self.gui_factory.get_midi_behavior_mode()]
95 self.window.set_title(client_name)
97 self.monitor_channel = self.mixer.add_output_channel("Monitor", True, True)
100 GLib.timeout_add(80, self.read_meters)
102 GLib.timeout_add(200, self.nsm_react)
103 GLib.timeout_add(50, self.midi_events_check)
105 def new_menu_item(self, title, callback=None, accel=None, enabled=True):
106 menuitem = Gtk.MenuItem.new_with_mnemonic(title)
107 menuitem.set_sensitive(enabled)
109 menuitem.connect("activate", callback)
111 key, mod = Gtk.accelerator_parse(accel)
112 menuitem.add_accelerator("activate", self.menu_accelgroup, key, mod,
113 Gtk.AccelFlags.VISIBLE)
116 def create_ui(self, with_nsm):
118 self.output_channels = []
119 self.window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
120 self.window.set_icon_name('jack_mixer')
121 self.gui_factory = gui.Factory(self.window, self.meter_scales, self.slider_scales)
122 self.gui_factory.connect('midi-behavior-mode-changed', self.on_midi_behavior_mode_changed)
123 self.vbox_top = Gtk.VBox()
124 self.window.add(self.vbox_top)
126 self.menu_accelgroup = Gtk.AccelGroup()
127 self.window.add_accel_group(self.menu_accelgroup)
129 self.menubar = Gtk.MenuBar()
130 self.vbox_top.pack_start(self.menubar, False, True, 0)
132 mixer_menu_item = Gtk.MenuItem.new_with_mnemonic("_Mixer")
133 self.menubar.append(mixer_menu_item)
134 edit_menu_item = Gtk.MenuItem.new_with_mnemonic('_Edit')
135 self.menubar.append(edit_menu_item)
136 help_menu_item = Gtk.MenuItem.new_with_mnemonic('_Help')
137 self.menubar.append(help_menu_item)
139 self.window.set_default_size(420, 420)
141 self.mixer_menu = Gtk.Menu()
142 mixer_menu_item.set_submenu(self.mixer_menu)
144 self.mixer_menu.append(self.new_menu_item('New _Input Channel',
145 self.on_add_input_channel, "<Control>N"))
146 self.mixer_menu.append(self.new_menu_item('New Output _Channel',
147 self.on_add_output_channel, "<Shift><Control>N"))
149 self.mixer_menu.append(Gtk.SeparatorMenuItem())
151 self.mixer_menu.append(self.new_menu_item('_Open...', self.on_open_cb, "<Control>O"))
153 self.mixer_menu.append(self.new_menu_item('_Save', self.on_save_cb, "<Control>S"))
156 self.mixer_menu.append(self.new_menu_item('Save _As...', self.on_save_as_cb,
157 "<Shift><Control>S"))
159 self.mixer_menu.append(Gtk.SeparatorMenuItem())
160 self.mixer_menu.append(self.new_menu_item('_Quit', self.on_quit_cb, "<Control>Q"))
162 edit_menu = Gtk.Menu()
163 edit_menu_item.set_submenu(edit_menu)
165 self.channel_edit_input_menu_item = self.new_menu_item('_Edit Input Channel',
167 edit_menu.append(self.channel_edit_input_menu_item)
168 self.channel_edit_input_menu = Gtk.Menu()
169 self.channel_edit_input_menu_item.set_submenu(self.channel_edit_input_menu)
171 self.channel_edit_output_menu_item = self.new_menu_item('E_dit Output Channel',
173 edit_menu.append(self.channel_edit_output_menu_item)
174 self.channel_edit_output_menu = Gtk.Menu()
175 self.channel_edit_output_menu_item.set_submenu(self.channel_edit_output_menu)
177 self.channel_remove_input_menu_item = self.new_menu_item('_Remove Input Channel',
179 edit_menu.append(self.channel_remove_input_menu_item)
180 self.channel_remove_input_menu = Gtk.Menu()
181 self.channel_remove_input_menu_item.set_submenu(self.channel_remove_input_menu)
183 self.channel_remove_output_menu_item = self.new_menu_item('Re_move Output Channel',
185 edit_menu.append(self.channel_remove_output_menu_item)
186 self.channel_remove_output_menu = Gtk.Menu()
187 self.channel_remove_output_menu_item.set_submenu(self.channel_remove_output_menu)
189 edit_menu.append(self.new_menu_item('_Clear', self.on_channels_clear, "<Control>X"))
190 edit_menu.append(Gtk.SeparatorMenuItem())
191 edit_menu.append(self.new_menu_item('_Preferences', self.on_preferences_cb, "<Control>P"))
193 help_menu = Gtk.Menu()
194 help_menu_item.set_submenu(help_menu)
196 help_menu.append(self.new_menu_item('_About', self.on_about, "F1"))
198 self.hbox_top = Gtk.HBox()
199 self.vbox_top.pack_start(self.hbox_top, True, True, 0)
201 self.scrolled_window = Gtk.ScrolledWindow()
202 self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
204 self.hbox_inputs = Gtk.Box()
205 self.hbox_inputs.set_spacing(0)
206 self.hbox_inputs.set_border_width(0)
207 self.hbox_top.set_spacing(0)
208 self.hbox_top.set_border_width(0)
209 self.scrolled_window.add(self.hbox_inputs)
210 self.hbox_outputs = Gtk.Box()
211 self.hbox_outputs.set_spacing(0)
212 self.hbox_outputs.set_border_width(0)
213 self.scrolled_output = Gtk.ScrolledWindow()
214 self.scrolled_output.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
215 self.scrolled_output.add(self.hbox_outputs)
216 self.paned = Gtk.HPaned()
217 self.paned.set_wide_handle(True)
218 self.hbox_top.pack_start(self.paned, True, True, 0)
219 self.paned.pack1(self.scrolled_window, True, False)
220 self.paned.pack2(self.scrolled_output, True, False)
222 self.window.connect("destroy", Gtk.main_quit)
224 self.window.connect('delete-event', self.on_delete_event)
227 self.nsm_client.reactToMessage()
230 def nsm_hide_cb(self):
233 self.nsm_client.announceGuiVisibility(False)
235 def nsm_show_cb(self):
236 self.window.show_all()
238 self.nsm_client.announceGuiVisibility(True)
240 def nsm_open_cb(self, path, session_name, client_name):
241 self.create_mixer(client_name, with_nsm = True)
242 self.current_filename = path + '.xml'
243 if os.path.isfile(self.current_filename):
244 f = open(self.current_filename, 'r')
245 self.load_from_xml(f)
248 f = open(self.current_filename, 'w')
251 def nsm_save_cb(self, path, session_name, client_name):
252 self.current_filename = path + '.xml'
253 f = open(self.current_filename, 'w')
257 def nsm_exit_cb(self, path, session_name, client_name):
260 def on_midi_behavior_mode_changed(self, gui_factory, value):
261 self.mixer.midi_behavior_mode = value
263 def on_delete_event(self, widget, event):
266 def sighandler(self, signum, frame):
267 #print "Signal %d received" % signum
268 if signum == signal.SIGUSR1:
270 elif signum == signal.SIGTERM:
272 elif signum == signal.SIGINT:
275 print("Unknown signal %d received" % signum)
278 print("Cleaning jack_mixer")
282 for channel in self.channels:
287 def on_open_cb(self, *args):
288 dlg = Gtk.FileChooserDialog(title='Open', parent=self.window,
289 action=Gtk.FileChooserAction.OPEN)
290 dlg.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
291 Gtk.STOCK_OPEN, Gtk.ResponseType.OK)
292 dlg.set_default_response(Gtk.ResponseType.OK)
293 if dlg.run() == Gtk.ResponseType.OK:
294 filename = dlg.get_filename()
296 f = open(filename, 'r')
297 self.load_from_xml(f)
298 except Exception as e:
299 err = Gtk.MessageDialog(parent = self.window,
301 message_type = Gtk.MessageType.ERROR,
302 buttons = Gtk.ButtonsType.OK,
303 text = "Failed loading settings (%s)." % str(e))
307 self.current_filename = filename
312 def on_save_cb(self, *args):
313 if not self.current_filename:
314 return self.on_save_as_cb()
315 f = open(self.current_filename, 'w')
319 def on_save_as_cb(self, *args):
320 dlg = Gtk.FileChooserDialog(title='Save', parent=self.window,
321 action=Gtk.FileChooserAction.SAVE)
322 dlg.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
323 Gtk.STOCK_SAVE, Gtk.ResponseType.OK)
324 dlg.set_default_response(Gtk.ResponseType.OK)
325 if dlg.run() == Gtk.ResponseType.OK:
326 self.current_filename = dlg.get_filename()
330 def on_quit_cb(self, *args):
333 preferences_dialog = None
334 def on_preferences_cb(self, widget):
335 if not self.preferences_dialog:
336 self.preferences_dialog = PreferencesDialog(self)
337 self.preferences_dialog.show()
338 self.preferences_dialog.present()
340 def on_add_input_channel(self, widget):
341 dialog = NewInputChannelDialog(app=self)
342 dialog.set_transient_for(self.window)
347 if ret == Gtk.ResponseType.OK:
348 result = dialog.get_result()
349 channel = self.add_channel(**result)
351 self.window.show_all()
353 def on_add_output_channel(self, widget):
354 dialog = NewOutputChannelDialog(app=self)
355 dialog.set_transient_for(self.window)
360 if ret == Gtk.ResponseType.OK:
361 result = dialog.get_result()
362 channel = self.add_output_channel(**result)
364 self.window.show_all()
366 def on_edit_input_channel(self, widget, channel):
367 print('Editing channel "%s"' % channel.channel_name)
368 channel.on_channel_properties()
370 def remove_channel_edit_input_menuitem_by_label(self, widget, label):
371 if (widget.get_label() == label):
372 self.channel_edit_input_menu.remove(widget)
374 def on_remove_input_channel(self, widget, channel):
375 print('Removing channel "%s"' % channel.channel_name)
376 self.channel_remove_input_menu.remove(widget)
377 self.channel_edit_input_menu.foreach(
378 self.remove_channel_edit_input_menuitem_by_label,
379 channel.channel_name);
380 if self.monitored_channel is channel:
381 channel.monitor_button.set_active(False)
382 for i in range(len(self.channels)):
383 if self.channels[i] is channel:
386 self.hbox_inputs.remove(channel.get_parent())
388 if not self.channels:
389 self.channel_edit_input_menu_item.set_sensitive(False)
390 self.channel_remove_input_menu_item.set_sensitive(False)
392 def on_edit_output_channel(self, widget, channel):
393 print('Editing channel "%s"' % channel.channel_name)
394 channel.on_channel_properties()
396 def remove_channel_edit_output_menuitem_by_label(self, widget, label):
397 if (widget.get_label() == label):
398 self.channel_edit_output_menu.remove(widget)
400 def on_remove_output_channel(self, widget, channel):
401 print('Removing channel "%s"' % channel.channel_name)
402 self.channel_remove_output_menu.remove(widget)
403 self.channel_edit_output_menu.foreach(
404 self.remove_channel_edit_output_menuitem_by_label,
405 channel.channel_name);
406 if self.monitored_channel is channel:
407 channel.monitor_button.set_active(False)
408 for i in range(len(self.channels)):
409 if self.output_channels[i] is channel:
411 del self.output_channels[i]
412 self.hbox_outputs.remove(channel.get_parent())
414 if not self.output_channels:
415 self.channel_edit_output_menu_item.set_sensitive(False)
416 self.channel_remove_output_menu_item.set_sensitive(False)
418 def rename_channels(self, container, parameters):
419 if (container.get_label() == parameters['oldname']):
420 container.set_label(parameters['newname'])
422 def on_channel_rename(self, oldname, newname):
423 rename_parameters = { 'oldname' : oldname, 'newname' : newname }
424 self.channel_edit_input_menu.foreach(self.rename_channels,
426 self.channel_edit_output_menu.foreach(self.rename_channels,
428 self.channel_remove_input_menu.foreach(self.rename_channels,
430 self.channel_remove_output_menu.foreach(self.rename_channels,
432 #print("Renaming channel from %s to %s\n" % (oldname, newname))
435 def on_channels_clear(self, widget):
436 dlg = Gtk.MessageDialog(parent = self.window,
438 message_type = Gtk.MessageType.WARNING,
439 text = "Are you sure you want to clear all channels?",
440 buttons = Gtk.ButtonsType.OK_CANCEL)
441 if not widget or dlg.run() == Gtk.ResponseType.OK:
442 for channel in self.output_channels:
444 self.hbox_outputs.remove(channel.get_parent())
445 for channel in self.channels:
447 self.hbox_inputs.remove(channel.get_parent())
449 self.output_channels = []
450 self.channel_edit_input_menu = Gtk.Menu()
451 self.channel_edit_input_menu_item.set_submenu(self.channel_edit_input_menu)
452 self.channel_edit_input_menu_item.set_sensitive(False)
453 self.channel_remove_input_menu = Gtk.Menu()
454 self.channel_remove_input_menu_item.set_submenu(self.channel_remove_input_menu)
455 self.channel_remove_input_menu_item.set_sensitive(False)
456 self.channel_edit_output_menu = Gtk.Menu()
457 self.channel_edit_output_menu_item.set_submenu(self.channel_edit_output_menu)
458 self.channel_edit_output_menu_item.set_sensitive(False)
459 self.channel_remove_output_menu = Gtk.Menu()
460 self.channel_remove_output_menu_item.set_submenu(self.channel_remove_output_menu)
461 self.channel_remove_output_menu_item.set_sensitive(False)
464 def add_channel(self, name, stereo, volume_cc, balance_cc, mute_cc, solo_cc, value):
466 channel = InputChannel(self, name, stereo, value)
467 self.add_channel_precreated(channel)
469 e = sys.exc_info()[0]
470 err = Gtk.MessageDialog(self.window,
471 Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
472 Gtk.MessageType.ERROR,
474 "Channel creation failed")
479 channel.channel.volume_midi_cc = volume_cc
481 channel.channel.autoset_volume_midi_cc()
483 channel.channel.balance_midi_cc = balance_cc
485 channel.channel.autoset_balance_midi_cc()
487 channel.channel.mute_midi_cc = mute_cc
489 channel.channel.autoset_mute_midi_cc()
491 channel.channel.solo_midi_cc = solo_cc
493 channel.channel.autoset_solo_midi_cc()
496 def add_channel_precreated(self, channel):
499 self.hbox_inputs.pack_start(frame, False, True, 0)
502 channel_edit_menu_item = Gtk.MenuItem(label=channel.channel_name)
503 self.channel_edit_input_menu.append(channel_edit_menu_item)
504 channel_edit_menu_item.connect("activate", self.on_edit_input_channel, channel)
505 self.channel_edit_input_menu_item.set_sensitive(True)
507 channel_remove_menu_item = Gtk.MenuItem(label=channel.channel_name)
508 self.channel_remove_input_menu.append(channel_remove_menu_item)
509 channel_remove_menu_item.connect("activate", self.on_remove_input_channel, channel)
510 self.channel_remove_input_menu_item.set_sensitive(True)
512 self.channels.append(channel)
514 for outputchannel in self.output_channels:
515 channel.add_control_group(outputchannel)
517 # create post fader output channel matching the input channel
518 channel.post_fader_output_channel = self.mixer.add_output_channel(
519 channel.channel.name + ' Out', channel.channel.is_stereo, True)
520 channel.post_fader_output_channel.volume = 0
521 channel.post_fader_output_channel.set_solo(channel.channel, True)
523 def read_meters(self):
524 for channel in self.channels:
526 for channel in self.output_channels:
530 def midi_events_check(self):
531 for channel in self.channels + self.output_channels:
532 channel.midi_events_check()
535 def add_output_channel(self, name, stereo, volume_cc, balance_cc, mute_cc,
536 display_solo_buttons, color, value):
538 channel = OutputChannel(self, name, stereo, value)
539 channel.display_solo_buttons = display_solo_buttons
540 channel.color = color
541 self.add_output_channel_precreated(channel)
543 err = Gtk.MessageDialog(self.window,
544 Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
545 Gtk.MessageType.ERROR,
547 "Channel creation failed")
553 channel.channel.volume_midi_cc = volume_cc
555 channel.channel.autoset_volume_midi_cc()
557 channel.channel.balance_midi_cc = balance_cc
559 channel.channel.autoset_balance_midi_cc()
561 channel.channel.mute_midi_cc = mute_cc
563 channel.channel.autoset_mute_midi_cc()
567 def add_output_channel_precreated(self, channel):
570 self.hbox_outputs.pack_end(frame, False, True, 0)
571 self.hbox_outputs.reorder_child(frame, 0)
574 channel_edit_menu_item = Gtk.MenuItem(label=channel.channel_name)
575 self.channel_edit_output_menu.append(channel_edit_menu_item)
576 channel_edit_menu_item.connect("activate", self.on_edit_output_channel, channel)
577 self.channel_edit_output_menu_item.set_sensitive(True)
579 channel_remove_menu_item = Gtk.MenuItem(label=channel.channel_name)
580 self.channel_remove_output_menu.append(channel_remove_menu_item)
581 channel_remove_menu_item.connect("activate", self.on_remove_output_channel, channel)
582 self.channel_remove_output_menu_item.set_sensitive(True)
584 self.output_channels.append(channel)
586 _monitored_channel = None
587 def get_monitored_channel(self):
588 return self._monitored_channel
590 def set_monitored_channel(self, channel):
591 if self._monitored_channel:
592 if channel.channel.name == self._monitored_channel.channel.name:
594 self._monitored_channel = channel
595 if type(channel) is InputChannel:
596 # reset all solo/mute settings
597 for in_channel in self.channels:
598 self.monitor_channel.set_solo(in_channel.channel, False)
599 self.monitor_channel.set_muted(in_channel.channel, False)
600 self.monitor_channel.set_solo(channel.channel, True)
601 self.monitor_channel.prefader = True
603 self.monitor_channel.prefader = False
604 self.update_monitor(channel)
605 monitored_channel = property(get_monitored_channel, set_monitored_channel)
607 def update_monitor(self, channel):
608 if self.monitored_channel is not channel:
610 self.monitor_channel.volume = channel.channel.volume
611 self.monitor_channel.balance = channel.channel.balance
612 self.monitor_channel.out_mute = channel.channel.out_mute
613 if type(self.monitored_channel) is OutputChannel:
614 # sync solo/muted channels
615 for input_channel in self.channels:
616 self.monitor_channel.set_solo(input_channel.channel,
617 channel.channel.is_solo(input_channel.channel))
618 self.monitor_channel.set_muted(input_channel.channel,
619 channel.channel.is_muted(input_channel.channel))
621 def get_input_channel_by_name(self, name):
622 for input_channel in self.channels:
623 if input_channel.channel.name == name:
627 def on_about(self, *args):
628 about = Gtk.AboutDialog()
629 about.set_name('jack_mixer')
630 about.set_copyright('Copyright © 2006-2020\nNedko Arnaudov, Frédéric Péters, Arnout Engelen, Daniel Sheeler')
631 about.set_license('''\
632 jack_mixer is free software; you can redistribute it and/or modify it
633 under the terms of the GNU General Public License as published by the
634 Free Software Foundation; either version 2 of the License, or (at your
635 option) any later version.
637 jack_mixer is distributed in the hope that it will be useful, but
638 WITHOUT ANY WARRANTY; without even the implied warranty of
639 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
640 General Public License for more details.
642 You should have received a copy of the GNU General Public License along
643 with jack_mixer; if not, write to the Free Software Foundation, Inc., 51
644 Franklin Street, Fifth Floor, Boston, MA 02110-130159 USA''')
646 'Nedko Arnaudov <nedko@arnaudov.name>',
647 'Christopher Arndt <chris@chrisarndt.de>',
648 'Arnout Engelen <arnouten@bzzt.net>',
649 'John Hedges <john@drystone.co.uk>',
650 'Olivier Humbert <trebmuh@tuxfamily.org>',
651 'Sarah Mischke <sarah@spooky-online.de>',
652 'Frédéric Péters <fpeters@0d.be>',
653 'Daniel Sheeler <dsheeler@pobox.com>',
654 'Athanasios Silis <athanasios.silis@gmail.com>',
656 about.set_logo_icon_name('jack_mixer')
657 about.set_website('https://rdio.space/jackmixer/')
662 def save_to_xml(self, file):
663 #print "Saving to XML..."
664 b = XmlSerialization()
669 def load_from_xml(self, file, silence_errors=False):
670 #print "Loading from XML..."
671 self.unserialized_channels = []
672 b = XmlSerialization()
679 self.on_channels_clear(None)
681 s.unserialize(self, b)
682 for channel in self.unserialized_channels:
683 if isinstance(channel, InputChannel):
684 if self._init_solo_channels and channel.channel_name in self._init_solo_channels:
686 self.add_channel_precreated(channel)
687 self._init_solo_channels = None
688 for channel in self.unserialized_channels:
689 if isinstance(channel, OutputChannel):
690 self.add_output_channel_precreated(channel)
691 del self.unserialized_channels
693 self.window.show_all()
695 def serialize(self, object_backend):
696 width, height = self.window.get_size()
697 object_backend.add_property('geometry',
698 '%sx%s' % (width, height))
699 pos = self.paned.get_position()
700 object_backend.add_property('paned_position', '%s' % pos)
702 for input_channel in self.channels:
703 if input_channel.channel.solo:
704 solo_channels.append(input_channel)
706 object_backend.add_property('solo_channels', '|'.join([x.channel.name for x in solo_channels]))
707 object_backend.add_property('visible', '%s' % str(self.visible))
709 def unserialize_property(self, name, value):
710 if name == 'geometry':
711 width, height = value.split('x')
712 self.window.resize(int(width), int(height))
714 if name == 'solo_channels':
715 self._init_solo_channels = value.split('|')
717 if name == 'visible':
718 self.visible = value == 'True'
720 if name == 'paned_position':
722 self.paned.set_position(pos)
726 def unserialize_child(self, name):
727 if name == InputChannel.serialization_name():
728 channel = InputChannel(self, "", True)
729 self.unserialized_channels.append(channel)
732 if name == OutputChannel.serialization_name():
733 channel = OutputChannel(self, "", True)
734 self.unserialized_channels.append(channel)
737 if name == gui.Factory.serialization_name():
738 return self.gui_factory
740 def serialization_get_childs(self):
741 '''Get child objects that required and support serialization'''
742 childs = self.channels[:] + self.output_channels[:] + [self.gui_factory]
745 def serialization_name(self):
753 self.window.show_all()
755 signal.signal(signal.SIGUSR1, self.sighandler)
756 signal.signal(signal.SIGTERM, self.sighandler)
757 signal.signal(signal.SIGINT, self.sighandler)
758 signal.signal(signal.SIGHUP, signal.SIG_IGN)
762 #f = file("/dev/stdout", "w")
767 parser = ArgumentParser()
768 parser.add_argument('-c', '--config', help='use a non default configuration file')
769 parser.add_argument('client_name', metavar='NAME', nargs='?', default='jack_mixer',
770 help='set JACK client name')
771 args = parser.parse_args()
774 mixer = JackMixer(args.client_name)
775 except Exception as e:
776 err = Gtk.MessageDialog(parent = None,
778 message_type = Gtk.MessageType.ERROR,
779 buttons = Gtk.ButtonsType.OK,
780 text = "Mixer creation failed (%s)" % str(e))
785 if not mixer.nsm_client and args.config:
786 f = open(args.config)
787 mixer.current_filename = args.config
790 mixer.load_from_xml(f)
791 except Exception as e:
792 err = Gtk.MessageDialog(parent = mixer.window,
794 message_type = Gtk.MessageType.ERROR,
795 buttons = Gtk.ButtonsType.OK,
796 text = "Failed loading settings (%s)." % str(e))
799 mixer.window.set_default_size(60*(1+len(mixer.channels)+len(mixer.output_channels)), 300)
806 if __name__ == "__main__":